[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX] Insertion of braces in math mode for certain macros
From: |
Tassilo Horn |
Subject: |
Re: [AUCTeX] Insertion of braces in math mode for certain macros |
Date: |
Tue, 06 Nov 2012 16:07:52 +0100 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) |
"Nicolas Richard" <address@hidden> writes:
> as a side note on the same subject, I use the following modified
> version of TeX-parse-macro. The change is so that, when the region is
> active and TeX-insert-macro is called, a pair of braces is inserted
> around the region, even in math mode : it's a slight abuse of the
> brace insertion mechanism (which, I assume, existed to avoid space
> gobbling by TeX in non-math mode), but that abuse already existed in
> non-math mode too.
Also as a side node: AUCTeX does a bit of regex parsing to find out
about macro arguments in the LaTeX style files. For example, it
successfully finds out that \frac has two mandatory arguments, and thus
`C-c RET frac RET' inserts \frac{}{} and places point in the first pair
of {}.
But the definition of \text isn't really accessible for this regex-based
approach, thus giving AUCTeX that information manually is required.
--8<---------------cut here---------------start------------->8---
\DeclareRobustCommand{\text}{%
address@hidden
address@hidden
address@hidden
address@hidden@size{#1}}%
address@hidden@address@hidden #1}}%
address@hidden@address@hidden #1}}%
address@hidden address@hidden@false #1}}%
address@hidden
}%
}
--8<---------------cut here---------------end--------------->8---
Maybe it would be a good idea to have some alist
(("amstext" ("text" t))
("foobar" ("foo" t nil nil) ("bar" t)))
which would add \text with one mandatory arg to the symbol list if
amstext is used, \foo with 3 mandatory args if the foobar package is
used, etc.
But currently, I don't see exactly how to implement that. Is there
already a check for package "usiness"? And a function that's run
periodically/when the used packages have been altered? (I'm pretty much
lost with the auto-parsing stuff to be honest.)
Bye,
Tassilo