0

I often color in red some key-words in my latex-notes taken in Org-mode.

So I often end up using \textcolor{pink}{Blah Blah} all over my notes.

I would like to bind Alt+F12 to automatically expand into this snippet with the cursor positioned on the second pair-of braces ready for input.

How would we do this?

I am using Spacemacs wrapped around emacs-24.5

2

Not sure it's the best way to do that, but that works:

(defun my/insert-pink ()
  (interactive)
  (insert "\\textcolor{pink}{}")
  (backward-char))

(defun my/add-org-pink-binding ()
   (local-set-key (kbd "<M-f12>") #'my/insert-pink))

(add-hook 'org-mode-hook #'my/add-org-pink-binding)
0
(defun my-insert-snippet ()
  "Insert snippet and move point."
  (interactive)
  (insert "\\textcolor{pink}{Blah Blah}")
  (backward-word 2))
(global-set-key (kbd "M-<f12>") 'my-insert-snippet)

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.