I am presenting a code snippet that would make editing of babel blocks
quite seemless. The editor parallels (inline!) editing of table
blocks. A suitable variation thereof could be considered for inclusion
in the core distribution.
Few other suggestions:
1. While invoking babel editor, offer babel guard lines as comment
blocks in the native mode.
2. On saving code blocks, do the reverse.
For example, in case of emacs-lisp
#+begin_src emacs_lisp:
(message "Hello World")
#+end_src
could be offered as:
;; begin_src emacs_lisp:
(message "Hello World")
;; end_src
One could then add say a ':tangle ...' directive and have it persisted
as
#+begin_src emacs_lisp: :tangle HelloWorld.el
(message "Hello World")
#+end_src
2. Is it possible to do org-edit-src-exit with more 'natural'
keybinding like C-x C-w or C-x C-s. Furthermore, C-x C-w could fix
up '#+srcname: ' directive as well.
;; CODE SNIPPET
;; make org-cycle look for babel blocks
((org-at-babel-p)
(call-interactively 'org-edit-special))
;; A semicolon followed by <TAB> would invoke the babel editor.
;; A tab within the babel block would invoke the babel editor.
(defconst org-babel-invoke-editor-regexp "^[ \t]*\\(;\\)"
"Detect beginning of babel src code")
(defun org-at-babel-p ()
""
(beginning-of-line 1)
(cond
((looking-at org-babel-invoke-editor-regexp)
(unless (org-babel-where-is-src-block-head)
(insert "#+begin_src emacs-lisp :\n\n")
(insert "#+end_src")
(kill-line)
(forward-line -1)
t)
)
((org-babel-where-is-src-block-head) t)
(t nil)
)
)
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-orgmode