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

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

[elpa] externals/org f2141541b4: ob-core: Unify Org Babel related buffer


From: ELPA Syncer
Subject: [elpa] externals/org f2141541b4: ob-core: Unify Org Babel related buffer names using constant variable
Date: Tue, 16 Jul 2024 15:58:38 -0400 (EDT)

branch: externals/org
commit f2141541b45229a72fa4acfbf589267414c2f212
Author: stardiviner <numbchild@gmail.com>
Commit: Ihor Radchenko <yantar92@posteo.net>

    ob-core: Unify Org Babel related buffer names using constant variable
    
    * lisp/ob-core.el (org-babel-results-buffer-name): Define constant
    variable for buffer name.
    (org-babel-open-src-block-result): Use the
    `org-babel-results-buffer-name'.
    * lisp/ob-eval.el (org-babel-error-buffer-name): Add docstring.
    * testing/lisp/test-ob-octave.el (org-babel-error-buffer-name):
    (ob-octave/graphics-file):
    (ob-octave/graphics-file-session):
    (ob-octave/graphics-file-space):
    * testing/lisp/test-ob-shell.el (org-babel-error-buffer-name):
    (test-ob-shell/dont-error-on-babel-error):
    (test-ob-shell/standard-output-after-failure):
    (test-ob-shell/error-output-after-success):
    (test-ob-shell/error-output-after-failure):
    (test-ob-shell/error-output-after-failure-multiple):
    (test-ob-shell/exit-code):
    (test-ob-shell/exit-code-multiple): Use variable for buffer names.
---
 lisp/ob-core.el                |  5 ++++-
 lisp/ob-eval.el                |  3 ++-
 testing/lisp/test-ob-octave.el | 18 ++++++++++--------
 testing/lisp/test-ob-shell.el  | 14 +++++++-------
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index d4114c4c54..975df7784f 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1238,6 +1238,9 @@ evaluation mechanisms."
    (save-match-data (org-element-context))
    '(babel-call inline-babel-call inline-src-block src-block)))
 
+(defvar org-babel-results-buffer-name "*Org Babel Results*"
+  "The buffer name of Org Babel evaluate results.")
+
 ;;;###autoload
 (defun org-babel-open-src-block-result (&optional re-run)
   "Open results of source block at point.
@@ -1261,7 +1264,7 @@ exist."
        (if (looking-at org-link-bracket-re) (org-open-at-point)
         (let ((r (org-babel-format-result (org-babel-read-result)
                                           (cdr (assq :sep arguments)))))
-          (pop-to-buffer (get-buffer-create "*Org Babel Results*"))
+          (pop-to-buffer (get-buffer-create org-babel-results-buffer-name))
           (erase-buffer)
           (insert r)))
        t))
diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el
index 6467393871..3d6ee6ce6e 100644
--- a/lisp/ob-eval.el
+++ b/lisp/ob-eval.el
@@ -33,7 +33,8 @@
 
 (eval-when-compile (require 'subr-x))  ; For `string-empty-p', Emacs < 29
 
-(defvar org-babel-error-buffer-name "*Org-Babel Error Output*")
+(defvar org-babel-error-buffer-name "*Org-Babel Error Output*"
+  "The buffer name Org Babel evaluate error output.")
 (declare-function org-babel-temp-file "ob-core" (prefix &optional suffix))
 
 (defun org-babel-eval-error-notify (exit-code stderr)
diff --git a/testing/lisp/test-ob-octave.el b/testing/lisp/test-ob-octave.el
index 3c58fad741..e508380e4e 100644
--- a/testing/lisp/test-ob-octave.el
+++ b/testing/lisp/test-ob-octave.el
@@ -18,6 +18,8 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
+(require 'ob-core)
+
 (org-test-for-executable "octave")
 (unless (featurep 'ob-octave)
   (signal 'missing-test-dependency '("Support for Octave code blocks")))
@@ -67,8 +69,8 @@
 (ert-deftest ob-octave/graphics-file ()
   "Graphics file.  Test that link is correctly inserted and graphics file is 
created (and not empty).  Clean-up side-effects."
   ;; In case a prior test left the Error Output buffer hanging around.
-  (when (get-buffer "*Org-Babel Error Output*")
-    (kill-buffer "*Org-Babel Error Output*"))
+  (when (get-buffer org-babel-error-buffer-name)
+    (kill-buffer org-babel-error-buffer-name))
   (let ((file (make-temp-file "test-ob-octave-" nil ".png")))
     (unwind-protect
         (org-test-with-temp-text
@@ -81,8 +83,8 @@ sombrero;
           (should (file-readable-p file)))
       ;; clean-up
       (delete-file file)
-      (when (get-buffer "*Org-Babel Error Output*")
-        (kill-buffer "*Org-Babel Error Output*")))))
+      (when (get-buffer org-babel-error-buffer-name)
+        (kill-buffer org-babel-error-buffer-name)))))
 
 (ert-deftest ob-octave/graphics-file-session ()
   "Graphics file in a session.  Test that session is started in *Inferior 
Octave* buffer, link is correctly inserted and graphics file is created (and 
not empty).  Clean-up side-effects."
@@ -102,8 +104,8 @@ sombrero;
       (delete-file file)
       (let (kill-buffer-query-functions kill-buffer-hook)
         (kill-buffer "*Inferior Octave*"))
-      (when (get-buffer "*Org-Babel Error Output*")
-        (kill-buffer "*Org-Babel Error Output*")))))
+      (when (get-buffer org-babel-error-buffer-name)
+        (kill-buffer org-babel-error-buffer-name)))))
 
 (ert-deftest ob-octave/graphics-file-space ()
   "Graphics file with a space in filename.  Test that session is started in 
*Inferior Octave* buffer, link is correctly inserted and graphics file is 
created (and not empty).  Clean-up side-effects."
@@ -119,8 +121,8 @@ sombrero;
           (should (file-readable-p file)))
       ;; clean-up
       (delete-file file)
