From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rafael Subject: Re: Change key binding in math mode only Date: Tue, 04 Mar 2014 17:11:41 -0600 Message-ID: <86eh2hpniq.fsf@gmail.com> References: <87r46hr904.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKyV7-0003Cp-BN for emacs-orgmode@gnu.org; Tue, 04 Mar 2014 18:12:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKyUy-00075F-CU for emacs-orgmode@gnu.org; Tue, 04 Mar 2014 18:11:53 -0500 Received: from mail-ob0-x232.google.com ([2607:f8b0:4003:c01::232]:54888) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKyUy-000754-7I for emacs-orgmode@gnu.org; Tue, 04 Mar 2014 18:11:44 -0500 Received: by mail-ob0-f178.google.com with SMTP id wp18so247754obc.9 for ; Tue, 04 Mar 2014 15:11:43 -0800 (PST) Received: from lahp ([189.142.12.154]) by mx.google.com with ESMTPSA id n5sm2757853oer.5.2014.03.04.15.11.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 04 Mar 2014 15:11:43 -0800 (PST) In-Reply-To: <87r46hr904.fsf@gmail.com> (Rafael's message of "Tue, 04 Mar 2014 14:42:19 -0600") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Rafael 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