emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: Achim Gratz <Stromeko@nexgo.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Add :special header argument
Date: Sun, 08 Jan 2012 12:58:31 -0700	[thread overview]
Message-ID: <87hb06yniw.fsf@gmx.com> (raw)
In-Reply-To: <87ipkm3vda.fsf@Rainer.invalid> (Achim Gratz's message of "Sun, 08 Jan 2012 19:24:49 +0100")

[-- Attachment #1: Type: text/plain, Size: 814 bytes --]

Achim Gratz <Stromeko@nexgo.de> writes:

> tsd@tsdye.com (Thomas S. Dye) writes:
>> The attached patch defines a new header argument, :special, which wraps
>> the results of Org babel source block execution in a #BEGIN_ ... #+END_
>> block.  The block name is taken from a new variable
>> org-babel-wrap-special, which is initialized as "results".
>
> What is the rationale for feeding the block name via a configuration
> variable rather then a value to the header argument ":special"?
>
>
> Regards,
> Achim.

Attached is an alternate patch and an example of its use.  This patch
introduces a ":wrap" header argument which accepts an optional value
used to specify the name of the block with which to wrap results.  If
this looks workable we could push it up once it gets some documentation
and tests.

Cheers,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: wrap.org --]
[-- Type: text/x-org, Size: 188 bytes --]

#+Title: demonstrating the new :wrap header argument

#+begin_src emacs-lisp :wrap schulte
  '((1 2)
    (3 4))
#+end_src

#+results:
#+BEGIN_schulte
| 1 | 2 |
| 3 | 4 |
#+END_schulte





[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-introduce-new-wrap-header-argument-for-wrapping-resu.patch --]
[-- Type: text/x-patch, Size: 2209 bytes --]

From 45b2335d5c6fba995ffe6556e5a1c9112ea392af Mon Sep 17 00:00:00 2001
From: Eric Schulte <eric.schulte@gmx.com>
Date: Sun, 8 Jan 2012 12:54:13 -0700
Subject: [PATCH] introduce new ":wrap" header argument for wrapping results
 in named blocks

* lisp/ob.el (org-babel-common-header-args-w-values): Add the new
  header argument name.
  (org-babel-insert-result): Respect the value of the :wrap header
  argument when inserting results.
  (org-babel-result-end): Find the end of arbitrarily named result
  blocks.
---
 lisp/ob.el |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lisp/ob.el b/lisp/ob.el
index 0288eb3..b51cc51 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -386,7 +386,8 @@ then run `org-babel-pop-to-session'."
     (session	. :any)
     (shebang	. :any)
     (tangle	. ((tangle yes no :any)))
-    (var	. :any)))
+    (var	. :any)
+    (wrap       . :any)))
 
 (defconst org-babel-header-arg-names
   (mapcar #'car org-babel-common-header-args-w-values)
@@ -1754,6 +1755,9 @@ code ---- the results are extracted in the syntax of the source
 	  (setq end (point-marker))
 	  ;; possibly wrap result
 	  (cond
+	   ((assoc :wrap (nth 2 info))
+	    (let ((name (or (cdr (assoc :wrap (nth 2 info))) "results")))
+	      (wrap (concat "#+BEGIN_" name) (concat "#+END_" name))))
 	   ((member "html" result-params)
 	    (wrap "#+BEGIN_HTML" "#+END_HTML"))
 	   ((member "latex" result-params)
@@ -1804,11 +1808,10 @@ code ---- the results are extracted in the syntax of the source
      ((looking-at "^\\([ \t]*\\):RESULTS:")
       (re-search-forward (concat "^" (match-string 1) ":END:")))
      (t
-      (let ((case-fold-search t)
-	    (blocks-re (regexp-opt
-			(list "latex" "html" "example" "src" "result" "org"))))
-	(if (looking-at (concat "[ \t]*#\\+begin_" blocks-re))
-	    (progn (re-search-forward (concat "[ \t]*#\\+end_" blocks-re) nil t)
+      (let ((case-fold-search t))
+	(if (looking-at (concat "[ \t]*#\\+begin_\\([^ \t\n\r]+\\)"))
+	    (progn (re-search-forward (concat "[ \t]*#\\+end_" (match-string 1))
+				      nil t)
 		   (forward-char 1))
 	  (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
 	    (forward-line 1))))
-- 
1.7.8.1


[-- Attachment #4: Type: text/plain, Size: 47 bytes --]


-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

  reply	other threads:[~2012-01-08 19:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-08 16:12 [PATCH] Add :special header argument Thomas S. Dye
2012-01-08 18:24 ` Achim Gratz
2012-01-08 19:58   ` Eric Schulte [this message]
2012-01-08 21:31     ` Thomas S. Dye
2012-01-12  2:14       ` [PATCH] :wrap header documentation Thomas S. Dye
2012-01-12  2:44         ` Eric Schulte
2012-01-12  4:09           ` Thomas S. Dye

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=87hb06yniw.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=Stromeko@nexgo.de \
    --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).