emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Custom keymaps on org blocks
@ 2017-06-05 21:53 John Kitchin
  2017-06-06 18:16 ` Nicolas Goaziou
  2017-06-07  1:22 ` Grant Rettke
  0 siblings, 2 replies; 13+ messages in thread
From: John Kitchin @ 2017-06-05 21:53 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-09-05 15:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-05 21:53 Custom keymaps on org blocks John Kitchin
2017-06-06 18:16 ` Nicolas Goaziou
2017-06-07 12:58   ` John Kitchin
2017-06-07 13:21     ` Nicolas Goaziou
2017-06-07 13:50       ` John Kitchin
2017-06-08  0:22         ` Grant Rettke
2017-06-10  9:03         ` Nicolas Goaziou
2017-06-10 13:58           ` John Kitchin
2017-06-10 19:31             ` John Kitchin
2018-09-05 15:52               ` Matt Price
2017-06-07  1:22 ` Grant Rettke
2017-06-07 12:49   ` John Kitchin
2017-06-07 23:52     ` Grant Rettke

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).