From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Custom keymaps on org blocks Date: Mon, 05 Jun 2017 15:53:33 -0600 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIHni-0003Ob-FR for emacs-orgmode@gnu.org; Tue, 06 Jun 2017 12:57:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIHne-0006s7-JR for emacs-orgmode@gnu.org; Tue, 06 Jun 2017 12:57:50 -0400 Received: from mail-it0-x232.google.com ([2607:f8b0:4001:c0b::232]:37690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIHne-0006qn-EQ for emacs-orgmode@gnu.org; Tue, 06 Jun 2017 12:57:46 -0400 Received: by mail-it0-x232.google.com with SMTP id m47so113227792iti.0 for ; Tue, 06 Jun 2017 09:57:44 -0700 (PDT) Received: from Johns-MacBook-Air.local ([198.59.53.12]) by smtp.gmail.com with ESMTPSA id e72sm3839186itd.29.2017.06.06.09.57.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Jun 2017 09:57:42 -0700 (PDT) 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" To: emacs-orgmode@gnu.org Is there any interest in having custom keymaps on org blocks? The idea I had is to have the option to make the major-mode keymaps be active on the src blocks. For example, you might want to use something like this to use the elpy in ipython blocks and lispy-mode-map in emacs-lisp blocks (defcustom org-src-block-keymaps `(("ipython" . ,(let* ((map (copy-keymap elpy-mode-map))) (define-key map (kbd "C-c C-c") 'org-ctrl-c-ctrl-c) (define-key map (kbd "C-c '") 'org-edit-special) map)) ("emacs-lisp" . ,(let* ((map (copy-keymap lispy-mode-map))) (define-key map (kbd "C-c C-c") 'org-ctrl-c-ctrl-c) (define-key map (kbd "C-c '") 'org-edit-special) map))) "alist of custom keymaps for src blocks.") The implementation is pretty simple, you just modify org-fontify-meta-lines-and-blocks-1 with a line like this: (when (assoc (org-no-properties lang) org-src-block-keymaps) (add-text-properties beg end `(local-map ,(cdr (assoc (org-no-properties lang) org-src-block-keymaps))))) I have tried this, and seems ok, and I wondered if anyone had an opinion for or against this idea. -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu