[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Change key binding in math mode only
From: |
Rafael |
Subject: |
Re: [O] Change key binding in math mode only |
Date: |
Tue, 04 Mar 2014 17:11:41 -0600 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3 (gnu/linux) |
Rafael <address@hidden> writes:
> I have been writing presentations in org-mode lately with a lot of math
> content. I am using org-cdlatex, and have already customized it to, say,
> type R'B inside math mode to obtain \mathbb{R}. I wonder, however, if it
> would be possible to make this procedure shorter, and obtain \mathbb{R}
> as soon as pressing R, *but only inside math mode*.
>
> I guess I could approximate this with abbrevs or yasnippet, but I think
> this would require an extra key besides the R, which is closer to what I
> already have.
I remembered that Org knows already if point is inside a math
expression, so by looking at the source I came up with the following,
that seems to work. Sorry for the noise.
#+BEGIN_SRC emacs-lisp
(defun org-cdlatex-real-numbers ()
(interactive)
(if (org-inside-LaTeX-fragment-p)
(insert "\\mathbb{R}")
(insert "R")
))
(add-hook 'org-mode-hook
(lambda ()
(local-set-key (kbd "R")
'org-cdlatex-real-numbers
)))
#+END_SRC