From: Philipp Stephani <p.stephani2@gmail.com>
To: Glenn Morris <rgm@gnu.org>
Cc: 25468@debbugs.gnu.org
Subject: bug#25468: 26.0.50; Can't load htmlfontify if shell binary doesn't exist
Date: Tue, 17 Jan 2017 18:23:14 +0000 [thread overview]
Message-ID: <CAArVCkQhTSOgpTL3S8mdETtnQijP=kmq_3BwBL3gT-6JTZry=Q@mail.gmail.com> (raw)
In-Reply-To: <ifeg01fv4u.fsf@fencepost.gnu.org>
[-- Attachment #1.1: Type: text/plain, Size: 338 bytes --]
Glenn Morris <rgm@gnu.org> schrieb am Di., 17. Jan. 2017 um 18:34 Uhr:
>
> I don't see a need for hfy-which-etags to go via the shell at all,
> so a better change to me would be to use call-process instead of
> shell-command-to-string there. I see there's also hfy-shell-file-name
> for some reason.
>
Good point, here's another patch.
[-- Attachment #1.2: Type: text/html, Size: 718 bytes --]
[-- Attachment #2: 0001-Don-t-require-a-shell-when-loading-htmlfontify.txt --]
[-- Type: text/plain, Size: 2384 bytes --]
From fd8196503247a4577a422475c6b8552b0ef4068e Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
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
next prev parent reply other threads:[~2017-01-17 18:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-17 14:19 bug#25468: 26.0.50; Can't load htmlfontify if shell binary doesn't exist Philipp Stephani
2017-01-17 17:27 ` Philipp Stephani
2017-01-17 17:34 ` Glenn Morris
2017-01-17 18:23 ` Philipp Stephani [this message]
2017-01-24 16:43 ` Philipp Stephani
2017-01-27 17:59 ` Philipp Stephani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAArVCkQhTSOgpTL3S8mdETtnQijP=kmq_3BwBL3gT-6JTZry=Q@mail.gmail.com' \
--to=p.stephani2@gmail.com \
--cc=25468@debbugs.gnu.org \
--cc=rgm@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.