Hi,

the function (org-babel-remove-result-one-or-many) does not remove results
of call lines when called with prefix argument. The attached patch makes
it do so.

I have attached two simple test cases as well.

Regards,
Momchil
>From 7ff68b05d3fa0f06439b58ee9a7e980235d52d45 Mon Sep 17 00:00:00 2001
From: Momchil Ivanov <momc...@xaxo.eu>
Date: Thu, 27 Feb 2025 12:15:29 +0100
Subject: [PATCH] lisp/ob-core.el: Fix org-babel-remove-result-one-or-many

* lisp/ob-core.el (org-babel-remove-result-one-or-many): This function
removes results from source blocks when called with prefix
argument. Make it remove results of call lines in this case as well.

TINYCHANGE
---
 lisp/ob-core.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 27e652558..2f66ab17d 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2881,7 +2881,9 @@ If called with prefix argument ARG, remove all result blocks in the
 buffer."
   (interactive "P")
   (if arg
-      (org-babel-map-src-blocks nil (org-babel-remove-result))
+      (progn
+        (org-babel-map-src-blocks nil (org-babel-remove-result))
+        (org-babel-map-call-lines nil (org-babel-remove-result)))
     (org-babel-remove-result)))
 
 (defun org-babel-result-end ()
-- 
2.39.5
Define a source code block named ~f~ and evaluate it to produce a
=RESULTS= block:

#+name: f
#+begin_src sh :var x="a" :eval yes :results output
  echo "${x}"
#+end_src

Call the named source code block ~f~ to produce another =RESULTS=
block:

#+call: f(x="b")

#+RESULTS:
: b

Try to remove all results blocks.

#+begin_src emacs-lisp :results none
  (org-babel-remove-result-one-or-many t)
#+end_src
Define a source code block named ~f~ and evaluate it to produce a
=RESULTS= block:

#+name: f
#+begin_src sh :var x="a" :eval yes :results output
  echo "${x}"
#+end_src

Call the named source code block ~f~ to produce another =RESULTS=
block:

#+call: f(x="b")

Fix function ~org-babel-remove-result-one-or-many~ to remove results
of call lines as well:

#+begin_src emacs-lisp :results none
  (defun org-babel-remove-result-one-or-many (x)
    "Remove the result of the current source block.
  If called with a prefix argument, remove all result blocks
  in the buffer."
    (interactive "P")
    (if x
        (progn
          (org-babel-map-src-blocks nil (org-babel-remove-result))
          (org-babel-map-call-lines nil (org-babel-remove-result)))
      (org-babel-remove-result)))
#+end_src

Try to remove all results blocks.

#+begin_src emacs-lisp :results none
  (org-babel-remove-result-one-or-many t)
#+end_src

Reply via email to