aboutsummaryrefslogtreecommitdiffhomepage
path: root/coq/coq-system.el
diff options
context:
space:
mode:
authorGravatar Hendrik Tews <hendrik@askra.de>2016-12-15 09:39:00 +0100
committerGravatar Hendrik Tews <hendrik@askra.de>2016-12-15 09:39:00 +0100
commitb0553954a4324efd873f7caae85f0ebc0665883c (patch)
treea9e66d5de552d516740270928930fc6aee6ccf32 /coq/coq-system.el
parent93a0d1ca16fd30e89e312932008106bc5503386f (diff)
die gracefully when visiting files in nonexisting directories
Diffstat (limited to 'coq/coq-system.el')
-rw-r--r--coq/coq-system.el16
1 files changed, 11 insertions, 5 deletions
diff --git a/coq/coq-system.el b/coq/coq-system.el
index 48757be5..88ce06be 100644
--- a/coq/coq-system.el
+++ b/coq/coq-system.el
@@ -57,10 +57,12 @@ See also `coq-prog-env' to adjust the environment."
:group 'coq)
(defun get-coq-library-directory ()
- (let ((c (substring (shell-command-to-string (concat coq-prog-name " -where")) 0 -1 )))
- (if (string-match "not found" c)
- "/usr/local/lib/coq"
- c)))
+ (let ((default-directory
+ (if (file-accessible-directory-p default-directory)
+ default-directory
+ "/")))
+ (or (ignore-errors (car (process-lines coq-prog-name "-where")))
+ "/usr/local/lib/coq")))
(defconst coq-library-directory (get-coq-library-directory) ;; FIXME Should be refreshed more often
"The coq library directory, as reported by \"coqtop -where\".")
@@ -123,7 +125,11 @@ Interactively (with INTERACTIVE-P), show that number."
;; Use `shell-command' via `find-file-name-handler' instead of
;; `process-line': when the buffer is running TRAMP, PG uses
;; `start-file-process', loading the binary from the remote server.
- (let* ((coq-command (shell-quote-argument (or coq-prog-name "coqtop")))
+ (let* ((default-directory
+ (if (file-accessible-directory-p default-directory)
+ default-directory
+ "/"))
+ (coq-command (shell-quote-argument (or coq-prog-name "coqtop")))
(shell-command-str (format "%s -v" coq-command))
(fh (find-file-name-handler default-directory 'shell-command))
(retv (if fh (funcall fh 'shell-command shell-command-str (current-buffer))