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

56637Re: New script: SmartTag (resolves ambiguous C++ tags etc)

Expand Messages
  • Lech Lorens
    May 1 3:51 AM
      On 28-Apr-2010 Robert Webb <stella4d@...> wrote:
      >
      > > - left a FIXME in the code stating that duplicate tags should be removed
      > > from the list returned by the user-defined function. Not quite sure,
      > > though, whether it wouldn't be better to leave it to the user.
      >
      > I don't think there's any point keeping them. They can never be of use if
      > all
      > details match (name, file, search command). Currently I have a function
      > called
      > UniqList() which does it. It's very inefficient (N^2). Would be more
      > efficiently handled in C. Maybe a uniq() function would be handy in
      > general,
      > to remove multiple copies in a list.
      >
      > Maybe a flag to taglist() requesting that duplicate entries be removed?

      What I meant is: if the user's function used in 'tagfunc' returns a list
      of tags, should I verify that there are no duplicates in the list? I'd
      say: no - leave it to the user to take care of what is returned.

      Another issue is whether taglist() should remove duplicates. It might be
      good to handle this but for now I'd rather stick to 'tagfunc' to get it
      done well.

      > > - maybe it would make some sense to let taglist() return a result
      > > returned by the 'tagfunc' function? taglist() could take an optional
      > > argument which would state whether recursion is allowed and an upper
      > > limit on the recursion level could be set. I can at least imagine
      > > a use case for such a feature (admittedly, awkward a bit).
      >
      > I don't know that an extra option is required. I think taglist() should
      > always
      > make use of 'tagfunc', unless called recursively from within the tag
      > function
      > itself. I guess an extra optional arg might be useful to allow the user to
      > avoid calling tagfunc if they wish.
      >
      > Hmm, I suppose taglist() won't know whether the 'c' flag should be used when
      > calling 'tagfunc'. Maybe we need to be able to pass this flag to taglist()
      > too so it can pass it through?

      OK, I'll think about this later.

      > Hmm, another small difference. My script presumes the tag name is complete,
      > whereas taglist() just searches, eg taglist("blah") will find tags for
      > "blabbyblahblab". Is this an issue?

      I have no problem with that.

      > Some other thoughts:
      >
      > - Another thing I need is a way to do more than one search in the tag command.
      [...]
      > - Gets a little trickier than above too, because I want to have access to
      > all
      > of vim's search capabilities in that tag command. The format of a search
      [...]
      > - Vim doesn't load all tags when it does a tag search. It looks at one file
      [...]

      It would be great to have all of them, but I consider them improvements
      to the basic functionality offered by 'tagfunc'. Once 'tagfunc' is
      implemented properly these can be considered.

      > - By the way, in TagFunc2() you should use "taglist('^' . pattern . '$')"
      > rather than "taglist('\<' . pattern . '\>')". The latter may miss some
      > non-alphabetic tags like operators. Not that it matters for a proof of
      > concept like this, but thought I'd mention it. Oh, I see this example is
      > in
      > the docs too, so all the more reason to do it the "proper" way. Not sure
      > it's the best example though, since not many tags will use line numbers
      > (for
      > me none of them do although not sure why).

      OK, I changed the example totally so this is a non-issue.

      > The script shouldn't be hard to convert for use with 'tagfunc'. Something
      > like
      > this:

      After my small adjustments works for me almost perfectly:

      function! SmartTagFunc(pattern, flags)
      if a:flags =~? 'c'
      let tags = []
      let id = GetNiceTagList(tags, 'nk')
      return tags
      else
      return taglist(a:pattern)
      endif
      endfunc

      I am having some problems with the code that I am working on.
      Unfortunately, I cannot share it so I will try to tackle the thing
      myself.

      Some news about 'tagfunc':
      I discovered that the 'tagfunc' implementation prevented omni completion
      for C from working when 'tagfunc' was set to the SmartTagFunc() function
      defined a few lines above. This was due to the fact that - as mentioned
      by the documentation - in each of the dictionaries returned by
      SmartTagFunc() only the entries 'name', 'filename' and 'cmd' are
      considered relevant. Without thinking too much I simply discarded all
      the other entries effectively filtering out the data essential to omni
      completion. The latest patch fixes the problem. Find it attached.

      --
      Cheers,
      Lech

      --
      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
    • Show all 25 messages in this topic