all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Daniel Ortmann <daniel.ortmann@oracle.com>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Add new :results ignore header argument (was: [External] : Re: [BUG] executing sh source block with ':results none' encounters error region is longer than org-table-convert-region-max-lines [9.6-pre (release_9.5.5-1118-g70cee1 @ /home/dortmann/src/git-org-mode/lisp/)])
Date: Tue, 22 Nov 2022 02:12:58 +0000	[thread overview]
Message-ID: <87cz9fd9ed.fsf@localhost> (raw)
In-Reply-To: <1e89cf84-e38c-382b-71cf-e4a8ce9b1bf9@oracle.com>

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

Daniel Ortmann <daniel.ortmann@oracle.com> writes:

> I am happy with whatever you decide.  :-)

Then, here is a tentative patch introducing new :results ignore header
argument.

Any objections?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-babel-Add-new-results-ignore-header-argument.patch --]
[-- Type: text/x-patch, Size: 4422 bytes --]

From ea48cb04301588688f736e9461ebb7824224fe44 Mon Sep 17 00:00:00 2001
Message-Id: <ea48cb04301588688f736e9461ebb7824224fe44.1669083088.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Tue, 22 Nov 2022 10:06:24 +0800
Subject: [PATCH] org-babel: Add new :results ignore header argument

* lisp/ob-core.el (org-babel-result-cond): Unconditionally return nil
and suppress all the processing for :results ignore.
(org-babel-common-header-args-w-values):
(org-babel-sha1-hash): Add the new value to know :results value list.
* doc/org-manual.org (Handling):
* etc/ORG-NEWS (New =:results ignore= header argument): Document the
new value.

Reported-by: Daniel Ortmann <daniel.ortmann@oracle.com>
Link: https://orgmode.org/list/87tu2tjary.fsf@localhost
---
 doc/org-manual.org |  8 ++++++++
 etc/ORG-NEWS       |  8 ++++++++
 lisp/ob-core.el    | 31 ++++++++++++++++---------------
 3 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 4f877d371..194cabe99 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -18482,6 +18482,14 @@ *** Handling
   can still be used when referenced from another code block.
   Usage example: =:results none=.
 
+- =ignore= ::
+
+  Ignore the results completely.  This option is similar to =none=,
+  but no processing is performed on the return value.  Calling the
+  code block programatically (see [[*How to evaluate source code]]) or by
+  reference (see [[*Passing arguments]] and [[*Noweb Reference Syntax]]) will
+  always yield nil.
+
 - =append= ::
 
   Append results to the Org buffer.  Latest results are at the bottom.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 1f79f8ae5..d92cb139a 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -373,6 +373,14 @@ value of ~org-babel-clojure-backend~. For example:
 (range 2)
 #+end_src
 
+*** New =:results ignore= header argument
+
+Unlike =:results none=, the return value of code blocks called with
+=:results ignore= header argument is always ~nil~.  Org does not
+attempt to analyze the results and simply returns nil.  This can be
+useful when the code block is used for side effects only but generates
+large outputs that may be slow to analyze for Org.
+
 ** New options
 *** A new option for custom setting ~org-refile-use-outline-path~ to show document title in refile targets
 
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 1259909a0..89d3e104c 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -425,7 +425,7 @@ (defconst org-babel-common-header-args-w-values
     (prologue   . :any)
     (results	. ((file list vector table scalar verbatim)
 		   (raw html latex org code pp drawer link graphics)
-		   (replace silent none append prepend)
+		   (replace silent none ignore append prepend)
 		   (output value)))
     (rownames	. ((no yes)))
     (sep	. :any)
@@ -1345,7 +1345,7 @@ (defun org-babel-sha1-hash (&optional info context)
 		(lambda (a b) (string< (car a) (car b)))))
     (let* ((rm (lambda (lst)
 		 (dolist (p '("replace" "silent" "none"
-			      "append" "prepend"))
+			      "ignore" "append" "prepend"))
 		   (setq lst (remove p lst)))
 		 lst))
 	   (norm (lambda (arg)
@@ -3282,19 +3282,20 @@ (defmacro org-babel-result-cond (result-params scalar-form &rest table-forms)
   (declare (indent 1) (debug t))
   (org-with-gensyms (params)
     `(let ((,params ,result-params))
-       (if (or (member "scalar" ,params)
-	       (member "verbatim" ,params)
-	       (member "html" ,params)
-	       (member "code" ,params)
-	       (member "pp" ,params)
-	       (member "file" ,params)
-	       (and (or (member "output" ,params)
-			(member "raw"    ,params)
-			(member "org"    ,params)
-			(member "drawer" ,params))
-		    (not (member "table" ,params))))
-	   ,scalar-form
-	 ,@table-forms))))
+       (unless (member "ignore" ,params)
+         (if (or (member "scalar" ,params)
+	         (member "verbatim" ,params)
+	         (member "html" ,params)
+	         (member "code" ,params)
+	         (member "pp" ,params)
+	         (member "file" ,params)
+	         (and (or (member "output" ,params)
+			  (member "raw"    ,params)
+			  (member "org"    ,params)
+			  (member "drawer" ,params))
+		      (not (member "table" ,params))))
+	     ,scalar-form
+	   ,@table-forms)))))
 
 (defmacro org-babel-temp-directory ()
   "Return temporary directory suitable for `default-directory'."
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 225 bytes --]



-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

  reply	other threads:[~2022-11-22  2:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 18:04 [BUG] executing sh source block with ':results none' encounters error region is longer than org-table-convert-region-max-lines [9.6-pre (release_9.5.5-1118-g70cee1 @ /home/dortmann/src/git-org-mode/lisp/)] Daniel Ortmann
2022-11-18  8:45 ` Ihor Radchenko
2022-11-19 18:39   ` [External] : " Daniel Ortmann
2022-11-21  2:34     ` Ihor Radchenko
2022-11-21 20:47       ` Daniel Ortmann
2022-11-22  2:12         ` Ihor Radchenko [this message]
2022-11-22  6:02           ` [PATCH] Add new :results ignore header argument (was: [External] : Re: [BUG] executing sh source block with ':results none' encounters error region is longer than org-table-convert-region-max-lines [9.6-pre (release_9.5.5-1118-g70cee1 @ /home/dortmann/src/git-org-mode/lisp/)]) Daniel Ortmann
2022-11-23  7:29             ` Daniel Ortmann
2022-11-25 23:23           ` Rudolf Adamkovič
2022-11-26  2:12             ` Ihor Radchenko
2022-11-27  0:35               ` Ihor Radchenko

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cz9fd9ed.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=daniel.ortmann@oracle.com \
    --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 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.