On 21-Apr-2010 Robert Webb <[email protected]> wrote:
> Lech Lorens wrote:
>
> > I was about to get to implementing the 'tagfunc' option so I will gladly
> > volunteer for this task.
>
> You were about to do it anyway? I asked about the possibility a year ago,
> did
> it make it to a to-do list somewhere?
>From todo.txt:
8 Use a mechanism similar to omni completion to figure out the kind of tab
for CTRL-] and jump to the appropriate matching tag (if there are
several).
Alternative: be able to define a function that takes the tag name and uses
taglist() to find the right location. With indication of using CTRL-] so
that the context can be taken into account. (Robert Webb)
I'd also like some better way to navigate around C code than cscope
currently offers. I was hoping to be able to use the Netbeans interface
and the Clang C compiler to get that. This will, however, have to wait
a moment.
> > - I think that making it an autoload script would be a good idea,
> > - I'd define an interface for the script: pick some functions made
> > available to the user, make the other ones local (e.g. change the name
> > of CursorChar() to s:CursorChar()),
> > - would you like to pick a license for your script?
>
> These are all things I don't know much about. Vim scripts have different
> licenses? Man, didn't know anyone worried about that.
Well... Since you claimed you didn't have much time, I immediately
assumed you would not address any problems with SmartTags. I intended to
fix any problems and then simply to share the results with others.
I wanted to be sure that you didn't have any objections.
> > - I managed to break it (sorry!): I modified the example C++ code in
> > such a way that - although I get the right results - I also get lots
> > of error messages. I attached the two C++ source files and the tags
> > file. The instruction for getting the errors is at the end of the .cpp
> > file,
>
> Don't apologise, it's good that you found a bug and reported it so clearly.
>
> It was because your tags file was created in a different way to mine.
> Mine has search patterns for #defined, whereas yours specifies line numbers,
> and although my code attempted to handle it, I suppose I never tested it!
> (Or possibly broke it after I did). I've fixed it. New script attached.
Should I have run Ctags in any special way? I simply ran
"ctags --fields=+iS filenames..."
> > Hooray!
> > It works for C. My C code was simply written in a way that revealed an
> > issue with the script. Here's a patch for this problem and for the
> > beep.
>
> Hmm, not sure about either of those patches. I presume the earlier one is
> to
> fix the beep? (I have beeps disabled, although I can't figure out how!).
> The "normal [{" is different from the search() call you used, by only
> jumping
> to outer levels of the {...} nesting. The search() would find any "{",
> possibly not an outer nesting, and I think that would be more likely to
> break.
> Better if there's a way to stop "normal [{" from beeping. Is there?
Obviously - search() is wrong. But then there is searchpair() (which
doesn't beep!)...
searchpair('{', '', '}', 'bW')
My experience is that it tends to be slow in large files, however.
":help beep" says:
When no beep or flash is wanted, use ":set vb t_vb=".
So avoiding the beep should be doable without searchpair(). How about
the attached patch?
> I presume the second patch fixes your C code? You must have structs defined
> in
> a column that isn't the first. The search deliberately looks only in the
> first
> column because in a later column it may not be defining a struct/class, but
> rather defining the type of a function or other member. In fact, I think I
> ran
> into that error which is why I added the "^", but looks like I forgot in the
> subsequent similar case. Hmm, I did make sure there was no ";" for the rest
> of
> the line, but I guess there may not be if it's the return type of a
> function.
> ... OK, I've fixed it another way, so test the attached script. Could you
> give
> me a sample of the code that broke it?
It was due to a "typedef":
typedef struct structname {
//
}
Since a few lines below the regexp did not specify "^", I assumed that
it was only a typo and removed it. Didn't analyze your script very
thoroughly...
Do you by any chance have any tests for your script? Today at work
I encountered two cases where SmartTags did not yield the right result
(maybe it was due to one of my two modifications...). I'll try to fix
them but would feel safer if I had some tests.
If there are no tests - I'll prepare some for C myself. I don't feel
that comfortable with C++, though.
--
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
Subscription settings: http://groups.google.com/group/vim_dev/subscribe?hl=en
diff --git a/_vimSmartTags.vim b/_vimSmartTags.vim
index 31487b3..fb76231 100644
--- a/_vimSmartTags.vim
+++ b/_vimSmartTags.vim
@@ -440,7 +440,14 @@ func! GetThisClass()
let firstTime = 1
while (1)
let origCursor = getpos(".")
+ " To avoid the annoying beeping caused by failing [{, switch to using
+ " the visual bell, but make the visual bell do nothing:
+ let save_vb=&vb
+ let save_t_vb=&t_vb
+ set vb t_vb=
normal [{
+ let &vb=save_vb
+ let &t_vb=save_t_vb
let oldCursor = getpos(".")
if (!firstTime && oldCursor == origCursor)
break " We're stuck at start of outer {..} block.