branch: elpa/dirvish
commit 1b905092f67483bce8db4901227df15e6c548dce
Author: Alex Lu <[email protected]>
Commit: Alex Lu <[email protected]>
fix: drop usages of `featurep`
It's not reliable to check if a package is loaded using `featurep`.
---
dirvish-widgets.el | 9 +++++++--
dirvish.el | 7 ++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dirvish-widgets.el b/dirvish-widgets.el
index 8ddfb09540..1470f7ca27 100644
--- a/dirvish-widgets.el
+++ b/dirvish-widgets.el
@@ -616,8 +616,10 @@ Require: `epub-thumbnailer' (executable)"
"Preview pdf files.
Require: `pdf-tools' (Emacs package)"
(when (equal ext "pdf")
- (if (featurep 'pdf-tools) (dirvish--find-file-temporarily file)
- '(info . "Emacs package 'pdf-tools' is required to preview pdf
documents"))))
+ (if (and (require 'pdf-tools nil t)
+ (file-exists-p pdf-info-epdfinfo-program))
+ (dirvish--find-file-temporarily file)
+ '(info . "`epdfinfo' program required to preview pdfs; run `M-x
pdf-tools-install'"))))
(dirvish-define-preview pdf-preface (file ext preview-window)
"Display the preface image as preview for pdf files."
@@ -637,6 +639,9 @@ Require: `zipinfo' (executable)
Require: `tar' (executable)"
:require ("zipinfo" "tar")
(cond ((equal ext "zip") `(shell . ("zipinfo" ,file)))
+ ;; Emacs source code files
+ ((string-suffix-p ".el.gz" file)
+ (dirvish--find-file-temporarily file))
((member ext '("tar" "zst" "bz2" "bz" "gz" "xz" "tgz"))
`(shell . ("tar" "-tvf" ,file)))))
diff --git a/dirvish.el b/dirvish.el
index b2ca5bae1a..9a88decd68 100644
--- a/dirvish.el
+++ b/dirvish.el
@@ -1205,8 +1205,7 @@ LEVEL is the depth of current window."
"Script for DIR data retrieving."
`(with-temp-buffer
(let ((hash (make-hash-table))
- (bk ,(and (featurep 'dirvish-vc)
- `(ignore-errors (vc-responsible-backend ,dir)))))
+ (bk (ignore-errors (vc-responsible-backend ,dir))))
;; keep this until `vc-git' fixed upstream. See: #224 and #273
(advice-add #'vc-git--git-status-to-vc-state :around
(lambda (fn code-list)
@@ -1214,7 +1213,9 @@ LEVEL is the depth of current window."
(dolist (file (directory-files ,dir t nil t))
(let* ((attrs (file-attributes file))
(state (and bk (vc-state-refresh file bk)))
- (git (and (eq bk 'Git) ; TODO: refactor this
+ ;; TODO: eventually this should belong to `dirvish-vc'
+ ;; we spawn a separate process to deal with git stuff.
+ (git (and (eq bk 'Git)
(shell-command-to-string
(format "git log -1 --pretty=%%s %s"
(shell-quote-argument file)))))