emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Bash results broken?


From: Ihor Radchenko
Subject: Re: Bash results broken?
Date: Sun, 25 Dec 2022 11:23:53 +0000

Matt <matt@excalamus.com> writes:

> For :results list, the manual says, "Interpret the results as an Org list.  
> If the result is a single value, create a list of one element".  I don't find 
> that clarifies what would be best.
>
> Thoughts?

In my patch, I followed the previous code branch:

(list (if (stringp e) e (format "%S" e)))

As you see, "%S" have been used previously for non-string results.
I cannot find explanation in git log.

That said, I think that it will be more consistent to leave strings
specifically as is. See the attached patch.

>From 22ee116511a40cc9cbee02e66799fdeb3e81ba78 Mon Sep 17 00:00:00 2001
Message-Id: 
<22ee116511a40cc9cbee02e66799fdeb3e81ba78.1671967390.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Sun, 25 Dec 2022 14:20:48 +0300
Subject: [PATCH] org-babel-insert-result: Output strings as is for lists of
 strings

* lisp/ob-core.el (org-babel-insert-result): Do not use %S format for
lists of strings in :results list output.  This is more consistent
with single string output.

Reported-by: Matt <matt@excalamus.com>
Link: 
1852d9eb52f.c4c534f9581400.7140516675874523594@excalamus.com">https://orgmode.org/list/1852d9eb52f.c4c534f9581400.7140516675874523594@excalamus.com
---
 lisp/ob-core.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index c2a367375..300c9d92f 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2461,13 +2461,18 @@ (defun org-babel-insert-result (result &optional 
result-params info hash lang ex
                    (insert
                     (org-trim
                      (org-list-to-org
+                       ;; We arbitrarily choose to format non-strings
+                       ;; as %S.
                       (cons 'unordered
                             (mapcar
                              (lambda (e)
                                 (cond
                                  ((stringp e) (list e))
                                  ((listp e)
-                                  (mapcar (lambda (x) (format "%S" x)) e))
+                                  (mapcar
+                                   (lambda (x)
+                                     (if (stringp x) x (format "%S" x)))
+                                   e))
                                  (t (list (format "%S" e)))))
                              (if (listp result) result
                                (split-string result "\n" t))))
-- 
2.38.1


-- 
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 via email to

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