emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Make org-babel-result-end work with :wrap keyword
@ 2019-03-28 16:27 Bosché Aurélien
  0 siblings, 0 replies; only message in thread
From: Bosché Aurélien @ 2019-03-28 16:27 UTC (permalink / raw)
  To: emacs-orgmode

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

It seems that the :wrap header argument and the append option to 
the
:results header argument are incompatible in source blocks.

The reason is that `org-babel-result-end` does not find the end of 
the results when :wrap is used and this is due to `org-babel-result-end` only 
looking for blocks of type among `(drawer example-block export-block fixed-width item plain-list 
src-block table)` while the :wrap header argument produces blocks 
of type `special-block`. Appending `special-block` to the previous list seems to work.

It has already been discussed in this thread
http://lists.gnu.org/archive/html/emacs-orgmode/2018-10/threads.html#00393
which ends in a patch request that AFAIK has never been sent.

Below is a patch. I also added some precisions in the docs 
concerning the raw option to the :results header argument (I am 
not a native speaker so do not hesitate to change my wording). I 
tried those changes on the master branch (commit a9d3eaa9f) and no 
new errors showed up during the ERT tests (4 tests failed but 
already failed without this fix). I also tried exporting to html 
and latex and it seemed to work fine here.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-org-babel-result-end-work-with-wrap-keyword.patch --]
[-- Type: text/x-patch, Size: 858 bytes --]

From 3a7beadcc2a1d9e8d7b7f520f4caa992b2b1e6c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Bosch=C3=A9?= <aurelien_bosche@yahoo.fr>
Date: Thu, 28 Mar 2019 17:25:15 +0100
Subject: [PATCH 1/2] Make org-babel-result-end work with :wrap keyword

---
 lisp/ob-core.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 7591e99ca..6f99ca6f2 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2486,7 +2486,7 @@ in the buffer."
 	   (if (memq (org-element-type element)
 		     ;; Possible results types.
 		     '(drawer example-block export-block fixed-width item
-			      plain-list src-block table))
+			      plain-list src-block table special-block))
 	       (save-excursion
 		 (goto-char (min (point-max) ;for narrowed buffers
 				 (org-element-property :end element)))
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Docs-specify-that-raw-option-does-not-delimit-the-re.patch --]
[-- Type: text/x-patch, Size: 2241 bytes --]

From a424317301c738e5d9d0325b594ff31be664d41c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Bosch=C3=A9?= <aurelien_bosche@yahoo.fr>
Date: Fri, 29 Mar 2019 07:46:42 +0100
Subject: [PATCH 2/2] Docs: specify that raw option does not delimit the
 results

---
 doc/org-manual.org | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index b818b4bae..d006c5b73 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -17275,8 +17275,10 @@ follows from the type specified above.
 
 - =raw= ::
 
-  Interpreted as raw Org mode.  Inserted directly into the buffer.
-  Aligned if it is a table.  Usage example: =:results value raw=.
+  Interpreted as raw Org mode. Inserted directly into the buffer.
+  Aligned if it is a table. No delimiters are added to mark the end of
+  the raw output so options like =replace=, =append= and =prepend=
+  won't work as intended. Usage example: =:results value raw=.  
 
 #+cindex: @samp{wrap}, header argument
 The =wrap= header argument unconditionnally marks the results block by
@@ -17286,14 +17288,14 @@ specified, Org wraps the results in a =#+BEGIN_results=
 value listed above.  E.g.,
 
 #+begin_example
-,#+BEGIN_SRC emacs-lisp :results html :wrap EXPORT markdown
-"<blink>Welcome back to the 90's</blink>"
-,#+END_SRC
+  ,#+BEGIN_SRC emacs-lisp :results html :wrap EXPORT markdown
+  "<blink>Welcome back to the 90's</blink>"
+  ,#+END_SRC
 
-,#+RESULTS:
-,#+BEGIN_EXPORT markdown
-<blink>Welcome back to the 90's</blink>
-,#+END_EXPORT
+  ,#+RESULTS:
+  ,#+BEGIN_EXPORT markdown
+  <blink>Welcome back to the 90's</blink>
+  ,#+END_EXPORT
 #+end_example
 
 *** Handling
@@ -17325,6 +17327,13 @@ Handling options after collecting the results.
   Does not remove previous results.  Usage example: =:results output
   prepend=.
 
+Options =replace=, =append= and =prepend= need to find the end of the
+previously inserted results and so won't work as intended if the =raw=
+option to the =results= header argument was in force. In this case
+consider using the =:wrap= header argument.
+
+Handling options after collecting the results.
+
 *** Post-processing
 :PROPERTIES:
 :UNNUMBERED: notoc
-- 
2.21.0


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


<#secure method=pgpmime mode=sign>
--
Bosché Aurélien

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-03-29  7:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-28 16:27 [PATCH] Make org-babel-result-end work with :wrap keyword Bosché Aurélien

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).