branch: externals/org
commit 480c9b706a273984991a38b3542e1acc69ef5105
Author: Christian Moe <[email protected]>
Commit: Ihor Radchenko <[email protected]>

    ob-core.el: Respect no/nil value in :wrap header argument
    
    * lisp/ob-core.el (org-babel-insert-result): Do not wrap results if
    the value of the :wrap header argument is "no" or "nil".
    * doc/org-manual.org (Results of Evaluation): Update documentation.
    * etc/ORG-NEWS (=:wrap= header argument can now be explicitly
    disabled): Announce the new feature.
    
    An empty :wrap header argument leads results to be wrapped in a
    "results" special block.  It may sometimes be useful to turn off
    wrapping explicitly for a particular block, e.g.  if the value of
    :wrap is set programatically or in a file-level header.
    
    Prompted by an issue with captioning results when using the by-backend
    trick in
    https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html.
    Reported-by: Mathew Moore <[email protected]>
    Link: 
https://list.orgmode.org/CAAur0QTNjLMPp=2twqrjlen3tk6e1a6ozbavexzvga6yid5...@mail.gmail.com
---
 doc/org-manual.org | 8 ++++----
 etc/ORG-NEWS       | 8 ++++++++
 lisp/ob-core.el    | 4 ++++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index fe2cd171e1..61bc764305 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -19331,10 +19331,10 @@ follows from the type specified above.
 
 #+cindex: @samp{wrap}, header argument
 The =wrap= header argument unconditionally marks the results block by
-appending strings to =#+BEGIN_= and =#+END_=.  If no string is
-specified, Org wraps the results in a =#+BEGIN_results=
-... =#+END_results= block.  It takes precedent over the =results=
-value listed above.  E.g.,
+appending strings to =#+BEGIN_= and =#+END_=, except if the value is
+=nil= or =no=.  If no string is specified, Org wraps the results in a
+=#+BEGIN_results= ... =#+END_results= block.  It takes precedent over
+the =results= value listed above.  E.g.,
 
 #+begin_example
 ,#+BEGIN_SRC emacs-lisp :results html :wrap EXPORT markdown
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 6cb9eb7a73..2e1f79f8c2 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -172,6 +172,14 @@ removed as part of refactoring for numeric priorities.
 # We list the most important features, and the features that may
 # require user action to be used.
 
+*** =:wrap= header argument can now be explicitly disabled
+
+Previously, presence of =:wrap= argument (inherited or not) in code
+block headers always made the block results wrapped. There was no way
+to disable wrapping if =:wrap= was specified in the inherited header
+arguments. Now, =:wrap no= or =:wrap nil= will explicitly disable
+wrapping.
+
 *** All Org link types can be previewed
 :PROPERTIES:
 :CUSTOM_ID: link-preview
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index c112d579de..7d0e893529 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2725,6 +2725,10 @@ result:
                           (opening-line (concat "#+begin_" full))
                           (closing-line (concat "#+end_" type)))
                      (cond
+                       ;; Do nothing if type is "no" or "nil"
+                       ((or (org-string-equal-ignore-case type "nil")
+                            (org-string-equal-ignore-case type "no"))
+                        nil)
                       ;; Escape contents from "export" wrap.  Wrap
                       ;; inline results within an export snippet with
                       ;; appropriate value.

Reply via email to