emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BABEL] Seemless editing of Babel Blocks
@ 2010-07-20 12:10 Jambunathan K
  2010-07-20 22:58 ` Eric Schulte
  0 siblings, 1 reply; 14+ messages in thread
From: Jambunathan K @ 2010-07-20 12:10 UTC (permalink / raw)
  To: emacs-orgmode


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

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

end of thread, other threads:[~2010-09-05 21:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-20 12:10 [BABEL] Seemless editing of Babel Blocks Jambunathan K
2010-07-20 22:58 ` Eric Schulte
2010-08-16  8:38   ` Jambunathan K
2010-08-16  9:20     ` [BABEL] [PROPOSAL] " Jambunathan K
2010-09-02 23:41       ` Dan Davison
2010-09-02 23:50         ` Erik Iverson
2010-09-03 19:08         ` Tom Short
2010-09-03 20:45           ` Dan Davison
2010-09-04  8:58         ` Jambunathan K
2010-09-04 15:04           ` Eric Schulte
2010-09-05  9:55             ` Jambunathan K
2010-09-05 15:58               ` Dan Davison
2010-09-05 19:12                 ` Eric Schulte
2010-09-05 20:22               ` Eric Schulte

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