From ac4f528a7797ffa2fcc0b46014ec15232bd8807e Mon Sep 17 00:00:00 2001 From: Clément Pit--Claudel Date: Thu, 19 May 2016 17:56:44 -0400 Subject: Fail silently if Coq's version can't be detected Rationale: if Coq isn't installed, we will detect it when trying to run it, and we don't need to duplicate the error logic. Additionally, change from using process-lines to using shell-command, possibly through file-name-handler. The reason for this change is that we want to do the version detection on the remote server if we're running in Tramp. --- coq/coq-system.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'coq/coq-system.el') diff --git a/coq/coq-system.el b/coq/coq-system.el index 2a803f36..8e0f9034 100644 --- a/coq/coq-system.el +++ b/coq/coq-system.el @@ -99,9 +99,20 @@ If it doesn't look right, try `coq-autodetect-version'." Interactively (with INTERACTIVE-P), show that number." (interactive '(t)) (setq coq-autodetected-version nil) - (let ((version-string (car (process-lines (or coq-prog-name "coqtop") "-v")))) - (when (and version-string (string-match "version \\([^ ]+\\)" version-string)) - (setq coq-autodetected-version (match-string 1 version-string)))) + (with-temp-buffer + ;; 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"))) + (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)) + (shell-command shell-command-str (current-buffer))))) + (when (equal 0 retv) + ;; Fail silently (in that case we'll just assume Coq 8.5) + (goto-char (point-min)) + (when (re-search-forward "version \\([^ ]+\\)" nil t) + (setq coq-autodetected-version (match-string 1)))))) (when interactive-p (coq-show-version)) coq-autodetected-version) -- cgit v1.2.3