From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: org-babel - utility to ease chopping src chunks into smaller org entries Date: Sun, 19 Sep 2010 12:21:37 -0600 Message-ID: <878w2xfllt.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=56266 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OxRnJ-0002qH-I8 for emacs-orgmode@gnu.org; Sun, 19 Sep 2010 17:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OxRnI-00071O-4J for emacs-orgmode@gnu.org; Sun, 19 Sep 2010 17:51:33 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:53268) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxRnH-00070x-WD for emacs-orgmode@gnu.org; Sun, 19 Sep 2010 17:51:32 -0400 Received: by pvc30 with SMTP id 30so2711307pvc.0 for ; Sun, 19 Sep 2010 14:51:31 -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: Richard Riley Cc: emacs-orgmode@gnu.org Hi Richard, This is a good idea, I too frequently find myself splitting code blocks. How about this following alternative implementation which should be smart enough to notice if it is inside of a code block, and should work across any code block type. --8<---------------cut here---------------start------------->8--- (defun org-babel-split-block-maybe (&optional arg) "Split the current source code block on the cursor." (interactive "P") ((lambda (info) (if info (let ((lang (nth 0 info)) (indent (make-string (nth 6 info) ? )) (stars (concat (make-string (org-current-level) ?*) " "))) (insert (concat (if (looking-at "^") "" "\n") indent "#+end_src\n" (if arg stars indent) "\n" indent "#+begin_src " lang (if (looking-at "[\n\r]") "" "\n "))) (when arg (previous-line) (move-end-of-line 1))) (message "Not in src block."))) (org-babel-get-src-block-info))) --8<---------------cut here---------------end--------------->8--- Let me know what you think. I notice your implementation uses regions, where as this one does not, so it's possible I left out some functionality. I'd like to include some version of this functionality into Org-mode core. Best -- Eric Richard Riley writes: > I often find myself chopping a large source code block into smaller > entities with their own notes, tags and comments etc. This small utility > facilitates that by wrapping the current region with org entry markers > and src code delimiters. It assumes you are in a currently src block. > > http://splash-of-open-sauce.blogspot.com/2010/09/mark-region-as-src-code-if-prefix-used.html > > Its currently hardcoded for emacs-lisp but it might be useful nonetheless. > > (Anyone know how to make blogspot line wrap?) > > > r. > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode