[comp.editors] Vi: Macro Challange... tags..^].. one better

jww@cpqhou.uucp (Jeff Wolford) (01/27/91)

Here is the simple challange:

First I want to be able to create a key just like ^] only that it uses
the W definition of a word instead of w...

Q: ie how do you yank a word (yW) and have it spit back out after
	a ":ta " is typed... given that I want to be able to map it
	to a key...

NOW for the REAL challange:

Given this I might be able to get the following (which is really what 
I want...) to work..

1 - I have a tag file that has several entries that are the same but
	point to different files and different locations,

what I would like to do is have it so that when I type ^] on a
	variable in a file, it looks in the tag file and then goes
	to the file where that variable is changed,
	(ok, so far the standard ^] works just fine).

But, since a variable can be changed in more than one routine,
	I have the variable name listed several times in the tag
	file (yes all sorted, and I have the script to generate it)....

	But when I type ^] again I want vi to "tag" to the second entry
	in the file and then the third ..fourth..etc and finally back
	to the first

Yes I have the ability to add a _1 ... _9 to the tag entry name to make
	each tag unique, but would prefer that it be a postpend so that
	all the entries are together after they are sorted...

My Thoughts:

I figure that if I can get a macro that takes the current word (with W
	definition), yank it and put it after a :ta pW, I can force
	a _1 after the yanked word... and then change the variable that
	has the _1 to a _2...etc and would be ready for the next
	invocation and if I don't find the tag, set it back to _1...


Jeff Wolford		uunet!cpqhou!jww
Compaq Computer Corp
(713) 374-9465
#include <standard.disclaimer>
-- 
Jeff Wolford		uunet!cpqhou!jww
Compaq Computer Corp
(713) 374-9465

em@dce.ie (Eamonn McManus) (01/30/91)

jww@cpqhou.uucp (Jeff Wolford) writes:
>	But when I type ^] again I want vi to "tag" to the second entry
>	in the file and then the third ..fourth..etc and finally back
>	to the first

One hacky possibility would be to have several tags files, as many as there
can be entries for variables.  For instance, if variable `v' has three
entries, then the files tags1, tags2, tags3 could look like this:

tags1:	v	filea	/patterna/=|set tags=tags2
tags2:	v	fileb	/patternb/=|set tags=tags3
tags3:	v	filec	/patternc/=|set tags=tags1

For other variables with fewer entries you can just duplicate the tags1
entries in the later tags files.  There are lots of problems with this way
of doing things, such as that a :tag will end you up at an essentially
random one of the entries (depending on the current tags file), and vi
insists on printing out the matched line and saying [Hit return to
continue] if you just say /pattern/; the = causes it to print the matched
line number instead and not wait for a key.

,
Eamonn