emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] Make org-babel-result-end work with :wrap keyword


From: Bosché Aurélien
Subject: [O] [PATCH] Make org-babel-result-end work with :wrap keyword
Date: Thu, 28 Mar 2019 17:27:23 +0100
User-agent: mu4e 1.1.0; emacs 26.1

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.

>From 3a7beadcc2a1d9e8d7b7f520f4caa992b2b1e6c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Bosch=C3=A9?= <address@hidden>
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

>From a424317301c738e5d9d0325b594ff31be664d41c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Bosch=C3=A9?= <address@hidden>
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


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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]