diff options
| author | Andreas Politz <politza@hochschule-trier.de> | 2015-04-10 10:16:20 +0200 |
|---|---|---|
| committer | Andreas Politz <politza@hochschule-trier.de> | 2015-04-10 10:16:20 +0200 |
| commit | 703fe6f28a01e59cd18ea6edfbe30315225d0cff (patch) | |
| tree | cea5851e385134326a5340e1d84b6591cc9f4618 /lisp | |
| parent | 3b83106d995fbc6acce89c6dc9b2dbba185712c1 (diff) | |
Improve feedback if epdfinfo is not in working.
* lisp/pdf-info.el (pdf-info-check-epdfinfo): New function: Send a
simple command and check for errors.
(pdf-info-process-assert-running): Use it.
* test/pdf-info.ert (pdf-info-check-epdfinfo): Test it.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/pdf-info.el | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lisp/pdf-info.el b/lisp/pdf-info.el index fd68515..5bd40fb 100644 --- a/lisp/pdf-info.el +++ b/lisp/pdf-info.el @@ -167,6 +167,29 @@ server, that it never ran.") (not (eq t pdf-info--queue)) (tq-process pdf-info--queue))) +(defun pdf-info-check-epdfinfo (&optional interactive-p) + (interactive "p") + (let ((executable pdf-info-epdfinfo-program)) + (unless (stringp executable) + (error "pdf-info-epdfinfo-program is unset or not a string")) + (unless (file-executable-p executable) + (error "pdf-info-epdfinfo-program is not executable")) + (let ((tempfile (make-temp-file "pdf-info-check-epdfinfo"))) + (unwind-protect + (with-temp-buffer + (with-temp-file tempfile + (insert "quit\n")) + (unless (= 0 (call-process + executable tempfile (current-buffer))) + (error "Error running `%s': %s" + pdf-info-epdfinfo-program + (buffer-string)))) + (when (file-exists-p tempfile) + (delete-file tempfile))))) + (when interactive-p + (message "The epdfinfo programm appears to be working.")) + nil) + (defun pdf-info-process-assert-running (&optional force) "Assert a running process. @@ -197,10 +220,7 @@ error." (when (eq pdf-info-restart-process-p 'ask) (setq pdf-info-restart-process-p nil)) (error "The epdfinfo server quit")) - (unless (and pdf-info-epdfinfo-program - (file-executable-p pdf-info-epdfinfo-program)) - (error "The variable pdf-info-epdfinfo-program is unset or not executable: %s" - pdf-info-epdfinfo-program)) + (pdf-info-check-epdfinfo) (let* ((process-connection-type) ;Avoid 4096 Byte bug #12440. (proc (start-process "epdfinfo" " *epdfinfo*" pdf-info-epdfinfo-program))) |
