From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries Date: Tue, 21 Sep 2010 09:35:29 -0600 Message-ID: <87eicnaz3y.fsf@gmail.com> References: <878w2xfllt.fsf@gmail.com> <877hihdqtz.fsf@gmail.com> <87fwx4sco2.fsf@gmail.com> <87iq20p473.fsf@stats.ox.ac.uk> <4C9865B2.1040103@christianmoe.com> <871v8nfd2i.fsf@gmail.com> <4C98C2A8.1080709@christianmoe.com> <87mxrb40d8.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=48825 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy4sg-0006Hz-N6 for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 11:35:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oy4se-0008UC-IP for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 11:35:42 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:54147) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oy4se-0008Tx-Ad for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 11:35:40 -0400 Received: by pvc30 with SMTP id 30so3849295pvc.0 for ; Tue, 21 Sep 2010 08:35:39 -0700 (PDT) In-Reply-To: <87mxrb40d8.fsf@stats.ox.ac.uk> (Dan Davison's message of "Tue, 21 Sep 2010 15:50:11 +0100") 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: Dan Davison Cc: Richard Riley , emacs-orgmode@gnu.org, mail@christianmoe.com Applied, Thanks Dan Davison writes: > Christian -- thanks, I think your suggestion is better than mine. > > Eric -- here's a small change that allows it to work before the first > headline. (protected from patchwork I hope) > > Dan > > X diff --git a/lisp/ob.el b/lisp/ob.el > X index e3f9fc7..655a79d 100644 > X --- a/lisp/ob.el > X +++ b/lisp/ob.el > X @@ -1146,7 +1146,8 @@ region is not active then the point is demarcated." > X (goto-char place) > X (let ((lang (nth 0 info)) > X (indent (make-string (nth 6 info) ? )) > X - (stars (concat (make-string (org-current-level) ?*) " "))) > X + (stars > X + (concat (make-string (or (org-current-level) 0) ?*) " "))) > X (when (string-match "^[[:space:]]*$" > X (buffer-substring (point-at-bol) > X (point-at-eol))) > X @@ -1161,7 +1162,7 @@ region is not active then the point is demarcated." > X (let ((start (point)) > X (body (delete-and-extract-region > X (if (region-active-p) (mark) (point)) (point))) > X - (stars (concat (make-string (org-current-level) ?*) " "))) > X + (stars (concat (make-string (or (org-current-level) 0) ?*) " "))) > X (insert (concat (if (looking-at "^") "" "\n") > X (if arg (concat stars "\n") "") > X "#+begin_src " (read-from-minibuffer "Lang: ") "\n" > X > > > Christian Moe writes: > >> Hi Eric, >> >> Great, thanks. >> >> Christian >> >> On 9/21/10 3:04 PM, Eric Schulte wrote: >>> Hi Christian, >>> >>> I agree generalizing this function over all block types would be very >>> useful. When I find the time I will make this change. >>> >>> Thanks -- Eric >>> >>> Christian Moe writes: >>> >>>> Hi, >>>> >>>> I'm late to this discussion, but just a lateral thought: >>>> >>>> Would you consider rewriting this as `org-demarcate-block' or similar, >>>> to operate on all #+begin_...end blocks, not just src? >>>> >>>> If generalized this function could be equally useful for non-src >>>> blocks as well. Example blocks come immediately to mind, but there are >>>> non-coding applications too. >>>> >>>> For instance, I store many notes with quotes from various texts, >>>> sometimes in fairly long =#+begin_quote= blocks, which I then need to >>>> split up when I want to write an extended discussion of a passage, >>>> quoting a few lines at a time. >>>> >>>> For those who use verse blocks (I all too seldom have the need...), it >>>> may be even more useful. >>>> >>>> For personal use, I already have a little org-insert-block utility >>>> function to insert/wrap [q]uote, [s]rc, e[x]ample, [v]erse or [o]ther >>>> blocks at a keystroke. This works for me since I use at least the >>>> first two more or less equally often. A generalized demarcate-block >>>> function would be a nice complement. >>>> >>>> Yours, >>>> CM >>>> >>>> >>>> >>>> >>>>>> I've just added this to the org-mode repo. >>>>>> >>>>>>> Not in the babel key map - in the org key map (I use it most in normal >>>>>>> non src org entries to mark a block of elisp as src for samples/examples). >>>>>> >>>>>> For now it still lives in the babel keymap behind (C-c C-v d) since it >>>>>> is fundamentally code-block related, >>>>> >>>>> For me, "fundamentally code-block related", in the absence of >>>>> execution-related functionality, points to org-src.el rather than >>>>> org-babel, so I suggest naming this function >>>>> org-src-demarcate-block. The babel keymap is still a good place for a >>>>> binding -- I think it's reasonable for the babel keymap to accomodate >>>>> pure code block stuff in addition to execution/tangling stuff. >>>>> >>>>> Dan >>>>> >>>>> _______________________________________________ >>>>> 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 >>>>> >>>