emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [BABEL] Seemless editing of Babel Blocks
Date: Tue, 20 Jul 2010 17:40:30 +0530	[thread overview]
Message-ID: <4C459236.3@gmail.com> (raw)


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

             reply	other threads:[~2010-07-20 12:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20 12:10 Jambunathan K [this message]
2010-07-20 22:58 ` [BABEL] Seemless editing of Babel Blocks 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C459236.3@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).