emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Custom keymaps on org blocks


From: John Kitchin
Subject: [O] Custom keymaps on org blocks
Date: Mon, 05 Jun 2017 15:53:33 -0600

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]