Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am having a totally bizarre problem with typing quote marks in tex documents in emacs. I work as an editor, so I receive tex source files from a publisher and I work on them. I work in emacs 24.3.1 with auctex 11.87, on Ubuntu 14.04.

A few days ago, the following behavior began: when I type the double-quote key " in the source buffer, emacs inserts guillemets, \og and \fg{}, rather than `` and '', which is what usually happens when pressing " in LaTeX-mode.

Here is as much information as I could gather:

  1. This only happens with files I receive from the publisher. It doesn't happen with pre-existing tex files on my machine, nor with new ones that I create.
  2. It happens even when I start emacs with the emacs -q command, so that it doesn't read my .emacs file.
  3. It still happens if I copy or move the file to another location from the command line.
  4. It still happens if I copy or move the file to another location from the command line, then delete its contents within emacs.
  5. It doesn't happen if I copy the file contents into a new buffer from within emacs.
  6. It still happens if I delete the .aux and .log files.
  7. The " key is bound to the command TeX-insert-quote.
  8. The values of the variables TeX-open-quote and TeX-close-quote are `` and '', respectively, as usual.

I conclude from this that emacs is reading some "secret" information associated to the file that I don't know about. It is nothing in my settings and seems to have nothing to do with the file contents.

Any thoughts/suggestions/fixes much appreciated.

Update: The problem went away for a while, then reasserted itself. As per giordano's suggestion in the comments, I checked the value of TeX-quote-language and found that it is:

("french" "\\og " 
    (lambda nil (concat "\\fg" (unless (member "xspace" TeX-active-styles)"{}"))) nil)

(However, the value of TeX-quote-language-alist is nil.) I think this is somehow being caused by the custom class file that I need to use for my work. Is there some way to just add a line in my .emacs that will override this behavior? I just want my normal quotes back!!

share|improve this question
3  
I guess the file you receive from the publisher has \usepackage[french]{babel} –  egreg May 13 at 21:15
2  
Emacs+auctex also knows file local variables, which can be defined as comments. Look for a comment block that starts with % Local variables:. –  Alex May 13 at 21:19
    
It has happened in english papers that are not using the babel package at all, and in french papers that are using it. The files do not contain any local variables. And, as I said, this happens even when I completely delete the contents of the file, so it seems like these things cannot be causing this behavior. –  MTS May 13 at 21:45
    
@MTS, "totally deleting the buffer contents" doesn't reset emacs to a pristine state, some settings gleaned from the file's contents stay. Try opening a new file, check package by package (save and load again!) which one does this. AUCTeX does adjust settings from packges. Also check if the master file, it's settings override the local ones. –  vonbrand May 14 at 1:09
    
Check also the value of the TeX-quote-language-alist variable. –  giordano May 15 at 8:43

2 Answers 2

up vote 4 down vote accepted

Here is a solution the does not disable the guillemets in French documents. Thanks to Giordano and David Carlisle for providing all the pieces necessary to assemble the information.

AUCTeX thinks any document that loads the class you're using (call it foo.cls) is in French. It thinks that because it has compiled foo.cls into a file (foo.el or foo.elc) that it reads everytime you load a document loading that class.

So to avoid the behavior you're seeing, you can do one of several things:

  • option 1: Remove foo.el or foo.elc. (Use locate or your OS's finder to find it; if it's in a directory where you don't have write permission, such as /var/lib/auctex/emacs24, you'll need to have administrative privileges.)

  • option 2: Edit foo.el to remove the offending line (it says francais because foo.cls contains the line \RequirePackage[english,francais]{babel}, albeit in a conditional branch. Again, you might need to have administrative priviledges.

  • option 3: If you have no way to edit or delete foo.el, create your own version of foo.cls, say myfoo.cls, and replace \RequirePackage[english,francais]{babel} by \@nameuse{RequirePackage}[english,francais]{babel}; then use this in your documents. (If you want, you can create myfoo.el by typing M-x TeX-auto-generate in emacs.)

Finally, when you do need to work a French document and want to have the double-quote key insert guillement, you can tell AUCTeX the document is in French by adding \usepackage[francais]{babel} to the preamble. (This is redundant from the point of view of LaTeX, but is harmless.)

share|improve this answer

I found a reasonable workaround here on SuperUser (by giordano). The code that fixed it was:

(add-hook 'TeX-language-fr-hook
      (lambda ()
        (setq TeX-quote-language `("francais" "``" "''" ,TeX-quote-after-quote))))

Obviously, this doesn't solve the underlying problem of why AUCTeX is entering French mode when it doesn't need to, but it does put an effective band-aid over the problem.

share|improve this answer
    
AUCTeX knows your language is French by noting that \usepackage[french]{babel} is in the document. –  egreg Jul 18 at 18:08
    
@egreg Yes, but it's in a conditional branch in the class file - I guess AUCTeX doesn't see that? –  MTS Jul 18 at 18:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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