On 2015-10-16, at 12:16, Tassilo Horn <[email protected]> wrote: > Marcin Borkowski <[email protected]> writes: > >>> Uh, that sounds quite complicated to integrate into RefTeX. >>> Basically, you have to have something similar to >>> `reftex-parse-bibtex-entry' or `reftex-parse-bibitem' for amsrefs >>> entries which knows about custom entry types and fields. >> >> Well, what I would like to have is not really /that/ complicated (or >> so I hope). The thing I would really like to have is that when the >> point is on a \cite (and btw, amsrefs has a bit different syntax for >> \cite; this seems insane, but it's not), I can see some details of the >> bib entry in the echo area. I hear that RefTeX can do that (I haven't >> tried it yet). > > Yes, it does that. > > ,----[ C-h v reftex-auto-view-crossref RET ] > | reftex-auto-view-crossref is a variable defined in ‘reftex-vars.el’. > | Its value is t > | > | Documentation: > | Non-nil means, initially turn automatic viewing of crossref info on. > | Automatic viewing of crossref info normally uses the echo area. > | Whenever point is idle for more than ‘reftex-idle-time’ seconds on the > | argument of a \ref or \cite macro, and no other message is being > | displayed, the echo area will display information about that cross > | reference. You can also set the variable to the symbol ‘window’. In > | this case a small temporary window is used for the display. > | This feature can be turned on and off from the menu > | (Ref->Options). > | > | You can customize this variable. > `---- > > That's basically all implemented in reftex-dcr.el (dcr = display > cross-ref). > >> Well, this could be easily implemented using eldoc (at least in simple >> cases, where the bibliography is in the same file as the document; but >> even if not, this doesn't seem extremely hard). Maybe I should do >> /this/ first, since I really, really need this - I can live without >> it, but it's very inefficient. (What I need is to be able to >> determine quickly whether the reference I'm on points to a paper or a >> book.) >> >> But using eldoc when RefTeX exists seems wrong. >> >> OTOH, the parsing functions which find the bib entry /somewhere/ and >> extract information from it would be the same anyway. > > In theory, yes. The thing you want to do seems to be quite doable with > eldoc. But if you also want to have support for `reftex-citation' and > friends, then you need a real integration.
Exactly. Maybe I should just watch `reftex-citation' in action with edebug. >> BTW, this leads to another problem: general parsing of (La)TeX by >> Emacs. AFAICT, AUCTeX doesn't really have this. > > (La)TeX is not parsable. ;-) It is - but only by (La)TeX itself;-). In practice, of course, we can (and may) make some assumptions. Like, catcodes don't change. (In real-life documents, the main place this assumption might hurt is verbatim-like constructs.) >> There is TeX-macro-boundaries, but it deals with "macros", i.e., >> control sequences /with parameters/. What I would like to start with >> would be /tokens/ (in TeX's meaning, which is made a bit difficult >> because of the whitespace-after-control-word issue and because of the >> blank-line-is-a-par issue). > > Another issue is catcodes. You can change the meaning of any character > at any place, and it's hard to keep track of that. Basically, I can > assume a working (La)TeX parser which could parse a file from the > beginning to the end. The problem is that you rarely want to do that > but are only concerned about the region around point. > >> In fact, I wrote some functions to deal with that (they almost work, I >> discovered yet another bug yesterday), and used them for one nice >> thing (see https://github.com/mbork/tex-plus.el and especially the >> functions with "delimiter" in their name) - but that's another story, >> though I'd like to see that integrated into AUCTeX, too. > > Looks interesting. Thanks. That is exactly what you write about: I do not parse the whole file, but only a small portion around point. One of the main things in my library is this: --8<---------------cut here---------------start------------->8--- (defun TeX+-move-beginning-of-token () "Move to the beginning of TeX token the point is at. Move also if the point is on whitespace. Return a non-nil value iff the point was moved." ...) --8<---------------cut here---------------end--------------->8--- Then, I could write this: --8<---------------cut here---------------start------------->8--- (defun TeX+-info-about-token-beginning-at-point () "Return a cons cell with car being the token beginning at point and cdr being one of the following symbols: 'control-symbol, 'control-word, 'implicit-par, 'whitespace, 'normal-character, 'eob. For simplicity, if the point is at a backslash, which is the last character in the buffer, it treats it as a control symbol." ...) --8<---------------cut here---------------end--------------->8--- And using those, I will be soon able to move by tokens. The next step could be making e.g. M-d and M-DEL kill a word /or/ a token, depending on the context. For instance, in this situation: \foo-!-bar pressing M-DEL kills "foo", which doesn't make sense, and I want it to kill "\foo". I have some more plans for that library, too. In general, I'd like to have something like "a paredit for TeX". > Bye, > Tassilo Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University _______________________________________________ auctex-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/auctex-devel
