Subject: bug#25468: 26.0.50; Can't load htmlfontify if shell binary doesn't exist

From: Philipp Stephani <[email-masked]>
Date: Tue, 17 Jan 2017 17:27:27 +0000

Philipp Stephani <[email-masked]> schrieb am Di., 17. Jan. 2017 um
15:21 Uhr:

>
> $ SHELL=/doesnotexist src/emacs -Q -batch -l htmlfontify ; echo $?
> Searching for program: No such file or directory, /doesnotexist
> 255
>
> This is of course a rather rare edge case, but I think that
> unavailability of a shell shouldn't prevent htmlfontify from loading.
> The shell is only used to initialize hfy-etags-cmd, this variable could
> simply be initialized to nil if no shell is found, similar to when no
> etags binary is found.
>

I've attached a patch.
From a9337090f19a25e1e92de8e6b8a9aedbb720b931 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <[email-masked]>
Date: Tue, 17 Jan 2017 18:24:29 +0100
Subject: [PATCH] Don't error when loading htmlfontify without shell

* lisp/htmlfontify.el (hfy-etags-cmd): Don't raise an error if no
shell is available (Bug#25468).
* test/lisp/htmlfontify-tests.el (htmlfontify-bug25468): Add unit
test.
---
 lisp/htmlfontify.el            |  6 +++++-
 test/lisp/htmlfontify-tests.el | 12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el
index 21aac1ab21..b15aa39f10 100644
--- a/lisp/htmlfontify.el
+++ b/lisp/htmlfontify.el
@@ -376,7 +376,11 @@ hfy-etags-cmd
   ;; - it signals an error (`hfy-which-etags' is not defined at compile-time).
   ;; - we want this auto-detection to reflect the system on which Emacs is run
   ;;   rather than the one on which it's compiled.
-  (cdr (assoc (hfy-which-etags) hfy-etags-cmd-alist))
+  ;; If no shell is available, loading this file would error, therefore
+  ;; demote errors to warnings (Bug#25468).
+  (cdr (assoc (with-demoted-errors "Error detecting location of etags: %S"
+                (hfy-which-etags))
+              hfy-etags-cmd-alist))
   "The etags equivalent command to run in a source directory to generate a tags
 file for the whole source tree from there on down.  The command should emit
 the etags output on stdout.\n
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