What kind of information do you want to put into the tag file?
You can teach ctags to use arbitrary regular expressions
Eg this will teach ctags to match the name after the class and mark it
as a "c" tag:
'--regex-PHP=/abstract class ([^ ]*)/\1/c/'
Can you rephrase your question and tell what kind of tags you'd like to
get? I imagine something like this:
How can I tag all \subsection{title} titles and jump to them?
Have you already used tags before?
Marc Weber
My exuberant ctags doesn't seem to support .tex or LaTeX natively:
marc %ctags --list-languages
Asm
Asp
Awk
Basic
BETA
C
C++
C#
Cobol
Eiffel
Erlang
Fortran
HTML
Java
JavaScript
Lisp
Lua
Make
Pascal
Perl
PHP
Python
REXX
Ruby
Scheme
Sh
SLang
SML
SQL
Tcl
Vera
Verilog
Vim
YAC
Perhaps I've missed something in this thread, but I don't think you have
mentioned your problem. Generally, people reading a mailing list don't
want to click links to read someone's question.
Unless the situation has changed, your problem is that you are running
on Windows and are trying to add LaTeX as a language to ctags, as
described at [1].
Your first attempt resulted in an error from ctags:
ctags.exe: Warning: regex support not available; required for --langdef
option
You then used the ctags FAQ [2] to download the GNU regex package for
Win32 from [3].
Your current problem (I think) is that the regex package from [3] is
corrupt and can't be installed.
I'm interested in making the tip work for Windows users, or at least
recording that it won't work, so I downloaded the file from [3]. I did
not run it, but I used two different unzip programs to examine it. One
listed the contents, but gave an error on trying to extract any file.
The other just said the file was corrupt. I notice that the package is
from 1997, but some quick searching failed to find anything newer.
So, unless someone here happens to know the solution, I think you need
to ask on a ctags mailing list.
[1] http://vim.wikia.com/wiki/Use_Taglist_with_LaTeX_files
[2] http://ctags.sourceforge.net/faq.html#14
[3] http://people.delphiforums.com/gjc/gnu_regex.html
John
Spot on. I didn't intend to click the links, but now that you've got
some of the content out in the open, perhaps I can help.
> You then used the ctags FAQ [2] to download the GNU regex package for
> Win32 from [3].
>
> Your current problem (I think) is that the regex package from [3] is
> corrupt and can't be installed.
Perhaps try getting the GNU regex package for Windows from here:
http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=73286&release_id=140957
I have had success with it cross-compiling some other software, so I'm
fairly confident it will work! You may need to rename some files or give
ctags' ./configure some arguments or something to get it to recognise
it (since it's not called simply libregex but libgnurx or something).
Ben.
I am the maintainer and author of a few of the Exuberant Tags parsers.
I know nothing about Latex, but I did look briefly at this page:
http://en.wikibooks.org/wiki/TeX#The_Structure_of_TeX
If someone could provide a small (but useful) Tex program and indicate
which tags should be identified, and the rules by which to identify
it, I could consider how much work it would be to add it.
If I recall on this list, there is other talk about ReTex (or something).
Is there different dialects of Tex?
Dave
Likewise, here's a section that I give to my students when I ask them to
submit their assignments in LaTeX.
http://www.ece.osu.edu/~pavlict/ece327/#latex_help
I have a simple "Hello world!" example.
> TeX is a generic language.
It's probably better to think about something like ASCIIDOC, which
should be very familiar to most readers of this list. ASCIIDOC now
allows you to include TeX math snippets. In many cases, ASCIIDOC
competes with TeX for certain applications.
> There are some extensions of it.
These extensions (e.g., eTeX) are very technical. As far as Vim is
concerned, there are no significant differences.
> The most popular (and common) is LaTeX.
TeX allows you to define macros to simplify common tasks (so you don't
have primitives floating around everywhere). "LaTeX", "Plain TeX", and
"ConTeXt" are the three common sets of macros.
Arguably, LaTeX is the most popular of the macro'd forms, and the pure
TeX form doesn't have the same type of pre-defined sections. So it's
probably best to focus on LaTeX (until the ConTeXt people start bitching).
> Furthermore bibtex and tetex.
BibTeX and teTeX are not extensions.
*) teTeX is a distribution, like Ubuntu is a distribution of Linux.
teTeX has been deprecated. For modern distributions, see the link above.
*) BibTeX is an EXTERNAL PROGRAM used to manage bibliographies and
produce a properly formatted list of references. That being said, BibTeX
has its own "bibliography database files" as well as "bibliography style
files." The former have a pretty simple syntax. The latter uses a
post-fix (e.g., like RPN) programming language to setup how to generate
the properly formatted references.
> subsubsection
> subsection
> section
> chapter
Every document has different levels of sections, just like you can have
nested loops in programming languages.
Each of these defines the beginning of a new section.
\part{The Early Years} (Part I: The Early Years)
\chapter{Teenage Lust} (Chapter 5: Teenage Lust)
\section{Introduction} (Section 1: Introduction)
\subsection{
But you'll also have to recognize the starred and optional argument
versions (which exist for all of those above), like...
\section[optional shortname]{Long name}
\subsection*{Unnumbered section}
Finally, every LaTeX document will start with a documentclass line:
\documentclass[optional arg,optional arg,optional arg]{name}
OR
\documentclass{name}
And after the LaTeX preamble starts a document "environment."
\begin{document}
...
\end{document}
Plus, you can have macros defining major sections of the source... like...
\frontmatter
\backmatter
\appendix
\bibliography{...}
Oh, and every macro (\macro) eats all whitespace (including newlines)
after it.
Comments start with % anywhere in the line, and that % eats all
whitespace after it and STARTING on the NEXT LINE.
--Ted
--
Ted Pavlic <t...@tedpavlic.com>
If you can build ctags from source I have checked in a tex parser.
Looks for files with .tex extension.
Produces 5 types of tags:
c,chapter
s,section
u,subsection
b,subsubsection
p,package
It is a token parser which can handle tags of this format:
\keyword{any number of words}
\keyword[short desc]{any number of words}
\keyword*[short desc]{any number of words}
\keyword[short desc]*{any number of words}
Will find tags for the following lines:
\usepackage{amsmath}
\chapter{chapter text}
\section{section1 text}
\subsection{subsection2}
\subsubsection{subsubsection3 with extra text}
If someone that actually uses Tex can give it a go you can email me
directly with any issues.
Dave
I forgot to mention, to use this with Vim, open up your .vimrc and add
the following:
" Tex language
let g:tlist_tex_settings =
'tex;c:chapters;s:sections;u:subsections;b:subsubsections;p:packages'
Next time you restart Vim, the taglist plugin will be able to
recognize the Tex tags ctags provides.
Dave
I think it's easier to get the dev package and use the static library
libregex.a which is included there. The dev package also includes the
header file regex.h which you'll almost certainly need.
I couldn't get ctags' ./configure to behave itself, so I got it to
compile like this:
- put libregex.a and regex.h in the ctags' source directory
- ./configure
- edit config.h as follows:
- remove #define REGCOMP_BROKEN 1
- remove #define CHECK_REGCOMP 1
- change /* #undef HAVE_REGCOMP */ into #define HAVE_REGCOMP 1
- edit Makefile as follows:
- change LIBS = into LIBS = -lregex
- make
That said, although I can compile it, I can't run it, as I don't have a
Windows machine handy right now.
It may need libgnurx at runtime, but I don't think so. If it does, just
make sure it's in the same directory as ctags.exe when you run it and
you should be fine.
I suppose all the binaries in the dev and bin packages are for use with
MinGW GCC. I'm not sure if they'd work with MSVC (depends whether and
how they link with the C standard library and runtime), but they may
well. You'd have to modify ctags' mk_mvc.mak so it has EXTRA_LIBS =
libregex.a and it should work, I think. But I'm not able to even try
compiling that, for obvious reasons. If for some reason the
MinGW-compiled regex library isn't compatible with MSVC you'd have to
get the regex src package and build it yourself--or download MinGW GCC
and build ctags using that, which is what I would do!
Anyway...it shouldn't be too hard. The main thing is that the compiler
needs to be able to find regex.h, the HAVE_REGCOMP macro needs to be set
while compiling the source, and libregex.a needs to be linked in. And
the binaries need to be compatible with each other--but I think that
part should be OK
If you need more help, write back with more specifics about what
compiler you're using, what error messages you get, etc.. If all else
fails, I can always cross-compile a binary for you to try; I've just
done it anyway to test it out, though not with ctags from VC so it won't
have David's newly-checked-in LaTeX module.
Ben.
You forgot to add the newly added parsers to the objects list.
This caused the following linker error:
parse.o:(.rodata+0x0): undefined reference to `AntParser'
parse.o:(.rodata+0x28): undefined reference to `DosBatchParser'
parse.o:(.rodata+0x54): undefined reference to `MatLabParser'
parse.o:(.rodata+0x88): undefined reference to `TexParser'
collect2: ld returned 1 exit status
make: *** [ctags] Error 1
---
source.mak | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/source.mak b/source.mak
index 92e659e..0ff7382 100644
--- a/source.mak
+++ b/source.mak
@@ -70,6 +70,7 @@ REGEX_HEADERS = gnu_regex/regex.h
OBJECTS = \
args.$(OBJEXT) \
+ ant.$(OBJEXT) \
asm.$(OBJEXT) \
asp.$(OBJEXT) \
awk.$(OBJEXT) \
@@ -77,6 +78,7 @@ OBJECTS = \
beta.$(OBJEXT) \
c.$(OBJEXT) \
cobol.$(OBJEXT) \
+ dosbatch.$(OBJEXT) \
eiffel.$(OBJEXT) \
entry.$(OBJEXT) \
erlang.$(OBJEXT) \
@@ -91,6 +93,7 @@ OBJECTS = \
lua.$(OBJEXT) \
main.$(OBJEXT) \
make.$(OBJEXT) \
+ matlab.$(OBJEXT) \
options.$(OBJEXT) \
parse.$(OBJEXT) \
pascal.$(OBJEXT) \
@@ -109,6 +112,7 @@ OBJECTS = \
sql.$(OBJEXT) \
strlist.$(OBJEXT) \
tcl.$(OBJEXT) \
+ tex.$(OBJEXT) \
verilog.$(OBJEXT) \
vhdl.$(OBJEXT) \
vim.$(OBJEXT) \
--
1.6.1.rc2.34.gb7bf
No, not in any useful definition of the word. That is, there are several
sets of macros that are *required* in order for a distribution to comply
with LaTeX, but LaTeX itself is not a distribution. It's more of a
convention or a standard.
Several additional packages have been written USING LaTeX that provide
even more functionality. Collections of those contributed packages go
into distributions (like gwTeX, MacTeX, TeXLive, and MiKTeX).
> What tags parser should do when somebody will write on his tex file
> something like this:
>
> \newcommand{\mysubsection}{\subsection}
>
> and then use his \mysubsection?
The same thing Vim-LaTeX suite does --- leave it up to the TeXnician to
write his own Vim support for that.
Additionally, the TeXer might do something like...
\let\oldsubsection\subsection
\renewcommand{\subsection}{stuff...\oldsubsection}
and that way Vim wouldn't be confused at all.
Nice. Thank you.
However ctags fails to build with the new parsers on MacOS 10.5:
gcc -o ctags args.o asm.o asp.o awk.o basic.o beta.o c.o cobol.o eiffel.o entry.o erlang.o flex.o fortran.o get.o html.o jscript.o keyword.o lisp.o lregex.o lua.o main.o make.o options.o parse.o pascal.o perl.o php.o python.o read.o rexx.o routines.o ruby.o scheme.o sh.o slang.o sml.o sort.o sql.o strlist.o tcl.o verilog.o vhdl.o vim.o yacc.o vstring.o
Undefined symbols:
"_DosBatchParser", referenced from:
_BuiltInParsers in parse.o
"_TexParser", referenced from:
_BuiltInParsers in parse.o
"_AntParser", referenced from:
_BuiltInParsers in parse.o
"_MatLabParser", referenced from:
_BuiltInParsers in parse.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [ctags] Error 1
Let me know if you need more info.
c
--
\black\trash movie _C O W B O Y_ _C A N O E_ _C O M A_
Ein deutscher Western/A German Western
-->> http://www.blacktrash.org/underdogma/ccc.html
-->> http://www.blacktrash.org/underdogma/ccc-en.html
What about...
part (\part{Early Years})
\document (\begin{document}...\end{document})
and even
\documentclass[opts]{stuff}
Usually the text between \documentclass and \begin{document} is
considered the "preamble."
> Will find tags for the following lines:
> \usepackage{amsmath}
Understand that \usepackage{...} doesn't define a new section of the
document. It just includes a separate package.
I get the following error after executing :Tlist and the taglist window
doesn't contain content:
Taglist: Failed to generate tags for /home/markus/example.tex
exuberant-ctags: Unknown language "tex" in "language-force" option^@
Press ENTER or type command to continue
It works when using the regex from the Vim tips wiki in ~/.ctags
Markus
Yes, and \paragraph and \subparagraph
And what about the \minisec command from KOMA-Script? I think this
package is very widely used, but it is not part of LaTeX 2e nor 3.
> \document (\begin{document}...\end{document})
How should this be represented?
> and even
>
> \documentclass[opts]{stuff}
Again, does this make sense? I think it's only useful to implement
commands that can occure more than once for an overview in taglist.
> Usually the text between \documentclass and \begin{document} is
> considered the "preamble."
>
> > Will find tags for the following lines:
> > \usepackage{amsmath}
>
> Understand that \usepackage{...} doesn't define a new section of the
> document. It just includes a separate package.
Compared with the #include directives from C files, \usepackage
shouldn't be included in ctags for TeX files.
Markus
Okay, I replace the package stuff with \part.
Anything decided upon though, has to be spelled out for me.
I have never written anything in Tex before.
Dave
What about the * in the first example, where can it be?
\section[optional shortname]{Long name}
\section*[optional shortname]{Long name}
\section[optional shortname]*{Long name}
Assuming there are short names, which name should the tag show?
Sounds like the short name as it will be more readily readable?
> Finally, every LaTeX document will start with a documentclass line:
Is this really necessary for navigation?
Won't there only be 1 of these tags?
> Plus, you can have macros defining major sections of the source... like...
I always need specifics.
If macros can be user defined, I am not sure how the parser is
supposed to know this isn't just another item the parser isn't looking
for.
Dave
\paragraph
\subparagraph
in the list in the previous message (I think someone else mentioned
these). Additionally, it's common to see people (or special document
classes) define crazy things like
\subsubsubsubsection
... It's probably not critical that you worry about those.
ADDITIONALLY, Vim-LaTeX created commented sections for structure... like
%fakesection{...}
It's not critical that you notice these, but it's common to see these
when Vimmers people use Vim-LaTeX.
>> \section[optional shortname]{Long name}
>> \subsection*{Unnumbered section}
>
> What about the * in the first example, where can it be?
> \section[optional shortname]{Long name}
That example is valid.
> \section*[optional shortname]{Long name}
> \section[optional shortname]*{Long name}
Both of these examples are invalid for \section.
For \section, ...
\section{Title} :
Creates a NUMBERED section called "Title". Because the section is
numbered, it will show up in the table of contents, and its title will
be "Title".
\section[Short Title]{Very Long Title}
Creates a NUMBERED section called "Very Long Title". It will show up in
the table of contents under "Short Title."
\section*{Some Title}
Creates an UNNUMBERED section called "Some Title." Because it's
unnumbered, it won't show up in the table of contents, and so it can't
take an optional argument.
So the * denotes an unnumbered section (i.e., a heading without a counter).
> Assuming there are short names, which name should the tag show?
> Sounds like the short name as it will be more readily readable?
That's a reasonable point. I'd say to use the short name if provided. If
not provided (of course), use the long name.
> Is this really necessary for navigation?
> Won't there only be 1 of these tags?
There can be some code before the \documentclass. Additionally, there
are often comments before the document class.
Vim-LaTeX will fold the documentclass together.
Additionally, the section between \documentclass and \begin{document} is
the preamble, and that preamble won't have any sections. The preamble
itself is a noteworthy section. That's why it might be nice to keep
those in mind.
> I always need specifics.
> If macros can be user defined, I am not sure how the parser is
> supposed to know this isn't just another item the parser isn't looking
> for.
I wouldn't worry about user-defined macros. Is it possible to make
things user extensible though?
--Ted (who has never used ctags in Vim)
--
Ted Pavlic <t...@tedpavlic.com>
David: When parsing C code, how do you treat #define lines, and the
words they define? They are also user-defined "macros".
TeX people: How do you define a macro?
Best regards,
Tony.
--
Anoint, v.:
To grease a king or other great functionary already
sufficiently slippery.
-- Ambrose Bierce, "The Devil's Dictionary"
IIUC, you don't need to recompile Exuberant Ctags to add a new language.
Just add the appropriate lines to your ~/.ctags (or ~/ctags.cnf on Windows).
See "man ctags" if you have that manpage.
Best regards,
Tony.
--
** Hello and Welcome to the Psychiatric Hotline **
If you are obsessive-compulsive, please press 1 repeatedly.
If you are co-dependent, please ask someone to press 2.
If you have multiple personalities, please press 3, 4, 5 and 6.
If you are paranoid-delusional, we know who you are and what you want
- just stay on the line so we can trace the call.
If you are schizophrenic, listen carefully and a little voice will
tell you which number to press next.
If you are manic-depressive, it doesn't matter which number you press
- no one will answer.
If you suffer from panic attacks, push every button you can find.
If you are sane, please hold on - we have the rest of humanity on the
other line and they desparately want to ask you a few questions.
In LaTeX (and some in TeX)...
\input{file} (where "file" may or may not have an extension)
\include{file} (again)
\usepackage{file} (again)
\input file (with no curly braces)
and a few other obscure examples.
> TeX people: How do you define a macro?
Very difficult question to answer... In all of the following, note that
line breaks are treated like any other whitespace.
In TeX:
\def\macroname{macro definition}
where {macro definition} itself could be a macro... that is, curly
braces are not required for single macros...
\def\macroname\anothermacro
The trouble is that there are lots of other "\def"-like macros, like
\xdef. Additionally, there are lots of different things that can come
after \macroname. So a good start would be something like...
\def\macroname[^}]*{macro def}
and note that "macro def" could span many lines.
A more complicated one is \let...
\let\something\another
The macro \let is much like a "hard link". That is, it causes
"\something" to get set to whatever is currently in "\another". That
lets me change "\another" while retaining its old functionality in
"\something."
So if \let\something\another defines a "hard link" between \something
and \another, then \def\something{\another} or \def\something\another
provides a "symlink" (or something like it). In the \def case, if I
change \another, then the function of \something also changes.
Unfortunately, I'm leaving out lots of other interesting and often used
cases that make use of \expandafter and \csname. There's probably no way
to handle those well.
In LaTeX:
\newcommand\macroname{macro definition}
\newcommand\macroname[5]{for a macro with 5 arguments}
\newcommand\macroname[5][default]{for macro with 5 arguments where the
first is an optional argument that defaults to "default"}
You also have...
\newcommand*
\renewcommand
\renewcommand*
\providecommand
\providecommand*
which have the same syntax as the above.
Oh, and I'm leaving out...
\newenvironment{envname}{before stuff}{after stuff}
which acts just like \newcommand (with the optional arguments and
everything). In fact, internally it's two \newcommands that create
macros \envname and \endenvname. There is a \renewenvironment as well.
Having something that can comprehensively handle LaTeX is probably
shooting too far right now. Having something that just handles the basic
sectioning commands might be a more tractable task.
--TEd
--
Ted Pavlic <t...@tedpavlic.com>
Yes, I believe some of the howto's point out the regex examples.
If not specifically for Tex, at least the Ant one discussed yesterday.
The _problem_ with extending tags using regex is for each regex you
add it must make another pass through the document. If the document
is quite large and you have many regex defined, it can be very slow to
generate the tags.
Given Tex is a document is stands to reason these files could get large.
So building a proper token parser results in a significantly faster
tag generation process.
Dave
What do you mean?
Are you asking for tags to be generated for these?
If so, do they have the usual {name of the paragraph) following them?
Dave
Ach so...
Best regards,
Tony.
--
Frobnicate, v.:
To manipulate or adjust, to tweak. Derived from FROBNITZ.
Usually abbreviated to FROB. Thus one has the saying "to frob a
frob". See TWEAK and TWIDDLE. Usage: FROB, TWIDDLE, and TWEAK
sometimes connote points along a continuum. FROB connotes aimless
manipulation; TWIDDLE connotes gross manipulation, often a coarse
search for a proper setting; TWEAK connotes fine-tuning. If someone is
turning a knob on an oscilloscope, then if he's carefully adjusting it
he is probably tweaking it; if he is just turning it but looking at the
screen he is probably twiddling it; but if he's just doing it because
turning a knob is fun, he's frobbing it.
Current SVN (revision 698) now supports:
'c', "chapter",
's', "section",
'u', "subsection",
'b', "subsubsection",
'p', "part",
'P', "paragraph",
'G', "subparagraph",
Add the following to your .vimrc:
let g:tlist_tex_settings =
'tex;c:chapters;s:sections;u:subsections;b:subsubsections;p:parts;P:paragraphs;G:subparagraphs'
Let me know if there are issues or more needed.
Dave
Dave
Compiles fine now with latest svn. Thanks again.
Incidentally, does it have the regex support compiled in? If so, which
regex library do you use?
Ben.
The LaTex parser is officially in the 5.8 release which is available now.
Improvements with very specific examples (I am not a LaTex user) would
greatly help in improving it.
Dave