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