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

    refactor: remove `dirvish-window-fringe` option
    
    Don't set window fringe except for vc-state attributes.
    On `dirvish-quit`, reset window fringe to default.
    
    Ref: https://github.com/hlissner/dirvish/issues/1
---
 dirvish.el               | 14 ++++----------
 extensions/dirvish-vc.el | 12 +++++-------
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/dirvish.el b/dirvish.el
index a32d988101..ecddc2e927 100644
--- a/dirvish.el
+++ b/dirvish.el
@@ -195,10 +195,6 @@ Works all the same as `dirvish-hide-details' but for 
cursor."
 Notice that it only take effects on the built-in `dired' preview dispatcher."
   :group 'dirvish :type 'boolean)
 
-(defcustom dirvish-window-fringe 1
-  "Window fringe for dirvish windows."
-  :group 'dirvish :type 'integer)
-
 (defconst dirvish-emacs-bin
   (cond
    ((and invocation-directory invocation-name)
@@ -550,7 +546,9 @@ ARGS is a list of keyword arguments for `dirvish' struct."
 (defun dirvish--clear-session (dv &optional from-quit)
   "Reset DV's slot and kill its buffers.
 FROM-QUIT is used to signify the calling command."
-  (let ((index (cdr (dv-index dv))))
+  (let ((index (cdr (dv-index dv)))
+        (fringe (dirvish-prop :fringe)))
+    (when fringe (set-window-fringes nil fringe) (dirvish-prop :fringe nil))
     (if (not (dv-curr-layout dv))
         (cl-loop for (_d . b) in (dv-roots dv)
                  when (and (not (get-buffer-window b))
@@ -1226,7 +1224,6 @@ LEVEL is the depth of current window."
     (when-let* ((fixed (dv-size-fixed dv))) (setq window-size-fixed fixed))
     (if (dv-curr-layout dv) (set-window-dedicated-p nil nil)
       (and (dv-dedicated dv) (set-window-dedicated-p nil t)))
-    (set-window-fringes nil dirvish-window-fringe dirvish-window-fringe)
     (while (and (< i depth) (not (string= current parent)))
       (cl-incf i)
       (push (cons current parent) parent-dirs)
@@ -1243,10 +1240,7 @@ LEVEL is the depth of current window."
                             (window-parameters . ((no-other-window . t))))
                for b = (dirvish--create-parent-buffer dv parent current level)
                for w = (display-buffer b `(dirvish--display-buffer . ,args)) do
-               (with-selected-window w
-                 (set-window-fringes
-                  nil dirvish-window-fringe dirvish-window-fringe)
-                 (set-window-dedicated-p w t))))))
+               (with-selected-window w (set-window-dedicated-p w t))))))
 
 (defun dirvish--init-util-buffers (dv)
   "Initialize util buffers for DV."
diff --git a/extensions/dirvish-vc.el b/extensions/dirvish-vc.el
index bdaed22be5..63bc90d648 100644
--- a/extensions/dirvish-vc.el
+++ b/extensions/dirvish-vc.el
@@ -22,10 +22,7 @@
   "Class for dirvish vc-* preview dispatchers.")
 
 (defcustom dirvish-vc-state-fringe 3
-  "The width of the fringe used to display the vc state indicator.
-It is recommended to make this value greater than
-`dirvish-window-fringe', which ensures that the `vc-state' attribute is
-displayed properly."
+  "The width of the fringe used to display the vc state indicator."
   :group 'dirvish :type 'integer)
 
 (defcustom dirvish-vc-state-face-alist
@@ -172,9 +169,10 @@ It is called when `:vc-backend' is included in 
DIRVISH-PROPs while
 (dirvish-define-attribute vc-state
   "The version control state at left fringe.
 This attribute only works on graphic displays."
-  ;; Avoid setting fringes constantly
-  (unless (= (car (window-fringes)) dirvish-vc-state-fringe)
-    (set-window-fringes nil dirvish-vc-state-fringe dirvish-window-fringe))
+  ;; Avoid setting fringes repeatedly
+  :when (prog1 t (unless (dirvish-prop :fringe)
+                   (dirvish-prop :fringe (car (window-fringes)))
+                   (set-window-fringes nil dirvish-vc-state-fringe)))
   (let ((ov (make-overlay l-beg l-beg)))
     (when-let* (((symbolp (dirvish-prop :vc-backend)))
                 (state (dirvish-attribute-cache f-name :vc-state))

Reply via email to