ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* ctags and ConTeXt
@ 2007-02-12  4:55 Aditya Mahajan
  2007-02-26  7:01 ` Aditya Mahajan
  2007-02-26 23:02 ` Aditya Mahajan
  0 siblings, 2 replies; 10+ messages in thread
From: Aditya Mahajan @ 2007-02-12  4:55 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

I am wondering how others manage a large list of reference labels in 
ConTeXt. I use Vim as an editor and it supports ctags. ctags is a 
utility that is basically for supporting tags in programs (initially 
only for C, and hence the name), but can be used relatively easily 
with LaTeX. Basically, ctags creates a tag file with the format

<tag-name> <tag-file> <tag-regex>

(for details see http://ctags.sourceforge.net/FORMAT)

Suppose I have a bunch of references all starting from eq:. Then 
inside Vim, I can type eq: and  press ^X^T for Vim to search for the 
tags file with everything starting with eq: and I get to see all of 
them in a pop up menu. I can choose which ever label I want and 
continue. Further I can press ^] on a tag, and Vim jumps to the 
location of the tag, something like a hyperlink within the editor. I 
find both these features very useful while working for files with more 
than 50 tags.

Creating a tag file for LaTeX is easy, since in LaTeX all labels are 
created using \label{....}. So, you can instruct ctags (the program) 
to search the file for \label{...} and store the first argument to the 
tags file.

However, taking this approach with ConTeXt is almost impossible. 
Since the label is tied to the environment that creates it, it is 
impossible to parse. There is no way a reg-ex can determine if mylabel 
in \startproblem[mylabel] is an optional argument or a label. So, the 
only way to really get the label is through TeX itself. The tui file 
has some information, but it can be very hard to parse. A typical tui 
file has enteries like

c 
\mainreference{}{cite-nsf-193}{2--0-2-4-2-0-0-0--9}{11}{MarschakRadner:1972}
c \mainreference{}{fnt:f:2}{2--0-2-4-1-0-0-0--8}{10}{}
c 
\mainreference{}{sec:prelim}{2--0-2-4-1-0-0-0--8}{10}{{C.4.1}{Preliminaries}}

where the first two are auto-generated, while I only want the user 
entered tags to be stored. Suppose, one is willing to have the extra 
overhead of parsing every mainreference in the tag file. I can get the 
first two pieces of information for the tag file, the name of the tag 
and the file that it is in. But how do I get a regex (or linenumber) 
of where the tag is located in the file, so that ^] takes me to that 
tag. I can not figure out a regex which will take care of every case.

Is there some other way to proceed? What are those other numbers in 
\mainreferece, do they contain any information about the line in the 
source file that generated the tag. And more generally, what do others 
do to keep track of labels in large projects.

Aditya

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-02-27 15:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-12  4:55 ctags and ConTeXt Aditya Mahajan
2007-02-26  7:01 ` Aditya Mahajan
2007-02-26  8:14   ` Hans Hagen
2007-02-26 17:06     ` Aditya Mahajan
2007-02-26  9:17   ` Taco Hoekwater
2007-02-26 10:49     ` Hans Hagen
2007-02-26 17:13       ` Aditya Mahajan
2007-02-26 23:02 ` Aditya Mahajan
2007-02-27  8:54   ` Hans Hagen
2007-02-27 15:19     ` Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).