From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Riley Subject: Re: org-babel - utility to ease chopping src chunks into smaller org entries Date: Mon, 20 Sep 2010 01:20:36 +0200 Message-ID: References: <878w2xfllt.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=37156 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OxTBm-0001IA-GI for emacs-orgmode@gnu.org; Sun, 19 Sep 2010 19:20:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OxTBk-0001ku-He for emacs-orgmode@gnu.org; Sun, 19 Sep 2010 19:20:54 -0400 Received: from lo.gmane.org ([80.91.229.12]:38456) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxTBk-0001ko-01 for emacs-orgmode@gnu.org; Sun, 19 Sep 2010 19:20:52 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OxTBg-0007B7-2t for emacs-orgmode@gnu.org; Mon, 20 Sep 2010 01:20:48 +0200 Received: from 85.183.18.158 ([85.183.18.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 20 Sep 2010 01:20:48 +0200 Received: from rileyrg by 85.183.18.158 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 20 Sep 2010 01:20:48 +0200 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 Richard Riley writes: > "Eric Schulte" writes: > >> >> Let me know what you think. I notice your implementation uses >> regions, > > It puts the begin/src markers around the region if selected or current word. > >> 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. > > _______________________________________________ > 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 > using your lang selection example If not in a source block then just surround current region with #+begin/end_src. If no region just put in markers around empty area. Dont create new org items since probably just including src code in an existing org item. If in a source block with region create new region with current region. If no region just create new empty block. previous src blocks delimited and marked as org items at current level (because almost certainly splitting the code to maintain it in discreate titled blocks. --8<---------------cut here---------------start------------->8--- (define-key org-mode-map (kbd "C-c C-b") 'rgr/org-split-src) (defun rgr/org-split-src(&optional arg) (interactive "P") (beginning-of-line) (save-excursion((lambda(info) (if info (let ((lang (nth 0 info)) (stars (make-string (org-current-level) ?*))) (insert (format "%s\n%s\n#+begin_src %s\n%s#+end_src\n%s\n#+begin_src %s\n" "#+end_src" stars lang (if (region-active-p) (delete-and-extract-region (region-beginning) (region-end)) "\n") stars lang))) (insert (format "\n#+begin_src\n%s\n#+end_src\n" (if (region-active-p) (delete-and-extract-region (region-beginning) (region-end)) ""))))) (org-babel-get-src-block-info)))) --8<---------------cut here---------------end--------------->8---