auctex
[Top][All Lists]
Advanced

[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 17:36:48 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

"Nicolas Richard" <address@hidden> writes:

Hi Nico,

>> But currently, I don't see exactly how to implement that.  Is there
>> already a check for package "usiness"?
>
> Yes, the variable TeX-active-styles contains a list of currently
> \use'd'package.

Thanks for the hint, but the feature seems to be already there.  Just
have a look at auctex/style/amstext.el.  It basically does exactly what
I manually clobbered together by looking sharply at the code. ;-)

However, it doesn't work automatically.  `TeX-active-styles' lists
"amstext", so shouldn't that trigger loading of auctex/style/amstext.el?

Hm, on further investigation, even when I eval

  (load-file "~/Repos/el/auctex/style/amstex.el")

using M-:, `TeX-style-hook-list' contains just an empty ("amstext")
entry without hook function!  That entry has been there before, too.

But when I eval (C-x C-e) the `TeX-add-style-hook' form directly, then
the hook function is indeed added to `TeX-style-hook-list', and after a
`C-c C-n' inserting a \text macro in math mode adds the curly braces as
it should.

Now I added a (message) to `TeX-load-style-file', and it's loaded at
some point.  So the problem is really that (load-file style-el-file)
doesn't work!  How can that be???

> In fact the alist you're proposing is/should be split into the style
> files for each package (these style files are loaded from the paths
> referenced in TeX-style-path.)
>
> The other way would be to follow (info "(auctex) Hacking the Parser")
> to make AUCTeX aware of \DeclareRobustCommand and friends (I have in
> mind \DeclareMathOperator, also from amsmath, and also
> \DeclarePairedDelimiter from the mathtools package).

Yes, that would be preferrable.  The problem is that the declaration
with \DeclareRobustCommand doesn't declare arguments but says \text is
either \text@ (in math mode) or \mbox (else).  Then you'd need to check
if \text@ declares arguments (which it does here).  So you have to
understand TeX to make that work; simple regex matching isn't enough
here.

Bye,
Tassilo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]