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

69077Re: [Patch] Refine listed tags with regex

Expand Messages
  • Lech Lorens
    Apr 14, 2013
      On 29-Mar-2013 Cody Cutler <ccutler@...> wrote:
      > Hello list. The attached patch allows optional regexs to be passed to
      > :tj and friends. these regexs is then used to further refine available
      > tags before they are printed.
      > This patch is useful when you have many tags for a single identifier.
      > For example, suppose a large C++ project has initialize() methods for
      > 100s of classes. Going through the list of tags printed by :tj is
      > tedious. Most of the time I know additional information about the
      > identifier I am looking for like the containing object type or source
      > filename. The text after the '/' in the argument is used as a regex
      > (unless a '/' is the first character of the tag identifier, then the
      > text after the second '/' is used) to match against the "other" tag
      > fields (which often contains the containing type name). If a '!' is
      > present, text after it is used to match against filenames. With this
      > patch you can type:
      > :tj initialize/SomeClass
      > to list all tags that also contain "SomeClass" in their "other" fields
      > or
      > :ts initialize/!arch/amd64
      > to list all tags matching initialize that contain "arch/amd64" in the
      > containing file's pathname. Or a mix:
      > :ts initialize/SomeClass!arch/amd64
      > The '/' and '!' characters were chosen somewhat arbitrarily--I'm not
      > sure if they are a safe choice.
      > Any comments are appreciated.

      I've been thinking about your proposed patch and I would have one
      problem with it: it doesn't seem intuitive and although I do work with
      software projects with quite large amounts of source code, I don't think
      I would use it much (because I wouldn't be able to remember all the
      quirks of the command).

      However, I think that there is a very simple solution to your problem
      which does not require changing the behaviour of Vim itself: create
      a command in VimL which will do everything you need. For this command
      I would use the following:
      - input() – for getting the name of the tag to jump to,
      - taglist() – to get a list of tags matching what the user chose to
      - input() – to get the name of the class,
      - input() – to get the file name pattern,
      - match() – to filter the tag list returned by taglist() with the
      criteria based on the values input by the user,
      - setqflist(), setloclist() – to create a list displayed in the quickfix
      window (:copen, :lopen),
      - inputlist() – perhaps instead of using setqflist() to make the
      experience akin to using :tselect.

      I believe that using such a command should be much more pleasant than
      poring through hundreds of lines of output generated by grep. And it has
      the potential of being more user-friendly – whenever you use input(),
      you can help the user by providing a hint in the prompt.

      What do you think? I'll be happy to hear from you.


      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 5 messages in this topic