I'm working with Aquamacs 2.3a to compile .tex documents. Typing double quotes " one time leads to ``. Then writing a word and finishing with " again, expands to ``myword''. How can I have autopair to directly give me ``'' when typing " once?

I used autopair before to pair "$" in .tex documents, but I couldn't get this to work for the above problem:

(add-hook 'TeX-mode-hook
    (lambda ()
        (modify-syntax-entry ?$ "\"")

migrated from stackoverflow.com Sep 29 '11 at 10:52

This question came from our site for professional and enthusiast programmers.


This is not trivial. The double-quote behaviour you currently have doesn't come from autopair but tex-mode.

You can advise it to get the specific behavior you want:

(defadvice tex-insert-quote (after maybe-pair activate compile)
  (when (equal "``" (buffer-substring-no-properties (- (point) 2) (point)))
      (insert tex-close-quote))))

However, you won't get the paired deleting or skipping. Just inserting.

  • I put it in Preferences.el and restarted Aquamacs. Unfortunately, typing double-quotes still gives me `` (bevor the word) and '' (after the word) and not ``'' right away. But I see, it's a non-trivial problem. Thanks a lot anyways. – Marius Hofert Sep 28 '11 at 7:47
  • It worked for me. I meant getting comprehensive autopair functionality is not trivial. Insertion is not too bad. This would only insert paired quotes when point is after a space. – event_jr Sep 28 '11 at 8:08

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.