Browse Source

Babel no longer throws error when inserting an empty result

  Thanks to Sébastien Vauban for pointing this out

* lisp/ob.el (org-babel-insert-result): no longer throws error when
  inserting an empty result
Eric Schulte 14 years ago
parent
commit
8ca802166b
1 changed files with 4 additions and 1 deletions
  1. 4 1
      lisp/ob.el

+ 4 - 1
lisp/ob.el

@@ -1293,6 +1293,7 @@ code ---- the results are extracted in the syntax of the source
 	(message (replace-regexp-in-string "%" "%%" (format "%S" result)))
 	result)
     (when (and (stringp result) ;; ensure results end in a newline
+	       (> (length result) 0)
 	       (not (or (string-equal (substring result -1) "\n")
 			(string-equal (substring result -1) "\r"))))
       (setq result (concat result "\n")))
@@ -1320,6 +1321,8 @@ code ---- the results are extracted in the syntax of the source
 	(setq results-switches
 	      (if results-switches (concat " " results-switches) ""))
 	(cond
+	 ;; do nothing for an empty result
+	 ((= (length result) 0))
 	 ;; assume the result is a table if it's not a string
 	 ((not (stringp result))
 	  (insert (concat (orgtbl-to-orgtbl
@@ -1412,7 +1415,7 @@ file's directory then expand relative links."
   (let ((size (count-lines beg end)))
     (save-excursion
       (cond ((= size 0)
-	     (error (concat "This should be impossible:"
+	     (error (concat "This should not be impossible:"
                             "a newline was appended to result if missing")))
 	    ((< size org-babel-min-lines-for-block-output)
 	     (goto-char beg)