A colleague using a class I wrote reports that AUCTeX is inserting guillemets when he hits the double-quote key. Investigation showed that TeX-language-fr-hook is being called even though the document itself is not in French.

If I understand a comment from @egreg in response to my colleague's question (Double-quote produces guillemets in emacs) the reason AUCTeX thinks the comment is in French might be something like \usepackage[french]{babel}.

In fact there is this code in the class: \iffrench \RequirePackage[english,francais]{babel}\fi This conditional branch is only triggered if the french option to our class is chosen by the user. It seems that AUCTeX is taking that line to mean that the document is in French, regardless. How can I arrange it so the \usepackage is hidden from AUCTeX or only has an effect when it's intended to?

For full context see Double-quote produces guillemets in emacs

Edit: Below are a few lines from the *Messages* buffer in emacs that may be useful in tracing the problem:

Loading /var/lib/auctex/emacs24/msp.elc...done
Loading /usr/share/emacs/site-lisp/auctex/style/babel.el (source)...done
Loading /var/lib/auctex/emacs24/francais.elc...done
Loading /usr/share/emacs/site-lisp/auctex/style/francais.el (source)...done
Loading /usr/share/emacs/site-lisp/auctex/style/frenchb.el (source)...done
Loading /var/lib/auctex/emacs24/english.elc...done
  • 1
    AUCTeX doesn't know much about TeX conditionals. Could you please post a MWE anyway? – giordano Jul 18 '14 at 20:09
  • 1
    Can you write an e-lisp hack that turns off the hook for just this document? – Ethan Bolker Jul 18 '14 at 20:11
  • Wow, welcome to TeX.sx, sir! We are not worthy, we are not worthy. – Paulo Cereda Jul 18 '14 at 20:16
  • 3
    I would guess you can hide the \usepackage in a class it would be better to use \RequirePackage anyway (it's the same thing but auctex may not know that:-) or \@nameuse{RequirePackage}[french]{babel} or... – David Carlisle Jul 18 '14 at 20:23
  • 2
    My guess: your colleague has an auto-generated style file for that class, you don't, this is why s/he always load style/french.el. Removing "french" from run hooks in her/his auto-generated style file should suffice. – giordano Jul 18 '14 at 20:58

From the *Messages* log I deduce the "offending" class is msp.cls. Unfortunately I can't find it on the Internet to test it, but anyway in the /var/lib/auctex/emacs24/msp.elc file there should be a "french" string somewhere. Just remove it (you'll need to edit it with root privileges, from within Emacs issue C-x C-f /sudo::/var/lib/auctex/emacs24/msp.elc RET to open it) and you should be done.

  • Giordano, thanks. I've not placed msp.cls on the internet because it's not meant for general use. You gave a good solution for the user of the class. However the writer of the class (me) would love for other users to be spared the same confusion. Maybe David Carlisle's suggestion of replacing \RequirePackage by \@nameuse works, and I would like to test it; but I don't know under what circumstances msp.elc is generated. (MTS is reporting it was not regenerated after he deleted it.) – Silvio Levy Jul 20 '14 at 15:54
  • 2
    @SilvioLevy It can be re-generated by issuing M-x TeX-auto-generate RET' on the msp.cls` buffer or, to re-generate all style files (it will take a while), sudo emacs -batch -f TeX-auto-generate-global in the command line. – giordano Jul 20 '14 at 16:30
  • Bingo. Either \@nameuse or \csname prevent francais from being added to msp.el -- so I'll incorporate that change to the class. – Silvio Levy Jul 20 '14 at 16:40
  • Yes, AUCTeX parser doesn't know that syntax. – giordano Jul 20 '14 at 16:43

Thanks to Giordano and David Carlisle who provided the key information, here is a complete answer. In the package file, replace \RequirePackage[english,francais]{babel} by \@nameuse{RequirePackage}[english,francais]{babel}. Now when your user's auctex compiles the file (which you can also do within emacs, for testing, with M-x TeX-auto-generate), the string francais will no longer appear in the output (which is typically placed in ~/.emacs.d/auctex/auto/msp.el), and all will be well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.