-      (when (get-buffer "*Org-Babel Error Output*")
-        (kill-buffer "*Org-Babel Error Output*")))))
+      (when (get-buffer org-babel-error-buffer-name)
+        (kill-buffer org-babel-error-buffer-name)))))
 
 (ert-deftest ob-octave/session-multiline ()
   "Test multiline session input."
diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el
index 273ec4fb88..e0ed5fd1e6 100644
--- a/testing/lisp/test-ob-shell.el
+++ b/testing/lisp/test-ob-shell.el
@@ -51,7 +51,7 @@ the body of the tangled block does."
 (ert-deftest test-ob-shell/dont-error-on-babel-error ()
   "Errors within Babel execution should not cause Lisp errors."
   (if (should (null (org-babel-execute:sh "ls NoSuchFileOrDirectory.txt" nil)))
-      (kill-buffer "*Org-Babel Error Output*")))
+      (kill-buffer org-babel-error-buffer-name)))
 
 (ert-deftest test-ob-shell/session-single-return-returns-string ()
   "Sessions with a single result should return a string."
@@ -429,7 +429,7 @@ echo 3
       (should (= 1
                  (org-babel-execute:sh
                   "echo 1; exit 2" nil)))
-      (kill-buffer "*Org-Babel Error Output*")))
+      (kill-buffer org-babel-error-buffer-name)))
 
 
 ;;; Standard error
@@ -446,7 +446,7 @@ the exit code, after exiting with a zero code."
                         "echo 1 >&2" nil)
                        (with-current-buffer org-babel-error-buffer-name
                          (buffer-string)))))
-      (kill-buffer "*Org-Babel Error Output*")))
+      (kill-buffer org-babel-error-buffer-name)))
 
 (ert-deftest test-ob-shell/error-output-after-failure ()
   "Test that standard error shows in the error buffer, alongside
@@ -460,7 +460,7 @@ the exit code, after exiting with a non-zero code."
                         "echo 1 >&2; exit 2" nil)
                        (with-current-buffer org-babel-error-buffer-name
                          (buffer-string)))))
-      (kill-buffer "*Org-Babel Error Output*")))
+      (kill-buffer org-babel-error-buffer-name)))
 
 (ert-deftest test-ob-shell/error-output-after-failure-multiple ()
   "Test that multiple standard error strings show in the error
@@ -478,7 +478,7 @@ buffer, alongside multiple exit codes."
                         "echo 3 >&2; exit 4" nil)
                        (with-current-buffer org-babel-error-buffer-name
                          (buffer-string)))))
-      (kill-buffer "*Org-Babel Error Output*")))
+      (kill-buffer org-babel-error-buffer-name)))
 
 
 ;;; Exit codes
@@ -494,7 +494,7 @@ with a non-zero return code."
                         "exit 1" nil)
                        (with-current-buffer org-babel-error-buffer-name
                          (buffer-string)))))
-      (kill-buffer "*Org-Babel Error Output*")))
+      (kill-buffer org-babel-error-buffer-name)))
 
 (ert-deftest test-ob-shell/exit-code-multiple ()
   "Test that multiple exit codes show in the error buffer after
@@ -510,7 +510,7 @@ exiting with a non-zero return code multiple times."
                         "exit 2" nil)
                        (with-current-buffer org-babel-error-buffer-name
                          (buffer-string)))))
-      (kill-buffer "*Org-Babel Error Output*")))
+      (kill-buffer org-babel-error-buffer-name)))
 
 (provide 'test-ob-shell)
 



reply via email to

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