From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: [BABEL] Seemless editing of Babel Blocks Date: Tue, 20 Jul 2010 17:40:30 +0530 Message-ID: <4C459236.3@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=52768 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObBep-0007Qd-Ri for emacs-orgmode@gnu.org; Tue, 20 Jul 2010 08:10:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ObBeo-00064h-Cu for emacs-orgmode@gnu.org; Tue, 20 Jul 2010 08:10:47 -0400 Received: from mail-pz0-f41.google.com ([209.85.210.41]:63900) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObBeo-00064X-3P for emacs-orgmode@gnu.org; Tue, 20 Jul 2010 08:10:46 -0400 Received: by pzk33 with SMTP id 33so4240324pzk.0 for ; Tue, 20 Jul 2010 05:10:45 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 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) ) )