[TxMt] LaTeX: Bibliography-Autocompletion stopped to work?
Adam R. Maxwell
amaxwell at mac.com
Sun Sep 24 18:54:52 UTC 2006
On Sep 24, 2006, at 10:59, Charilaos Skiadas wrote:
> On Sep 24, 2006, at 12:20 PM, Adam R. Maxwell wrote:
>
>> Well, I happen to think that parsing BibTeX is fairly difficult to
>> do correctly. As a trivial example,
>>
>> @article(citekey,
>> title = "title",
>> author = "m{\"e} and myself")
>>
>> and
>>
>> @article{citekey,
>> title = {title},
>> author = {me{\"e} and myself}}
>>
>> are both valid BibTeX (note the use of () and "" instead of {}
>> pairs). Add whitespace and remove newlines for extra fun. You can
>> write an ad-hoc parser that's probably adequate for completion
>> (although even then I can imagine some difficulty with encodings).
>
> Do I understand correctly though, that if the bib file is saved from
> within BibDesk, then it has kind of a standardized format, that
> would avoid both of the above cases?
Yes, that's correct; BibDesk reads any of the above (thanks to
btparse!), but saves using {} as delimiters.
> My parser is certainly extremely weak, and it assumes that the
> bibfile is pretty well formatted, which is the case with my bib
> files. They are however very small.
In that case, just grabbing citekeys is pretty straightforward. My
bib files are fairly large, so I'm not sure how well it scales to read
the file every time (if that's what you do?).
> I agree it would be extremely difficult to write a parser that
> actually parses the entire bib file to recover all the information.
> To begin with, I haven't even been able to find a complete and clear
> reference for the BibTeX syntax.
The only reference is the WEB source for BibTeX itself, but the docs
with btparse have a pretty good explanation, and Nelson Beebe wrote a
paper on bibclean that's helpful. The bottom line is that BibTeX
sucks because of the variations in syntax.
> For me the main/only disadvantage of the bibdesk completion command
> is that it needs BibDesk to be running, with the current file open
> and up front, unless I'm mistaken. It's been a while since I've used
> it.
That's partially correct; it uses AppleScript to get the list of
completions, so BibDesk has to be running, but it searches all open
documents. There are also some features that help searching (you can
search for "Bü" instead of "B{\"u} for author name completion).
We actually rewrote NSTextView's completion window/controller from
scratch for BibDesk, and that's what I was trying to wedge into
TextMate (to avoid any use of the mouse). Since there's no published
API for TextMate's main textview, that may be impossible for me.
>
> Haris
>
> PS: BibDesk is an awesome program, I can't even imagine managing bib
> files without it.
Thanks! I'll try to avoid promoting it on this list, though ;).
regards,
Adam
More information about the textmate
mailing list