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

    feat(subtree): add `dirvish-subtree-icon-scale-factor` option (#185)
    
    The dirvish-subtree-always-show-state now use t as default.
    
    Closes #185
---
 docs/EXTENSIONS.org           | 18 ++++++++++++------
 extensions/dirvish-subtree.el | 35 +++++++++++++++++++++++++----------
 2 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/docs/EXTENSIONS.org b/docs/EXTENSIONS.org
index 0440e1fcf5..7fa8825cf0 100644
--- a/docs/EXTENSIONS.org
+++ b/docs/EXTENSIONS.org
@@ -210,13 +210,19 @@ to any directory in the file system using results from 
=fd= command as completio
 
 * Turn Dirvish into a tree browser (dirvish-subtree.el)
 
-This extension gives Dirvish the ability to toggle a directory as subtree
-(~dirvish-subtree-toggle~), which can be seen as a stripped-down version of
-=dired-subtree=.
+This extension enhances Dirvish with the ~dirvish-subtree-toggle~ command, a
+streamlined alternative to =dired-subtree= for toggling a directory under the
+cursor as a subtree.
 
-You can use ~dirvish-subtree-toggle~ to toggle the directory under the cursor 
as a
-subtree.  Add ~subtree-state~ to ~dirvish-attributes~ gives you an indicator 
about
-whether the directory is expanded or not.
++ To visually indicate the expansion state of directories, add ~subtree-state~ 
to
+  ~dirvish-attributes~.
+
++ Customize the appearance of the expansion indicator using
+  ~dirvish-subtree-state-style~ and ~dirvish-subtree-icon-scale-factor~ to 
adjust
+  its displacement and size.
+
++ To hide the indicator when no directories are expanded, set
+  ~dirvish-subtree-always-show-state~ to nil.
 
 * History navigation (dirvish-history.el)
 
diff --git a/extensions/dirvish-subtree.el b/extensions/dirvish-subtree.el
index 116df758e8..81f7675c19 100644
--- a/extensions/dirvish-subtree.el
+++ b/extensions/dirvish-subtree.el
@@ -42,10 +42,17 @@ The prefix is repeated \"depth\" times."
          (if v (add-hook 'dirvish-after-revert-hook #'dirvish-subtree--revert)
            (remove-hook 'dirvish-after-revert-hook 
#'dirvish-subtree--revert))))
 
-(defcustom dirvish-subtree-always-show-state nil
-  "Non-nil means always show the subtree state indicator."
+(defcustom dirvish-subtree-always-show-state t
+  "Non-nil means show subtree state indicator even there is no subtrees."
   :type 'boolean :group 'dirvish)
 
+(defcustom dirvish-subtree-icon-scale-factor '(0.8 . 0.1)
+  "Scale factor for subtree state indicator.
+The value is a cons of \\='(HEIGHT . V-ADJUST) that used as values of
+:height and :v-adjust keyword respectively in `all-the-icons' and
+`nerd-icons'."
+  :type '(cons float float) :group 'dirvish)
+
 (defvar dirvish-subtree--state-icons nil)
 (defcustom dirvish-subtree-state-style 'chevron
   "Icon/string used for directory expanded state.
@@ -66,22 +73,30 @@ The value can be one of: `plus', `arrow', `chevron', 
`nerd'."
              (cons
               (nerd-icons-octicon
                "nf-oct-chevron_down"
-               :height (* (or (bound-and-true-p dirvish-nerd-icons-height) 1) 
0.8)
-               :v-adjust 0.1 :face 'dirvish-subtree-state)
+               :height (* (or (bound-and-true-p dirvish-nerd-icons-height) 1)
+                          (car dirvish-subtree-icon-scale-factor))
+               :v-adjust (cdr dirvish-subtree-icon-scale-factor)
+               :face 'dirvish-subtree-state)
               (nerd-icons-octicon
                "nf-oct-chevron_right"
-               :height (* (or (bound-and-true-p dirvish-nerd-icons-height) 1) 
0.8)
-               :v-adjust 0.1 :face 'dirvish-subtree-state)))
+               :height (* (or (bound-and-true-p dirvish-nerd-icons-height) 1)
+                          (car dirvish-subtree-icon-scale-factor))
+               :v-adjust (cdr dirvish-subtree-icon-scale-factor)
+               :face 'dirvish-subtree-state)))
             ('chevron
              (cons
               (all-the-icons-octicon
                "chevron-down"
-               :height (* (or (bound-and-true-p dirvish-all-the-icons-height) 
1) 0.8)
-               :v-adjust 0.1 :face 'dirvish-subtree-state)
+               :height (* (or (bound-and-true-p dirvish-all-the-icons-height) 
1)
+                          (car dirvish-subtree-icon-scale-factor))
+               :v-adjust (cdr dirvish-subtree-icon-scale-factor)
+               :face 'dirvish-subtree-state)
               (all-the-icons-octicon
                "chevron-right"
-               :height (* (or (bound-and-true-p dirvish-all-the-icons-height) 
1) 0.8)
-               :v-adjust 0.1 :face 'dirvish-subtree-state)))))))
+               :height (* (or (bound-and-true-p dirvish-all-the-icons-height) 
1)
+                          (car dirvish-subtree-icon-scale-factor))
+               :v-adjust (cdr dirvish-subtree-icon-scale-factor)
+               :face 'dirvish-subtree-state)))))))
 
 (defcustom dirvish-subtree-file-viewer #'dirvish-subtree-default-file-viewer
   "The function used to view a file node.

Reply via email to