I have a menu item added to AucTex's Command Menu, Latexindent. This calls an external process and is added in mu .emacs file by the following:

(with-eval-after-load "tex"
  (add-to-list 'TeX-command-list
              '("Latexindent" "latexindent -w -s %a"
            TeX-run-command nil t
             :help "Run Latexindent on file.")))

I'm trying to bind this a keystoke series C-c i using the following:

(with-eval-after-load "tex"
   (let ((map (make-sparse-keymap)))
      (set-keymap-parent map TeX-mode-map)
      (define-key map "\C-ci" 'forward-char)))

Unfortunately, this is not defining the C-c i at all, much less to a menu item.

Can someone point me in the right direction to get this defined correctly?

Shawn Way


I guess you're expecting TeX-mode-map to know that it has a 'child', but that's not the way keymap inheritance works.

Any reason you can't just make the change directly in TeX-mode-map? Or use local-set-key in the major modes setup hook. e.g.

(with-eval-after-load "tex"
  (define-key TeX-mode-map "\C-ci" 'forward-char))
  • No reason other than I don't know how... – Shawn Way Jan 25 '19 at 16:48
  • (define-key TeX-mode-map "\C-ci" 'forward-char) should do it – rpluim Jan 25 '19 at 16:51

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.