[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] Feature Request
From: |
Tassilo Horn |
Subject: |
Re: [AUCTeX-devel] Feature Request |
Date: |
Fri, 18 Dec 2015 22:12:08 +0100 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) |
Mosè Giordano <address@hidden> writes:
Hi all,
>> > I have been recommended to mail the list with a feature request, I
>> > hope this is the right place.
>>
>> > Currently if file.tex has \cite{ref2} and ref2 does not exist in the
>> > bib file, it displays no differently to \cite{ref1} which does.
>>
>> > Is it possible to get some sort of visual indication that ref2
>> > does not exist in the bib file? A red squiggly line, highlight,
>> > different colour, something?
This would be a very nice feature. RefTeX basically has the
functionality to know which citations are available in the bib file(s).
See `reftex-extract-bib-entries' and
`reftex-extract-bib-entries-from-thebibliography'.
So we could add some variable like `reftex-known-bibtex-entry-keys'
containing all known reftex entry keys. I guess a hash-table would be
best because we need a fast contains-check.
> Anyway, AUCTeX holds the list of known bibliography items in
> `LaTeX-bibitem-list',
That only contains the \bibitems of a thebibliography environment, not
the entries of standalone bibtex files.
> but I'm not expert enough of font-locking to implement this feature
> without some hints.
It shouldn't be overly hard in general, i.e., you write 2 functions
`font-latex-match-(un)known-citation' which search for the next
"\\\\cite{\\([[:alnum:]:-]+\\)}"
[1] where the group 1 is (not) contained in the hash-table. Then these
functions could be used as font-lock matchers, e.g.
(font-latex-match-known-citation 1 font-latex-known-citation-face)
(font-latex-match-unknown-citation 1 font-latex-unknown-citation-face)
The only problem I see is with updates. Point one is that we don't get
notifications about updates of bibtex entries, and re-computing all keys
can be slow. I have a rfc.bib which contains all IETF RFCs amounting to
almost 100.000 lines. Extracting all entries from that file takes about
3 seconds. However, `reftex-extract-bib-entries' does much more than
just extracting the keys, so we could easily add a much faster version
just for that purpose and then update the hash-table in an
`after-save-hook' or so.
Point two is that font-lock is lazy and won't re-font-lock a region
which has not changed. That is, even when our
`reftex-known-bibtex-entry-keys' hash-table has been just updated, we'd
need to `font-lock-flush' all \cite's arguments which is yet another
search across the complete document.
Bye,
Tassilo
[1] Since \cite{ref1,ref2} is also legal and ref1 could be known but
ref2 not, the functions should actually match both keys separately.
- [AUCTeX-devel] Feature Request, Caroline Glassberg-Powell, 2015/12/16
- Re: [AUCTeX-devel] Feature Request,
Tassilo Horn <=
- Re: [AUCTeX-devel] Feature Request, Tassilo Horn, 2015/12/18
- Re: [AUCTeX-devel] Feature Request, Mosè Giordano, 2015/12/18
- Re: [AUCTeX-devel] Feature Request, Mosè Giordano, 2015/12/18
- Re: [AUCTeX-devel] Feature Request, Tassilo Horn, 2015/12/20