Kyle Meyer 4 лет назад
Родитель
Сommit
c1fa5ea76f
3 измененных файлов с 28 добавлено и 3 удалено
  1. 5 2
      lisp/ob-exp.el
  2. 15 1
      lisp/org.el
  3. 8 0
      testing/lisp/test-ob-exp.el

+ 5 - 2
lisp/ob-exp.el

@@ -216,8 +216,11 @@ this template."
 			     (delete-region begin end)
 			     (insert replacement)))))
 		      ((or `babel-call `inline-babel-call)
-		       (org-babel-exp-do-export (org-babel-lob-get-info element)
-						'lob)
+                       (org-babel-exp-do-export
+                        (or (org-babel-lob-get-info element)
+                            (user-error "Unknown Babel reference: %s"
+                                        (org-element-property :call element)))
+                        'lob)
 		       (let ((rep
 			      (org-fill-template
 			       org-babel-exp-call-line-template

+ 15 - 1
lisp/org.el

@@ -8768,7 +8768,21 @@ If the file does not exist, throw an error."
 
       (save-window-excursion
 	(message "Running %s...done" cmd)
-	(start-process-shell-command cmd nil cmd)
+        ;; Handlers such as "gio open" and kde-open5 start viewer in background
+        ;; and exit immediately.  Avoid `start-process' since it assumes
+        ;; :connection-type 'pty and kills children processes with SIGHUP
+        ;; when temporary terminal session is finished.
+        (make-process
+         :name "org-open-file" :connection-type 'pipe :noquery t
+         :buffer nil ; use "*Messages*" for debugging
+         :sentinel (lambda (proc event)
+                     (when (and (memq (process-status proc) '(exit signal))
+                                (/= (process-exit-status proc) 0))
+                       (message
+                        "Command %s: %s."
+                        (mapconcat #'identity (process-command proc) " ")
+                        (substring event 0 -1))))
+         :command (list shell-file-name shell-command-switch cmd))
 	(and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))))
      ((or (stringp cmd)
 	  (eq cmd 'emacs))

+ 8 - 0
testing/lisp/test-ob-exp.el

@@ -585,6 +585,14 @@ src_emacs-lisp{(+ 1 1)}"
 	      (org-babel-exp-process-buffer))
 	    (buffer-string)))))
 
+(ert-deftest ob-exp/unknown-call-reference ()
+  "Test exporting with a call that references an unknown name."
+  (should-error
+   (org-test-with-temp-text
+       "call_foo()"
+     (let ((org-export-use-babel t))
+       (org-babel-exp-process-buffer)))
+   :type 'user-error))
 
 (provide 'test-ob-exp)