Loading ...
Sorry, an error occurred while loading the content.

Re: matchit support for python

Expand Messages
  • Edward Peschko
    ... wow.. that s cool.. any chance on getting that included with the standard distribution (and maybe making matchit.vim automatically call it instead if your
    Message 1 of 11 , Aug 2, 2004
    • 0 Attachment
      On Mon, Aug 02, 2004 at 09:56:58PM -0400, Dan Sharp wrote:
      > Edward Peschko wrote:
      > >hey,
      > >
      > >Now that I've got matchit working (thanks much) I'm wondering if there
      > >is something similar for python. Unfortunately, since python doesn't
      > >have any keywords to bounce against, just intelligent whitespace, I don't
      > >see how it could fit into the matchit paradigm.
      > >
      > >Is there are plugin specifically for python?
      >
      > From Benji Fisher, the maker of matchit.vim, comes python_match.vim,
      > the matchit.vim for python, available at
      >
      > http://www.vim.org/scripts/script.php?script_id=386
      >
      > Dan Sharp

      wow.. that's cool.. any chance on getting that included with the standard
      distribution (and maybe making matchit.vim automatically call it instead
      if your filetype so happens to be equal to python?

      Ed
    • Bram Moolenaar
      ... I am a bit conservative about changing the default way % works for specific types of files. And the other mappings defined by python_match.vim may
      Message 2 of 11 , Aug 31, 2004
      • 0 Attachment
        Edward Peschko wrote:

        > > >Now that I've got matchit working (thanks much) I'm wondering if there
        > > >is something similar for python. Unfortunately, since python doesn't
        > > >have any keywords to bounce against, just intelligent whitespace, I don't
        > > >see how it could fit into the matchit paradigm.
        > > >
        > > >Is there are plugin specifically for python?
        > >
        > > From Benji Fisher, the maker of matchit.vim, comes python_match.vim,
        > > the matchit.vim for python, available at
        > >
        > > http://www.vim.org/scripts/script.php?script_id=386
        > >
        > > Dan Sharp
        >
        > wow.. that's cool.. any chance on getting that included with the standard
        > distribution (and maybe making matchit.vim automatically call it instead
        > if your filetype so happens to be equal to python?

        I am a bit conservative about changing the default way "%" works for
        specific types of files. And the other mappings defined by
        python_match.vim may conflict with what a user defines himself.

        For the same reason the matchit plugin isn't enabled by default. It is
        included in the distribution, thus it's just a matter of enabling it
        when you want to.

        --
        hundred-and-one symptoms of being an internet addict:
        253. You wait for a slow loading web page before going to the toilet.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
      • Edward Peschko
        ... well, I don t mind having to do a source statement in order to get it running, but it would be cool to include it as part of the standard distribution so I
        Message 3 of 11 , Aug 31, 2004
        • 0 Attachment
          > > wow.. that's cool.. any chance on getting that included with the standard
          > > distribution (and maybe making matchit.vim automatically call it instead
          > > if your filetype so happens to be equal to python?
          >
          > I am a bit conservative about changing the default way "%" works for
          > specific types of files. And the other mappings defined by
          > python_match.vim may conflict with what a user defines himself.

          >
          > For the same reason the matchit plugin isn't enabled by default. It is
          > included in the distribution, thus it's just a matter of enabling it
          > when you want to.

          well, I don't mind having to do a source statement in order to get it running,
          but it would be cool to include it as part of the standard distribution so
          I don't need to download it separately.

          Ed
        • Bram Moolenaar
          ... The matchit plugin is included. It s probably not a bad idea if the Python version would be merged into it. Would anybody want the matchit functionality
          Message 4 of 11 , Sep 1, 2004
          • 0 Attachment
            Edward Peschko wrote:

            > > > wow.. that's cool.. any chance on getting that included with the
            > > > standard distribution (and maybe making matchit.vim automatically
            > > > call it instead if your filetype so happens to be equal to python?
            > >
            > > I am a bit conservative about changing the default way "%" works for
            > > specific types of files. And the other mappings defined by
            > > python_match.vim may conflict with what a user defines himself.
            > >
            > > For the same reason the matchit plugin isn't enabled by default. It is
            > > included in the distribution, thus it's just a matter of enabling it
            > > when you want to.
            >
            > well, I don't mind having to do a source statement in order to get it
            > running, but it would be cool to include it as part of the standard
            > distribution so I don't need to download it separately.

            The matchit plugin is included. It's probably not a bad idea if the
            Python version would be merged into it. Would anybody want the matchit
            functionality but not the extra Python stuff?

            Otherwise we could include matchit_python.vim as well, and instruct
            users to install that additionally. This is more complicated, thus it
            would be good if we can avoid that.

            --
            MAN: Fetchez la vache!
            GUARD: Quoi?
            MAN: Fetchez la vache!
            "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
            \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
          • Benji Fisher
            ... That would require a change to matchit.vim . Currently, the only customization for different file types is that matchit.vim looks for a list of regular
            Message 5 of 11 , Sep 3, 2004
            • 0 Attachment
              On Wed, Sep 01, 2004 at 12:03:01PM +0200, Bram Moolenaar wrote:
              >
              > Edward Peschko wrote:
              >
              > > > > wow.. that's cool.. any chance on getting that included with the
              > > > > standard distribution (and maybe making matchit.vim automatically
              > > > > call it instead if your filetype so happens to be equal to python?

              > > > ...
              > > > For the same reason the matchit plugin isn't enabled by default. It is
              > > > included in the distribution, thus it's just a matter of enabling it
              > > > when you want to.
              > >
              > > well, I don't mind having to do a source statement in order to get it
              > > running, but it would be cool to include it as part of the standard
              > > distribution so I don't need to download it separately.
              >
              > The matchit plugin is included. It's probably not a bad idea if the
              > Python version would be merged into it. Would anybody want the matchit
              > functionality but not the extra Python stuff?
              >
              > Otherwise we could include matchit_python.vim as well, and instruct
              > users to install that additionally. This is more complicated, thus it
              > would be good if we can avoid that.

              That would require a change to matchit.vim . Currently, the only
              customization for different file types is that matchit.vim looks for a
              list of regular expressions (usually defined in the ftplugin file) that
              define matching pairs. I suppose the simplest thing to do would be to
              look for a function like Matchit_python(); if the function exists and
              returns a non-zero value, then use it to decide where to jump;
              otherwise, continue as normal. The Matchit_python() function would be
              perhaps half as long as the current python_match.vim file, and would
              probably have to be defined in the ftplugin file.

              Another possibility is to add a new file to the distribution:
              $VIMRUNTIME/python_matchit.vim . Unlike the current python_matchit.vim,
              this would define only the Matchit_python() function, not actually remap
              % . The maintainer of the distribution would have to do this, not the
              maintainer of the standard ftplugin file. It might be a good thing to
              have an example in the standard distribution of a plugin with this sort
              of naming convention.

              The only other language I know where this might be useful is TeX.
              Matchit.vim can bounce between \begin{foo} and \end{foo}, but not
              between $ and $.

              HTH --Benji Fisher
            • Bram Moolenaar
              ... That should not be much of a problem. Most important is that the user can activate matchit.vim and get support for all languages. Exceptions make it more
              Message 6 of 11 , Sep 3, 2004
              • 0 Attachment
                Benji Fisher wrote:

                > > The matchit plugin is included. It's probably not a bad idea if the
                > > Python version would be merged into it. Would anybody want the matchit
                > > functionality but not the extra Python stuff?
                > >
                > > Otherwise we could include matchit_python.vim as well, and instruct
                > > users to install that additionally. This is more complicated, thus it
                > > would be good if we can avoid that.
                >
                > That would require a change to matchit.vim .

                That should not be much of a problem. Most important is that the user
                can activate matchit.vim and get support for all languages. Exceptions
                make it more complicated for the user.

                > Currently, the only
                > customization for different file types is that matchit.vim looks for a
                > list of regular expressions (usually defined in the ftplugin file) that
                > define matching pairs. I suppose the simplest thing to do would be to
                > look for a function like Matchit_python(); if the function exists and
                > returns a non-zero value, then use it to decide where to jump;
                > otherwise, continue as normal. The Matchit_python() function would be
                > perhaps half as long as the current python_match.vim file, and would
                > probably have to be defined in the ftplugin file.

                Defining a function in the filetype plugin, instead of/besides giving a
                value to b:match_words, appears to be a logical thing to do. Perhaps a
                b:match_function variable needs to be set? Or would the existence of
                the function with a specific name be sufficient? The function would
                need to be global though, can't select it on a per-buffer basis.

                > Another possibility is to add a new file to the distribution:
                > $VIMRUNTIME/python_matchit.vim . Unlike the current python_matchit.vim,
                > this would define only the Matchit_python() function, not actually remap
                > % . The maintainer of the distribution would have to do this, not the
                > maintainer of the standard ftplugin file. It might be a good thing to
                > have an example in the standard distribution of a plugin with this sort
                > of naming convention.

                This adds a new type of file in a specific place. I don't think this is
                attractive.

                > The only other language I know where this might be useful is TeX.
                > Matchit.vim can bounce between \begin{foo} and \end{foo}, but not
                > between $ and $.

                Others might pop up later, thus if we find a generic solution (without
                disadvantages) that would be good.

                --
                GALAHAD: No. Look, I can tackle this lot single-handed!
                GIRLS: Yes, yes, let him Tackle us single-handed!
                "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

                /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
              • Charles E. Campbell, Jr.
                ... With a function, highlighting can be used to help with figuring out what the matching pair is, too (see
                Message 7 of 11 , Sep 3, 2004
                • 0 Attachment
                  Benji Fisher wrote:

                  >
                  >...Currently, the only
                  >customization for different file types is that matchit.vim looks for a
                  >list of regular expressions (usually defined in the ftplugin file) that
                  >define matching pairs. I suppose the simplest thing to do would be to
                  >look for a function like Matchit_python(); if the function exists and
                  >returns a non-zero value, then use it to decide where to jump;
                  >otherwise, continue as normal.
                  >

                  With a function, highlighting can be used to help with figuring out what
                  the matching pair
                  is, too (see http://vim.sourceforge.net/scripts/script.php?script_id=848
                  for something related).

                  Regards,
                  Chip Campbell
                • Benji Fisher
                  ... Yes, matchit already uses synID() and related functions in order to skip quotes( and //comments) . I guess I should not have written only in the bit
                  Message 8 of 11 , Sep 6, 2004
                  • 0 Attachment
                    On Fri, Sep 03, 2004 at 11:42:14AM -0400, Charles E. Campbell, Jr. wrote:
                    > Benji Fisher wrote:
                    >
                    > >
                    > >...Currently, the only
                    > >customization for different file types is that matchit.vim looks for a
                    > >list of regular expressions (usually defined in the ftplugin file) that
                    > >define matching pairs. I suppose the simplest thing to do would be to
                    > >look for a function like Matchit_python(); if the function exists and
                    > >returns a non-zero value, then use it to decide where to jump;
                    > >otherwise, continue as normal.
                    >
                    > With a function, highlighting can be used to help with figuring out what
                    > the matching pair
                    > is, too (see http://vim.sourceforge.net/scripts/script.php?script_id=848
                    > for something related).

                    Yes, matchit already uses synID() and related functions in order to
                    skip "quotes(" and //comments) . I guess I should not have written
                    "only" in the bit quoted above.

                    :help matchit-configure

                    --Benji Fisher
                  Your message has been successfully submitted and would be delivered to recipients shortly.