* [PATCH] Add :special header argument @ 2012-01-08 16:12 Thomas S. Dye 2012-01-08 18:24 ` Achim Gratz 0 siblings, 1 reply; 7+ messages in thread From: Thomas S. Dye @ 2012-01-08 16:12 UTC (permalink / raw) To: Org-mode [-- Attachment #1: Type: text/plain, Size: 460 bytes --] Aloha all, 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". I use this in conjunction with org-special-blocks for LaTeX export. I'm writing a didactic article where I set off results and format them with the LaTeX framed package. All the best, Tom [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Special header argument --] [-- Type: text/x-patch, Size: 2096 bytes --] From 4a31fd6dc99168315dba91fea5df9f07233ad5e1 Mon Sep 17 00:00:00 2001 From: Thomas Dye <dk@poto.local> Date: Sun, 8 Jan 2012 06:00:47 -1000 Subject: [PATCH] * lisp/ob.el: Add :special header argument --- lisp/ob.el | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index 0288eb3..da63675 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -378,7 +378,7 @@ then run `org-babel-pop-to-session'." (noweb-ref . :any) (padline . ((yes no))) (results . ((file list vector table scalar verbatim) - (raw org html latex code pp wrap) + (raw org html latex code pp wrap special) (replace silent append prepend) (output value))) (rownames . ((no yes))) @@ -1622,6 +1622,7 @@ If the path of the link is a file path it is expanded using ;; scalar result (echo-res result)))) +(defvar org-babel-wrap-special "results") (defun org-babel-insert-result (result &optional result-params info hash indent lang) "Insert RESULT into the current buffer. @@ -1663,6 +1664,10 @@ latex --- results are added inside of a #+BEGIN_LATEX block. This is a good option if you code block will output latex formatted text. +special --- results are added inside of a #+BEGIN_ ... #+END_ + block, with the block name taken from the variable + org-babel-wrap-special. + code ---- the results are extracted in the syntax of the source code of the language being evaluated and are added inside of a #+BEGIN_SRC block with the source-code @@ -1767,6 +1772,8 @@ code ---- the results are extracted in the syntax of the source (goto-char beg) (if (org-at-table-p) (org-cycle))) ((member "wrap" result-params) (wrap ":RESULTS:" ":END:")) + ((member "special" result-params) + (wrap (format "#+BEGIN_%s" org-babel-wrap-special) (format "#+END_%s" org-babel-wrap-special) )) ((and (not (proper-list-p result)) (not (member "file" result-params))) (org-babel-examplize-region beg end results-switches) -- 1.7.5.4 [-- Attachment #3: Type: text/plain, Size: 146 bytes --] -- T.S. Dye & Colleagues, Archaeologists 735 Bishop St, Suite 315, Honolulu, HI 96813 Tel: 808-529-0866, Fax: 808-529-0884 http://www.tsdye.com ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Add :special header argument 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 0 siblings, 1 reply; 7+ messages in thread From: Achim Gratz @ 2012-01-08 18:24 UTC (permalink / raw) To: emacs-orgmode 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. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Factory and User Sound Singles for Waldorf Blofeld: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add :special header argument 2012-01-08 18:24 ` Achim Gratz @ 2012-01-08 19:58 ` Eric Schulte 2012-01-08 21:31 ` Thomas S. Dye 0 siblings, 1 reply; 7+ messages in thread From: Eric Schulte @ 2012-01-08 19:58 UTC (permalink / raw) To: Achim Gratz; +Cc: emacs-orgmode [-- 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/ ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Add :special header argument 2012-01-08 19:58 ` Eric Schulte @ 2012-01-08 21:31 ` Thomas S. Dye 2012-01-12 2:14 ` [PATCH] :wrap header documentation Thomas S. Dye 0 siblings, 1 reply; 7+ messages in thread From: Thomas S. Dye @ 2012-01-08 21:31 UTC (permalink / raw) To: Eric Schulte; +Cc: Achim Gratz, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1629 bytes --] Eric Schulte <eric.schulte@gmx.com> writes: > 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, > > > #+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 Hi Eric, Thanks for the :wrap header argument. It works for me. The attached patch on top of your patch looks for :wrap drawer, and puts the result in a drawer, rather than wrapping the results in #+begin ... #+end. What I'm trying to do is make :results wrap obsolete. Also, note that with the :wrap header argument, :results org and :results latex are both redundant. I'm not sure how you want to handle this--whether to leave them in place or remove them. I'll volunteer to work on the documentation. All the best, Tom [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Drawer option --] [-- Type: text/x-patch, Size: 915 bytes --] From 3c8a9500b3efcf7211946968cb5661f70808be1d Mon Sep 17 00:00:00 2001 From: Thomas Dye <dk@poto.local> Date: Sun, 8 Jan 2012 11:19:39 -1000 Subject: [PATCH] * lisp/ob.el: Add drawer option to :wrap --- lisp/ob.el | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index b51cc51..923fd6d 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1757,7 +1757,11 @@ code ---- the results are extracted in the syntax of the source (cond ((assoc :wrap (nth 2 info)) (let ((name (or (cdr (assoc :wrap (nth 2 info))) "results"))) - (wrap (concat "#+BEGIN_" name) (concat "#+END_" name)))) + (if (equal name "drawer") + (wrap ":RESULTS:" ":END:") + (wrap (concat "#+BEGIN_" name) (concat "#+END_" name)) + ) + )) ((member "html" result-params) (wrap "#+BEGIN_HTML" "#+END_HTML")) ((member "latex" result-params) -- 1.7.5.4 [-- Attachment #3: Type: text/plain, Size: 41 bytes --] -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] :wrap header documentation 2012-01-08 21:31 ` Thomas S. Dye @ 2012-01-12 2:14 ` Thomas S. Dye 2012-01-12 2:44 ` Eric Schulte 0 siblings, 1 reply; 7+ messages in thread From: Thomas S. Dye @ 2012-01-12 2:14 UTC (permalink / raw) To: Eric Schulte; +Cc: Achim Gratz, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 134 bytes --] Hi Eric, Attached please find a first draft of a patch for the manual entry documenting a :wrap header argument. All the best, Tom [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Manual patch --] [-- Type: text/x-patch, Size: 2528 bytes --] From 4e3a66a4fbfd8d6914fbfd3924981ae5c526aa4a Mon Sep 17 00:00:00 2001 From: Thomas Dye <dk@poto.myhome.westell.com> Date: Wed, 11 Jan 2012 16:06:17 -1000 Subject: [PATCH] * doc/org.texi: added documentation for :wrap --- doc/org.texi | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index f619c90..7ca797b 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -715,6 +715,7 @@ Specific header arguments * rownames:: Handle row names in tables * shebang:: Make tangled files executable * eval:: Limit evaluation of specific code blocks +* wrap:: Mark source block evaluation results Miscellaneous @@ -13007,6 +13008,7 @@ argument in lowercase letters. The following header arguments are defined: * rownames:: Handle row names in tables * shebang:: Make tangled files executable * eval:: Limit evaluation of specific code blocks +* wrap:: Mark source block evaluation results @end menu Additional header arguments are defined on a language-specific basis, see @@ -13865,7 +13867,7 @@ Setting the @code{:shebang} header argument to a string value first line of any tangled file holding the code block, and the file permissions of the tangled file are set to make it executable. -@node eval, , shebang, Specific header arguments +@node eval, wrap, shebang, Specific header arguments @subsubsection @code{:eval} The @code{:eval} header argument can be used to limit the evaluation of specific code blocks. The @code{:eval} header argument can be useful for @@ -13890,6 +13892,14 @@ If this header argument is not set then evaluation is determined by the value of the @code{org-confirm-babel-evaluate} variable see @ref{Code evaluation security}. +@node wrap, , eval, Specific header arguments +@subsubsection @code{:wrap} +The @code{:wrap} header argument is used to mark the results of source block +evaluation. The header argument can be passed a string that typically will +be appended to @code{#+BEGIN_} and @code{#+END_}, which will then be used to +wrap the results. An exception to this rule is the string @code{drawer}, +which instead wraps the results in an Org mode drawer. + @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code @section Results of evaluation @cindex code block, results of evaluation -- 1.7.5.4 [-- Attachment #3: Type: text/plain, Size: 1778 bytes --] tsd@tsdye.com (Thomas S. Dye) writes: > Eric Schulte <eric.schulte@gmx.com> writes: > >> 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, >> >> >> #+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 > > Hi Eric, > > Thanks for the :wrap header argument. It works for me. > > The attached patch on top of your patch looks for :wrap drawer, and puts > the result in a drawer, rather than wrapping the results in #+begin > ... #+end. > > What I'm trying to do is make :results wrap obsolete. > > Also, note that with the :wrap header argument, :results org and > :results latex are both redundant. I'm not sure how you want to handle > this--whether to leave them in place or remove them. > > I'll volunteer to work on the documentation. > > All the best, > Tom -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] :wrap header documentation 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 0 siblings, 1 reply; 7+ messages in thread From: Eric Schulte @ 2012-01-12 2:44 UTC (permalink / raw) To: Thomas S. Dye; +Cc: Achim Gratz, emacs-orgmode Hi Tom, Thanks for this patch, I've just pushed up an augmented version which more closely matches the current behavior. tsd@tsdye.com (Thomas S. Dye) writes: > Hi Eric, > > Attached please find a first draft of a patch for the manual entry > documenting a :wrap header argument. > > All the best, > Tom > > > > tsd@tsdye.com (Thomas S. Dye) writes: > >> Eric Schulte <eric.schulte@gmx.com> writes: >> >>> 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, >>> >>> >>> #+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 >> >> Hi Eric, >> >> Thanks for the :wrap header argument. It works for me. >> >> The attached patch on top of your patch looks for :wrap drawer, and puts >> the result in a drawer, rather than wrapping the results in #+begin >> ... #+end. >> >> What I'm trying to do is make :results wrap obsolete. >> >> Also, note that with the :wrap header argument, :results org and >> :results latex are both redundant. I'm not sure how you want to handle >> this--whether to leave them in place or remove them. >> >> I'll volunteer to work on the documentation. >> >> All the best, >> Tom -- Eric Schulte http://cs.unm.edu/~eschulte/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] :wrap header documentation 2012-01-12 2:44 ` Eric Schulte @ 2012-01-12 4:09 ` Thomas S. Dye 0 siblings, 0 replies; 7+ messages in thread From: Thomas S. Dye @ 2012-01-12 4:09 UTC (permalink / raw) To: Eric Schulte; +Cc: Achim Gratz, emacs-orgmode Hi Eric, It's great to find :wrap in master. Thanks for augmenting the draft. All the best, Tom Eric Schulte <eric.schulte@gmx.com> writes: > Hi Tom, > > Thanks for this patch, I've just pushed up an augmented version which > more closely matches the current behavior. > > tsd@tsdye.com (Thomas S. Dye) writes: > >> Hi Eric, >> >> Attached please find a first draft of a patch for the manual entry >> documenting a :wrap header argument. >> >> All the best, >> Tom >> >> >> >> tsd@tsdye.com (Thomas S. Dye) writes: >> >>> Eric Schulte <eric.schulte@gmx.com> writes: >>> >>>> 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, >>>> >>>> >>>> #+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 >>> >>> Hi Eric, >>> >>> Thanks for the :wrap header argument. It works for me. >>> >>> The attached patch on top of your patch looks for :wrap drawer, and puts >>> the result in a drawer, rather than wrapping the results in #+begin >>> ... #+end. >>> >>> What I'm trying to do is make :results wrap obsolete. >>> >>> Also, note that with the :wrap header argument, :results org and >>> :results latex are both redundant. I'm not sure how you want to handle >>> this--whether to leave them in place or remove them. >>> >>> I'll volunteer to work on the documentation. >>> >>> All the best, >>> Tom -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-01-12 4:10 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.