[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] [BABEL] Seemless editing of Babel Blocks
From: |
Jambunathan K |
Subject: |
[Orgmode] [BABEL] Seemless editing of Babel Blocks |
Date: |
Tue, 20 Jul 2010 17:40:30 +0530 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100608 Lightning/1.0b2 Thunderbird/3.1 |
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)
)
)
- [Orgmode] [BABEL] Seemless editing of Babel Blocks,
Jambunathan K <=