branch: externals-release/org
commit 62587ef12e9c70862c79393cfd54292ff6b09619
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org-babel-execute:emacs-lisp: Do not rely upon undocumented return value of 
`pp'
    
    * lisp/ob-emacs-lisp.el (org-babel-execute:emacs-lisp): Use
    `pp-to-string' to get formatted code.  `pp' is for side effects and no
    longer returns anything on the latest Emacs master.
    * testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/results):
    New test.
    
    Reported-by: No Wayman <iarchivedmywholel...@gmail.com>
    Link: https://orgmode.org/list/87r04guyq9....@gmail.com
---
 lisp/ob-emacs-lisp.el              |  2 +-
 testing/lisp/test-ob-emacs-lisp.el | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el
index 7a1bde1509..372f160af4 100644
--- a/lisp/ob-emacs-lisp.el
+++ b/lisp/ob-emacs-lisp.el
@@ -77,7 +77,7 @@ by `org-edit-src-code'.")
                       (org-babel-expand-body:emacs-lisp body params)))
         (result (eval (read (if (or (member "code" result-params)
                                     (member "pp" result-params))
-                                (concat "(pp " body ")")
+                                (concat "(pp-to-string " body ")")
                               body))
                       (org-babel-emacs-lisp-lexical lexical))))
     (when (and session (not (equal session "none")))
diff --git a/testing/lisp/test-ob-emacs-lisp.el 
b/testing/lisp/test-ob-emacs-lisp.el
index d6b5e945c2..6661e59286 100644
--- a/testing/lisp/test-ob-emacs-lisp.el
+++ b/testing/lisp/test-ob-emacs-lisp.el
@@ -168,6 +168,18 @@ lexical-binding
 lexical-binding
 #+end_src")))))
 
+(ert-deftest ob-emacs-lisp/results ()
+  "Test results formatting."
+  (org-test-with-temp-text-in-file
+      "
+#+begin_src emacs-lisp :lexical t :results value code
+(list 1 2 3)
+#+end_src"
+    (org-babel-next-src-block)
+    (org-babel-execute-src-block)
+    (search-forward "#+end_src")
+    (should (search-forward "(1 2 3)"))))
+
 (provide 'test-ob-emacs-lisp)
 
  ;;; test-ob-emacs-lisp.el ends here

Reply via email to