branch: elpa/dirvish
commit e819ca8b9c5732d46ab04429d0ac7f1b4f4a4394
Author: Alex Lu <hellosimon1...@hotmail.com>
Commit: Alex Lu <hellosimon1...@hotmail.com>

    fix: make `:vc-backend` a number or a non-nil symbol
---
 dirvish-extras.el        |  4 ++--
 dirvish.el               |  8 +-------
 extensions/dirvish-vc.el | 12 +++++++-----
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/dirvish-extras.el b/dirvish-extras.el
index 7558ecb922..90243bc294 100644
--- a/dirvish-extras.el
+++ b/dirvish-extras.el
@@ -93,9 +93,9 @@ RECIPE has the same form as `dirvish-default-layout'."
     ("c"  collapse      "Collapse unique nested paths"
      (not (dirvish-prop :remote)))
     ("v"  vc-state      "Version control state"
-     (and (display-graphic-p) (dirvish-prop :vc-backend)))
+     (and (display-graphic-p) (symbolp (dirvish-prop :vc-backend))))
     ("m"  git-msg       "Git commit messages"
-     (and (dirvish-prop :vc-backend) (not (dirvish-prop :remote))))
+     (and (symbolp (dirvish-prop :vc-backend)) (not (dirvish-prop :remote))))
     ("1" '(0 nil  0.4)  "     -       | current (60%) | preview (40%)")
     ("2" '(0 nil  0.8)  "     -       | current (20%) | preview (80%)")
     ("3" '(1 0.08 0.8)  "parent (8%)  | current (12%) | preview (80%)")
diff --git a/dirvish.el b/dirvish.el
index 700e70a0e0..1d8c3bfc4d 100644
--- a/dirvish.el
+++ b/dirvish.el
@@ -1233,19 +1233,13 @@ INHIBIT-SETUP is passed to `dirvish-data-for-dir'."
        (when (buffer-live-p buf)
          (with-current-buffer buf
            (maphash (lambda (k v) (puthash k v dirvish--attrs-hash)) data)
-           (dirvish-prop :vc-backend vc)
+           (dirvish-prop :vc-backend (or vc 0)) ; for &context compat
            (dirvish-data-for-dir dir buf inhibit-setup))))
      (delete-process p)
      (dirvish--kill-buffer (process-buffer p)))
    nil 'meta (cons buffer inhibit-setup)))
 
 (cl-defgeneric dirvish-data-for-dir (dir buffer inhibit-setup)
-  "Fetch data for DIR in BUFFER, maybe INHIBIT-SETUP.")
-
-(cl-defmethod dirvish-data-for-dir
-  (dir buffer inhibit-setup
-       &context ((dirvish-prop :vc-backend) boolean)
-       &context ((dirvish-prop :remote) boolean))
   "Fetch data for DIR in BUFFER.
 It is called when neither `:vc-backend' nor `:remote' is included in
 DIRVISH-PROPs, i.e. DIR is in localhost and is not being
diff --git a/extensions/dirvish-vc.el b/extensions/dirvish-vc.el
index ea9781d2a1..84bd7dea88 100644
--- a/extensions/dirvish-vc.el
+++ b/extensions/dirvish-vc.el
@@ -175,7 +175,7 @@ This attribute only works on graphic displays."
   (unless (= (car (window-fringes)) dirvish-vc-state-fringe)
     (set-window-fringes nil dirvish-vc-state-fringe dirvish-window-fringe))
   (let ((ov (make-overlay l-beg l-beg)))
-    (when-let* (((dirvish-prop :vc-backend))
+    (when-let* (((symbolp (dirvish-prop :vc-backend)))
                 (state (dirvish-attribute-cache f-name :vc-state))
                 (face (alist-get state dirvish-vc-state-face-alist))
                 (display `(left-fringe dirvish-vc-gutter . ,(cons face nil))))
@@ -196,7 +196,7 @@ This attribute only works on graphic displays."
 
 (dirvish-define-preview vc-diff (ext)
   "Use output of `vc-diff' as preview."
-  (when (and (dirvish-prop :vc-backend)
+  (when (and (symbolp (dirvish-prop :vc-backend))
              (not (member ext dirvish-media-exts))
              (cl-letf (((symbol-function 'pop-to-buffer) #'ignore)
                        ((symbol-function 'message) #'ignore))
@@ -205,7 +205,7 @@ This attribute only works on graphic displays."
 
 (dirvish-define-preview vc-log ()
   "Use output of `vc-print-log' as preview."
-  (when (and (dirvish-prop :vc-backend)
+  (when (and (symbolp (dirvish-prop :vc-backend))
              (cl-letf (((symbol-function 'pop-to-buffer) #'ignore))
                (prog1 t (vc-print-log))))
     '(buffer . "*vc-change-log*")))
@@ -213,6 +213,7 @@ This attribute only works on graphic displays."
 (dirvish-define-preview vc-blame (file ext preview-window dv)
   "Use output of `vc-annotate' (file) or `vc-dir' (dir) as preview."
   (when-let* ((bk (dirvish-prop :vc-backend))
+              ((symbolp bk))
               (orig-buflist (buffer-list))
               (display-buffer-alist
                '(("\\*\\(Annotate \\|vc-dir\\).*\\*"
@@ -241,6 +242,7 @@ This attribute only works on graphic displays."
   "Version control info such as git branch."
   (when-let* (((> (window-width) 30))
               (bk (dirvish-prop :vc-backend))
+              ((symbolp bk))
               (ml-str (vc-call-backend bk 'mode-line-string default-directory))
               (bk-str (format "%s:" bk)))
     (format " %s %s "
@@ -257,9 +259,9 @@ This attribute only works on graphic displays."
   [:description
    (lambda () (dirvish--format-menu-heading "Version control commands"))
    ("v" dirvish-vc-preview-ifx
-    :if (lambda () (dirvish-prop :vc-backend)))
+    :if (lambda () (symbolp (dirvish-prop :vc-backend))))
    ("n" "Do the next action" dired-vc-next-action
-    :if (lambda () (dirvish-prop :vc-backend)))
+    :if (lambda () (symbolp (dirvish-prop :vc-backend))))
    ("c" "Create repo" vc-create-repo)])
 
 (provide 'dirvish-vc)

Reply via email to