Fix issues with dired-sidebar refresh

This commit is contained in:
Jeremy Dormitzer 2020-06-03 16:10:39 -04:00
parent 4d2b44c256
commit 970e14702c

View File

@ -4591,6 +4591,53 @@ Or Gnus can read RSS feeds directly:
(lambda ()
(unless (file-remote-p default-directory)
(auto-revert-mode))))
:config
(with-eval-after-load 'all-the-icons-dired
;; Display chevrons next to directories
(defun all-the-icons-icon-for-dir-with-chevron (dir &optional chevron padding initial-padding &rest arg-overrides)
"Format an icon for DIR with CHEVRON similar to tree based directories.
If PADDING is provided, it will prepend and separate the chevron
and directory with PADDING.
Produces different symbols by inspecting DIR to distinguish
symlinks and git repositories which do not depend on the
directory contents"
(let ((icon (apply 'all-the-icons-icon-for-dir dir arg-overrides))
(chevron (if chevron (all-the-icons-octicon (format "chevron-%s" chevron) :height 0.8 :v-adjust -0.1) ""))
(padding (or padding "\t")))
(format "%s%s%s%s%s" initial-padding chevron padding icon padding)))
(defun all-the-icons-dired--refresh ()
"Display the icons of files in a dired buffer."
(all-the-icons-dired--remove-all-overlays)
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(when (dired-move-to-filename nil)
(let ((file (dired-get-filename 'relative 'noerror)))
(when file
(let ((icon (if (file-directory-p file)
(all-the-icons-icon-for-dir-with-chevron file
(if (dired-subtree--is-expanded-p)
"down"
"right")
"\t"
""
:face 'all-the-icons-dired-dir-face
:v-adjust all-the-icons-dired-v-adjust)
(all-the-icons-icon-for-file file :v-adjust all-the-icons-dired-v-adjust))))
(if (member file '("." ".."))
(all-the-icons-dired--add-overlay (point) " \t")
(all-the-icons-dired--add-overlay
(point)
(concat (when (not (file-directory-p file))
" \t")
icon
"\t")))))))
(forward-line 1)))))
(add-to-list 'dired-sidebar-special-refresh-commands 'dired-kill-subdir)
:custom
(dired-sidebar-should-follow-file t)
(dired-sidebar-pop-to-sidebar-on-toggle-open nil)
@ -4601,7 +4648,9 @@ Or Gnus can read RSS feeds directly:
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons)
(use-package all-the-icons-dired
:hook ((dired-mode . all-the-icons-dired-mode)))
:hook ((dired-mode . (lambda ()
(unless (eq major-mode 'dired-sidebar-mode)
(all-the-icons-dired-mode))))))
#+END_SRC