emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rafael <rvf0068@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Change key binding in math mode only
Date: Tue, 04 Mar 2014 17:11:41 -0600	[thread overview]
Message-ID: <86eh2hpniq.fsf@gmail.com> (raw)
In-Reply-To: <87r46hr904.fsf@gmail.com> (Rafael's message of "Tue, 04 Mar 2014 14:42:19 -0600")

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

  reply	other threads:[~2014-03-04 23:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04 20:42 Change key binding in math mode only Rafael
2014-03-04 23:11 ` Rafael [this message]
2014-03-13 15:11   ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86eh2hpniq.fsf@gmail.com \
    --to=rvf0068@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).