emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org 89af7b11a4 2/3: org-sbe: Fix when the macro is expa


From: ELPA Syncer
Subject: [elpa] externals/org 89af7b11a4 2/3: org-sbe: Fix when the macro is expanded outside Org file
Date: Wed, 23 Nov 2022 08:01:43 -0500 (EST)

branch: externals/org
commit 89af7b11a4f7f91a1fa3233273f78d4abf485d6b
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    org-sbe: Fix when the macro is expanded outside Org file
    
    * lisp/ob-table.el (org-sbe): Do not try to execute code block during
    macro expansion.
    * testing/lisp/test-ob-table.el (test-ob-table/sbe): Uncomment the
    test.  Update the expected return value.
---
 lisp/ob-table.el              | 69 +++++++++++++++++++++----------------------
 testing/lisp/test-ob-table.el |  9 +++---
 2 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/lisp/ob-table.el b/lisp/ob-table.el
index 807d58298d..e14117cd3b 100644
--- a/lisp/ob-table.el
+++ b/lisp/ob-table.el
@@ -112,44 +112,43 @@ as shown in the example below.
               ;; ensure that all cells prefixed with $'s are strings
               (cons (car var)
                     (delq nil (mapcar
-                               (lambda (el)
-                                 (if (eq '$ el)
-                                     (prog1 nil (setq quote t))
-                                   (prog1
-                                       (cond
-                                        (quote (format "\"%s\"" el))
-                                        ((stringp el) (org-no-properties el))
-                                        (t el))
-                                     (setq quote nil))))
-                               (cdr var)))))
+                             (lambda (el)
+                               (if (eq '$ el)
+                                   (prog1 nil (setq quote t))
+                                 (prog1
+                                     (cond
+                                      (quote (format "\"%s\"" el))
+                                      ((stringp el) (org-no-properties el))
+                                      (t el))
+                                   (setq quote nil))))
+                             (cdr var)))))
             variables)))
       (unless (stringp source-block)
        (setq source-block (symbol-name source-block)))
-      (let ((result
-             (if (and source-block (> (length source-block) 0))
-                 (let ((params
-                        ;; FIXME: Why `eval'?!?!?
-                        (eval `(org-babel-parse-header-arguments
-                                (concat
-                                 ":var results="
-                                 ,source-block
-                                 "[" ,header-args "]"
-                                 "("
-                                 (mapconcat
-                                  (lambda (var-spec)
-                                    (if (> (length (cdr var-spec)) 1)
-                                        (format "%S='%S"
-                                                (car var-spec)
-                                                (mapcar #'read (cdr var-spec)))
-                                      (format "%S=%s"
-                                              (car var-spec) (cadr var-spec))))
-                                  ',variables ", ")
-                                 ")")))))
-                   (org-babel-execute-src-block
-                    nil (list "emacs-lisp" "results" params)
-                    '((:results . "silent"))))
-               "")))
-        (org-trim (if (stringp result) result (format "%S" result)))))))
+      `(let ((result
+              (if ,(and source-block (> (length source-block) 0))
+                  (let ((params
+                         ',(org-babel-parse-header-arguments
+                            (concat
+                             ":var results="
+                             source-block
+                             "[" header-args "]"
+                             "("
+                             (mapconcat
+                              (lambda (var-spec)
+                                (if (> (length (cdr var-spec)) 1)
+                                    (format "%S='%S"
+                                            (car var-spec)
+                                            (mapcar #'read (cdr var-spec)))
+                                  (format "%S=%s"
+                                          (car var-spec) (cadr var-spec))))
+                              variables ", ")
+                             ")"))))
+                    (org-babel-execute-src-block
+                     nil (list "emacs-lisp" "results" params)
+                     '((:results . "silent"))))
+                "")))
+         (org-trim (if (stringp result) result (format "%S" result)))))))
 
 (provide 'ob-table)
 
diff --git a/testing/lisp/test-ob-table.el b/testing/lisp/test-ob-table.el
index e83014f2e1..844127c2f7 100644
--- a/testing/lisp/test-ob-table.el
+++ b/testing/lisp/test-ob-table.el
@@ -24,11 +24,10 @@
 
 ;;; Code:
 
-;; TODO Test Broken (wrong-type-argument number-or-marker-p "2.0")
-;; (ert-deftest test-ob-table/sbe ()
-;;   "Test that `sbe' can be used to call code blocks from inside tables."
-;;   (org-test-at-id "6d2ff4ce-4489-4e2a-9c65-e3f71f77d975"
-;;     (should (= 2 (sbe take-sqrt (n "4"))))))
+(ert-deftest test-ob-table/sbe ()
+  "Test that `sbe' can be used to call code blocks from inside tables."
+  (org-test-at-id "6d2ff4ce-4489-4e2a-9c65-e3f71f77d975"
+    (should (equal "2.0" (org-sbe take-sqrt (n "4"))))))
 
 (provide 'test-ob-table)
 



reply via email to

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