16

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
  • Thanks David and Paulo for the welcome. It's good to be among friends. Giordano, I'll try to provide an MWE but the problem is that the behavior does not happen for me (even though I use auctex too), only for my colleague. Thanks for the suggestion Ethan Bolker - one can write an elisp hack to do just about anything, but the problem is not "this document" -- according to MTS any document using this class triggers the behavior! So I'd prefer to solve the problem at the class level. – Silvio Levy Jul 18 '14 at 20:26
  • Thanks David - in fact what the class says is \RequirePackage[french]{babel}. When I posted the question I was piggybacking on a suggestion in the other posting and I didn't check carefully. I've now corrected my posting. We'll see what MTS says about @nameuse. – Silvio Levy Jul 18 '14 at 20:51
  • 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
  • @giordano, this happens even when I run emacs -q, so it seems that my custom settings are not the problem. – MTS Jul 18 '14 at 21:22
  • @DavidCarlisle, changing the \usepackage command to \@nameuse{RequirePackage}[french]{babel} didn't fix the problem either. – MTS Jul 18 '14 at 21:24
  • @MTS Do you have or not the auto-generated style file? I've never said that custom settings should count here. – giordano Jul 18 '14 at 21:40
  • @giordano, ah, sorry, I misinterpreted your question. I don't know anything about auto-generated style files. How do I check whether I have one or not? – MTS Jul 18 '14 at 21:54
  • @MTS in my setup in ~/.emacs.d/elpa/auctex-11.86/style/ i have lisp versions of various latex packages including babel.el do you have anywhere in your load path a lisp version of the class – David Carlisle Jul 18 '14 at 21:57
  • @DavidCarlisle yes, in ~/.emacs.d/elpa/auctex-11.87.5/style/babel.el I have babel.el (and babel.elc). – MTS Jul 18 '14 at 22:02
  • @MTS no I meant do you have a saved lisp version of the custom class if you use \documentclass{wibble} and auctex has a wibble.el that says it's french it will do that whatever the tex code actually does unless you force things back in sync – David Carlisle Jul 18 '14 at 22:08
  • @DavidCarlisle I see. No, there is no lisp version of the class that I can find. – MTS Jul 18 '14 at 22:15
  • @MTS The auto-generated file is placed in the auto/ subdirectory of the directory in which the class file is situated. – giordano Jul 18 '14 at 22:22
  • @giordano There is no auto/ subdirectory there; the class file is in a subdirectory of /usr/local/texlive/texmf-local/tex/latex/, where I don't have write permission as a regular user. – MTS Jul 18 '14 at 22:34
  • @MTS Ok, but somewhere there should be a style file triggering the loading of french.el. How is called this class? Following David's example, if it's called wibble, after opening your document visit the *Messages* buffer, there should be a line Loading /path/to/wibble.el...done. Where is the style file? – giordano Jul 19 '14 at 09:24
  • @giordano I've added a few of those lines in the question itself, but the change needs to be reviewed, as I don't have enough reputation to edit it myself. – MTS Jul 19 '14 at 23:50
  • @MTS Thank you, I added an answer to this question. Having the class file or at least the /var/lib/auctex/emacs24/msp.elc would help, but the answer should work anyway. – giordano Jul 20 '14 at 10:07
  • I usually set TeX-parse-self and TeX-auto-save to nil in .emacs. – doed Aug 25 '14 at 17:40

2 Answers2

4

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
  • 8,486
  • 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 themsp.clsbuffer 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
3

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.