1

Based on the discussion in these questions (1, 2, 3), I created the following key bindings for AucTeX in emacs.

(defun AucTeX-LaTeX-beginendgroup ()
  (local-set-key (kbd "C-{") "\\begingroup
")
  (local-set-key (kbd "C-}") "\\endgroup
"))

(add-hook 'LaTeX-mode-hook 'AucTeX-LaTeX-beginendgroup)

I wanted to create key binding in AucTeX to input text \begingroup RET when Ctrl-{ is pressed, and input \endgroup RET when Ctrl-} is pressed.

Emacs loads the style mode hooks successfully without any complaints.

While the first one (Ctrl-{), works fine (also C-h k C-{ reports correctly), the second one (Ctrl-}) does not work. Moreover, C-h k C-} remains silent without an answer.

I am really clueless about what could have gone wrong.

  • Shouldn't the last argument be a function? In this case one defined to (insert the given string. – Andrew Swann Nov 14 '14 at 8:18
  • @AndrewSwann Then why does the first binding work? – Masroor Nov 14 '14 at 8:31
  • 2
    As commented by Malabarba on the question on mx.sx, sending a string this way outputs the string as a keyboard macro. This means inserting the string, if it doesn't contain a character whose key is bound to something different from self-insert-command. emacs.stackexchange.com/a/3530/184 – T. Verron Nov 14 '14 at 12:26
1

Add the following code to your init file:

(eval-after-load "latex"
  '(progn
     (define-key LaTeX-mode-map (kbd "C-{") "\\begingroup\n")
     (define-key LaTeX-mode-map (kbd "C-}") "\\endgroup\n")))
  • Your proposed solution produces the same result as mine. The first one works, the second one does not. Even in an uninitialized state emacs remains silent when Ctrl-} is pressed. Any idea why this happens? I am using Ubuntu by the way. – Masroor Nov 14 '14 at 10:38
  • I don't have any idea since it works on my system. Try commenting in your init file everything except for the above code, perhaps there is something clashing with it. – giordano Nov 14 '14 at 10:48
  • I completely emptied my init file. Even then Ctrl-} is unresponsive. – Masroor Nov 14 '14 at 10:58
  • 3
    Then I don't think it's an Emacs issue, it seems your system hijacks that key binding . – giordano Nov 14 '14 at 11:35
  • 1
    @Masroor in ubuntu start off in keyboard settings, I could recreate your problem by assigning say Ctrl-} to universal access, for example, and it would remain silent, once in emacs – doed Nov 17 '14 at 3:21

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.