[TxMt] LaTeX bundle; reference/citation completion bug + suggested fix

Andrew Hill lists at thefrog.net
Mon Jan 11 08:55:16 UTC 2010


Hi there,

There seems to be a bug in the LaTeX bundle's reference/citation
auto-complete for my specific set-up.
I'm fairly sure I've fixed it (though its possible this is not the best /
most generic method) so I'll try to describe my problem / situation:

In my project I have a master .tex document, and several other .tex files
(each with something like the following line as their first line):

%!TEX root = ../thesis.tex


When I attempted to auto-complete references/citations I'd get this error
(output directly in my file at the cursor, not as a pop-up or tooltip):

/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:19:in
`initialize': No such file or directory -
/Users/andrew/Documents/Uni/Papers/Writing/Thesis/thesis.tex
 (Errno::ENOENT)
from
/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:19:in
`open'
from
/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:19:in
`options'
 from
/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:45:in
`master'
from
/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:56:in
`get_labels'
 from /tmp/temp_textmate.oacqrp:8
File:
/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb


The file that it claims does not exist definitely exists, but in the error
message that was output in my document, there was a diamond character
immediately after "thesis.tex", visible because i have the "Show Invisibles"
TextMate setting enabled.
I copied the text including the diamond character and pasted it into a
web-based ascii-to-hex converter (http://centricle.com/tools/ascii-hex/) and
it seems to be the character %0A, i.e. the Line Feed or new line character
(\n), suggesting the script is erroneously including the \n as part of the
TEX root filename property.
- I've checked the document in TextMate with Show Invisibles on and cannot
see any extra characters
- I've also tried deleting the line and typing it out again
- I've tried using absolute and relative paths for the root document
property
None of these solved the problem (and none had any detrimental effect after
I'd fixed it as described below).

I've fixed the problem by editing the script:
/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb
and changing line 42 from:

new_master = (master.parent + Pathname.new(opts['root'])).cleanpath

to:

new_master = (master.parent + Pathname.new(opts['root']*.strip*)).cleanpath


This fix would probably break the functionality of the root file if the full
specified path is required to start or end with a space (e.g. the root file
is called "master.tex "). I don't think quotation marks are allowed here to
account for this somewhat unlikely scenario, but it may well break the
script for someone. Perhaps a slightly better fix would be to remove a
single trailing \n character if it is present (however this is beyond my
Ruby scripting abilities).

Anyway, hope this is of some help and some kind of fix can be put into the
official bundle

cheers,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20100111/129fab40/attachment.html>


More information about the textmate mailing list