I've looked for a solution to this a number of times. Suppose 'kg' normally expands to 'knowledge' in my abbrev file. I wonder if there is any way to get emacs to expand after a single or double quotation mark, as in expanding from




I don't know lisp well but am willing to play with my .emacs. Thanks for any help!

Edit: I just noticed that it works fine in the scratch buffer, but not in markdown or LaTeX modes.

  • It's technically a small bug in LaTeX mode, because it redefines the double quote key and so the abbrev doesn't expand. What's your emacs version, I can write you a workaround.
    – Malabarba
    Mar 28, 2015 at 23:44
  • GNU Emacs 24.3.1 - but it happens in markdown mode too, where the quotation-mark substitution does not take place. Mar 29, 2015 at 19:54

1 Answer 1


How about this?

(with-eval-after-load 'tex-mode
 (defun expand-and-insert-space ()
  (insert "\ ")))

(define-key latex-mode-map (kbd "<SPC>") 'expand-and-insert-space)
(define-key latex-mode-map (kbd "<M-/>") 'expand-abbrev)

EDITED to include eval-after-load

  • 1
    Hmm thanks! I tried that but got Symbol's value as variable is void: latex-mode-map. Unfortunately this means little to me. Nov 24, 2015 at 17:42
  • 2
    Could be fixed by wrapping in (with-eval-after-load 'tex-mode ...).
    – npostavs
    Jul 20, 2016 at 18:50
  • Sorry I only just saw this answer - I guess I don't have notifications on. It seems to work, thanks! To be clear, I just add that first code line, (with-eval-after-load 'tex-mode (defun expand-and-insert-space () (interactive) (expand-abbrev) (insert "\ "))) - right? Aug 1, 2016 at 13:23
  • You should add the whole thing so that you can remap the space key. This is a hacky workaround and won't expand, for instance, when you hit delimiters like , and . unless you redefine those also. Aug 2, 2016 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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