[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: My humble additions to AUCTeX
From: |
Marcin Borkowski |
Subject: |
Re: My humble additions to AUCTeX |
Date: |
Tue, 20 Jan 2015 16:25:59 +0100 |
On 2014-01-13, at 21:47, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> Also, I want to level up the word commands to token-aware commands.
>
> That'd be a mistake. In Emacs, a "word" is not a "token".
>
> For those people who prefer symbol-navigation over word-navigation,
> Emacs-24.4 offers superword-mode. And indeed, it would be nice to make
> superword-mode understand TeX's notion of "symbol".
OK, so let me revive this (over a year!) old thread. (Last time I wrote
in it, I said that I'd look into new Emacs' superword-mode. Well,
I just did.)
Here's the catch (and the summary of what I want to accomplish). I'd
like M-f and M-b treat \these \things \as \words in AUCTeX mode. The
rationale is that they are really the basic components of a (La)TeX
code.
Now the advice Stefan gave me was to utilize superword-mode. I can see
a few problems with this approach. First is subjective: I looked into
the code, and have no idea how find-word-boundary-function-table works.
>From what I /did/ understand is that in superword-mode, M-f (somehow?)
calls (forward-symbol 1) and M-b calls (forward-symbol -1).
Now, I could somehow substitute my function for forward-symbol (assuming
that I will understand how that table works).
However, as I alluded in one of my previous posts, in LaTeX files the
code and (human-language) text are heavily interspersed. Take this
line, for instance:
I \emph{really} like \LaTeX.
Assume that the point is at the beginning of line (I will denote it by
the vertical line, |.) After a few subsequent presses of M-f, this is
what I would like to achieve:
I| \emph{really} like \LaTeX.
I \emph|{really} like \LaTeX.
I \emph{really|} like \LaTeX.
I \emph{really} like| \LaTeX.
I \emph{really} like \LaTeX|.
This is in fact how Emacs operates by default. However, imagine that
I start with the point at the end of line, and press M-b repeatedly.
Here's what I'd like to see:
I \emph{really} like \LaTeX.
I \emph{really} like |\LaTeX.
I \emph{really} |like \LaTeX.
I \emph{|really} like \LaTeX.
I |\emph{really} like \LaTeX.
As you can see, it's different from the normal Emacs operation.
OTOH, this@is@treated@as@one@symbol in AUCTeX; but email@address
shouldn't. So when the point is after `foo@bar', and the user presses
M-b, we should land at the `b'; but when the point if after `\foo@bar',
and the user presses M-b, we should land at the backslash. (In fact,
it's even more complicated than that, with the \makeatletter and stuff,
but let's forget about it now.)
Yet another example: I'd like M-b to move to the backslash when the
point is after the comma in `foo\,'. Normally, both (backward-word) and
(forward-symbol -1) travel all the way to the `f'.
In fact, I would also like a (single) M-f or M-b to skip the /entire/
math formula ($...$ or \(...\)) when I'm on its delimiter (this is
probably even more unorthodox, but would be very handy: M-f and M-b
would allow me to move between parts of the formula when I'm inside, but
would treat it as a single entity when I'm outside!)
Now I could more or less easily code these functions and e.g. define
a suitable minor mode. My question is not how to do this, but /where/
to put my functions, so to speak. IOW, what is the best/suggested
practice here? Should I just turn it on in AUCTeX mode? (Probably not
the best idea ever.) Should I utilize superword mode? (Might not be
a good idea either, since it might not work the way I want it to
/outside/ TeX commands.) Should I define my own minor mode where
I redefine M-f and M-b? (And M-d etc.? This seems the best solution to
me.)
> Stefan
Best,
--
Marcin Borkowski This email was proudly sent
http://mbork.pl from my Emacs.
- Re: My humble additions to AUCTeX,
Marcin Borkowski <=