Browse Source

babel: Wipe error buffer clean at start of execution

* lisp/ob-eval.el (org-babel-error-buffer-name): Define new variable.

  (org-babel-eval-error-notify): Use new variable `org-babel-error-buffer-name'
  (org-babel-eval): Make temp error buffer invisible to the user with
		    initial space in name.
  (org-babel-eval-wipe-error-buffer): New function to wipe the error message buffer.

* lisp/ob-exp.el (org-babel-eval-wipe-error-buffer): Declare external function
  `org-babel-eval-wipe-error-buffer'.
  (org-babel-exp-results): Wipe error buffer clean at outset of execution

* lisp/ob.el (org-babel-execute-src-block-maybe): Wipe error buffer clean at
  outset of execution
  (org-babel-eval-wipe-error-buffer): Declare external function
				    `org-babel-eval-wipe-error-buffer'.
Dan Davison 10 years ago
parent
commit
666e6ed5e7
3 changed files with 16 additions and 4 deletions
  1. 11 2
      lisp/ob-eval.el
  2. 2 1
      lisp/ob-exp.el
  3. 3 1
      lisp/ob.el

+ 11 - 2
lisp/ob-eval.el

@@ -31,9 +31,11 @@
 (require 'ob)
 (eval-when-compile (require 'cl))
 
+(defvar org-babel-error-buffer-name "*Org-Babel Error Output*")
+
 (defun org-babel-eval-error-notify (exit-code stderr)
   "Open a buffer to display STDERR and a message with the value of EXIT-CODE."
-  (let ((buf (get-buffer-create "*Org-Babel Error Output*")))
+  (let ((buf (get-buffer-create org-babel-error-buffer-name)))
     (with-current-buffer buf
       (goto-char (point-max))
       (save-excursion (insert stderr)))
@@ -44,7 +46,7 @@
   "Run CMD on BODY.
 If CMD succeeds then return its results, otherwise display
 STDERR with `org-babel-eval-error-notify'."
-  (let ((err-buff (get-buffer-create "*Org-Babel Error*")) exit-code)
+  (let ((err-buff (get-buffer-create " *Org-Babel Error*")) exit-code)
     (with-current-buffer err-buff (erase-buffer))
     (with-temp-buffer
       (insert body)
@@ -247,6 +249,13 @@ specifies the value of ERROR-BUFFER."
       (delete-file error-file))
     exit-status))
 
+
+(defun org-babel-eval-wipe-error-buffer ()
+  (when (get-buffer org-babel-error-buffer-name)
+    (save-excursion
+     (set-buffer org-babel-error-buffer-name)
+     (delete-region (point-min) (point-max)))))
+
 (provide 'ob-eval)
 
 ;; arch-tag: 5328b17f-957d-42d9-94da-a2952682d04d

+ 2 - 1
lisp/ob-exp.el

@@ -39,7 +39,7 @@
 (defvar org-babel-lob-one-liner-regexp)
 (defvar org-babel-ref-split-regexp)
 (declare-function org-babel-lob-get-info "ob-lob" ())
-
+(declare-function org-babel-eval-wipe-error-buffer "ob-eval" ())
 (add-to-list 'org-export-interblocks '(src org-babel-exp-inline-src-blocks))
 (add-to-list 'org-export-interblocks '(lob org-babel-exp-lob-one-liners))
 (add-hook 'org-export-blocks-postblock-hook 'org-exp-res/src-name-cleanup)
@@ -288,6 +288,7 @@ inhibit insertion of results into the buffer."
 			   (org-babel-process-params (nth 2 info))))
        ;; skip code blocks which we can't evaluate
        (when (fboundp (intern (concat "org-babel-execute:" lang)))
+	 (org-babel-eval-wipe-error-buffer)
 	 (if (equal type 'inline)
 	     (let ((raw (org-babel-execute-src-block
 			 nil info '((:results . "silent"))))

+ 3 - 1
lisp/ob.el

@@ -78,6 +78,7 @@
 (declare-function org-list-to-generic "org-list" (LIST PARAMS))
 (declare-function org-list-bottom-point "org-list" ())
 
+(declare-function org-babel-eval-wipe-error-buffer "ob-eval" ())
 (defgroup org-babel nil
   "Code block evaluation and management in `org-mode' documents."
   :tag "Babel"
@@ -242,7 +243,8 @@ then run `org-babel-execute-src-block'."
   (interactive)
   (let ((info (org-babel-get-src-block-info)))
     (if info
-	(progn (org-babel-execute-src-block current-prefix-arg info) t) nil)))
+	(progn (org-babel-eval-wipe-error-buffer)
+	       (org-babel-execute-src-block current-prefix-arg info) t) nil)))
 
 ;;;###autoload
 (defun org-babel-expand-src-block-maybe ()