From fd8196503247a4577a422475c6b8552b0ef4068e Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Tue, 17 Jan 2017 18:24:29 +0100 Subject: [PATCH] Don't require a shell when loading htmlfontify * lisp/htmlfontify.el (hfy-which-etags): Don't call a shell for detecting the etags version (Bug#25468). * test/lisp/htmlfontify-tests.el (htmlfontify-bug25468): Add unit test. --- lisp/htmlfontify.el | 12 +++++++++--- test/lisp/htmlfontify-tests.el | 12 ++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el index 21aac1ab21..74393ffbae 100644 --- a/lisp/htmlfontify.el +++ b/lisp/htmlfontify.el @@ -365,9 +365,15 @@ hfy-ignored-properties (defun hfy-which-etags () "Return a string indicating which flavor of etags we are using." - (let ((v (shell-command-to-string (concat hfy-etags-bin " --version")))) - (cond ((string-match "exube" v) "exuberant ctags") - ((string-match "GNU E" v) "emacs etags" )) )) + (with-temp-buffer + (condition-case nil + (when (eq (call-process hfy-etags-bin nil t nil "--version") 0) + (goto-char (point-min)) + (cond + ((looking-at-p "exube") "exuberant ctags") + ((looking-at-p "GNU E") "emacs etags"))) + ;; Return nil if the etags binary isn't executable (Bug#25468). + (file-error nil)))) (defcustom hfy-etags-cmd ;; We used to wrap this in a `eval-and-compile', but: diff --git a/test/lisp/htmlfontify-tests.el b/test/lisp/htmlfontify-tests.el index 15eb7c170c..4a1d566e96 100644 --- a/test/lisp/htmlfontify-tests.el +++ b/test/lisp/htmlfontify-tests.el @@ -30,5 +30,17 @@ (symbol-function 'htmlfontify-load-rgb-file)))) +(ert-deftest htmlfontify-bug25468 () + "Tests that htmlfontify can be loaded even if no shell is +available (Bug#25468)." + (should (equal (let ((process-environment + (cons "SHELL=/does/not/exist" process-environment))) + (call-process + (expand-file-name (invocation-name) (invocation-directory)) + nil nil nil + "--quick" "--batch" + (concat "--load=" (locate-library "htmlfontify")))) + 0))) + (provide 'htmlfontify-tests) ;; htmlfontify-tests.el ends here -- 2.11.0.483.g087da7b7c-goog