vi modeline -- another possible alternative using tags

gbergman at ucbtopaz.CC.Berkeley.ARPA gbergman at ucbtopaz.CC.Berkeley.ARPA
Thu May 3 05:53:35 AEST 1984


[Sorry for the two (three?) earlier munged versions of this message.
Seems our news-sending program has a prejudice against messages whose
first text-line begins with a space.  Here goes again!!]

     Having just broken the documentation barrier a few months ago
and figured out how to use vi tags, maybe I should begin by summarizing
these for anyone on the other side of the barrier.
     You give, generally in your EXINIT, the command

	:se tags=file.of.your.choice

     In that file, you keep a series of lines in a special format; here
are some random samples from my tags file (which I call ~/do/tags):

	c      /ca/fac/gbergman/.cshrc $-10
	clean  /ca/fac/gbergman/PS/new.mat/cleanup 1
	mocc   /ca/fac/gbergman/MOC/MOC/cyclic 1
	pml    /ca/fac/gbergman/Papers/Mailing/list 1
	tabr   /usr/lib/term/tabnew/README 1
	tags   /ca/fac/gbergman/do/tags 1
	thm    /ca/fac/gbergman/This/mistake.log $

     Now if I should, say, want to modify something in my .cshrc file
(I'm always fooling with new aliases) and I happen to be in the editor,
I write the buffer and then give the command

	:ta c

and I am immediately put into that file 10 lines from the bottom (as
specified by the right-most part of the tag entry ``c'').  If I
don't happen to be in the editor, I can get in at that point using

	% vi -t c

If one keeps the entries of this file limited to items of current (or
perennial) importance, (for which purpose it helps to have a tag for
the tags file itself, as above) it can be extremely convenient.
     With this introduction, I leave it to you to learn about the
default value of the tabs setting (useful only if you have, and are
interested in, source-files for UNIX commands) and other details,
from the Ex Reference Manual, pointing out only that (1) the results can
be very confusing if you forget that tag entries must be alphabetized,
and (2) the syntax for specifying more than one tag file is

	:se tags=file1\ file2

     Now to the point: the rightmost item in a line of the tags-file
is an address-specification.  Though I seldom need anything more
sophisticated than 1 or $, the ``usual'' kind of specification (e.g.
in the default file) is a pattern-search, executed (with nomagic set)
as one enters the file.  Why not more generally allow it to be an
arbitrary   c o m m a n d    to be executed on entering the file?
     This would allow the same sort of file-tailored initialization
that ``modeline'' was set up for, but being specific to the user who
specifies the given tag file, it would not allow the kind of malicious
traps possible with modeline.

     As a nonhacker, I can't write the code; can one of you?

		George Bergman
			(preferred address: gbergman at ucbcartan;
			but I post from topaz.cc because
			ucbcartan doesn't subscribe to net.news)



More information about the Comp.unix.wizards mailing list