]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't require a shell when loading htmlfontify
authorPhilipp Stephani <phst@google.com>
Tue, 17 Jan 2017 17:24:29 +0000 (18:24 +0100)
committerPhilipp Stephani <phst@google.com>
Fri, 27 Jan 2017 17:37:58 +0000 (18:37 +0100)
* 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
test/lisp/htmlfontify-tests.el

index 21aac1ab21664371acef5e651066db051630bff4..74393ffbaeba7fbeba70b19746aef69729c865d6 100644 (file)
@@ -365,9 +365,15 @@ commands in `hfy-etags-cmd-alist'."
 
 (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:
index 15eb7c170c954b354e06e39d53ece5821789c6b6..4a1d566e96c698236424a8fc7f286966d580a50a 100644 (file)
     (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