emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Change key binding in math mode only
@ 2014-03-04 20:42 Rafael
  2014-03-04 23:11 ` Rafael
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael @ 2014-03-04 20:42 UTC (permalink / raw)
  To: Emacs-orgmode list


Hi all,

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 would appreciate any tips in this direction!

Rafael

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Change key binding in math mode only
  2014-03-04 20:42 Change key binding in math mode only Rafael
@ 2014-03-04 23:11 ` Rafael
  2014-03-13 15:11   ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael @ 2014-03-04 23:11 UTC (permalink / raw)
  To: emacs-orgmode

Rafael <rvf0068@gmail.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Change key binding in math mode only
  2014-03-04 23:11 ` Rafael
@ 2014-03-13 15:11   ` Bastien
  0 siblings, 0 replies; 3+ messages in thread
From: Bastien @ 2014-03-13 15:11 UTC (permalink / raw)
  To: Rafael; +Cc: emacs-orgmode

Hi Rafael,

Rafael <rvf0068@gmail.com> writes:

> 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.

That's not 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

... that's a contribution -- thanks for it!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-13 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-04 20:42 Change key binding in math mode only Rafael
2014-03-04 23:11 ` Rafael
2014-03-13 15:11   ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).