From: Marcin Borkowski <mbork@wmi.amu.edu.pl>
To: help-gnu-emacs@gnu.org
Subject: Re: My humble additions to AUCTeX
Date: Tue, 20 Jan 2015 16:25:59 +0100 [thread overview]
Message-ID: <87r3upjx1v.fsf@wmi.amu.edu.pl> (raw)
In-Reply-To: <jwviotnsja5.fsf-monnier+gmane.emacs.help@gnu.org>
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.
next prev parent reply other threads:[~2015-01-20 15:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-12 23:28 My humble additions to AUCTeX Marcin Borkowski
2014-01-13 16:49 ` Nicolas Richard
2014-01-13 18:16 ` Marcin Borkowski
2014-01-13 20:47 ` Stefan Monnier
2014-01-14 9:57 ` Marcin Borkowski
2014-01-14 10:16 ` Marcin Borkowski
2014-01-15 13:26 ` Stefan Monnier
2015-01-20 15:25 ` Marcin Borkowski [this message]
2015-01-20 16:32 ` Artur Malabarba
2015-01-20 16:45 ` Marcin Borkowski
2015-01-20 18:42 ` Stefan Monnier
[not found] ` <mailman.18220.1421779378.1147.help-gnu-emacs@gnu.org>
2015-01-21 2:34 ` Rusi
2014-01-14 10:29 ` Nicolas Richard
2014-01-15 17:58 ` Marcin Borkowski
[not found] <mailman.11758.1389569313.10748.help-gnu-emacs@gnu.org>
2014-01-13 16:35 ` jack-mac
2014-01-13 18:11 ` Marcin Borkowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3upjx1v.fsf@wmi.amu.edu.pl \
--to=mbork@wmi.amu.edu.pl \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.