Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icon refresh after create file #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions all-the-icons-dired.el
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,29 @@
(when all-the-icons-dired-mode
(all-the-icons-dired--refresh)))

(defvar all-the-icons-dired-advice-alist
'((dired-readin . all-the-icons-dired--refresh-advice)
(dired-revert . all-the-icons-dired--refresh-advice)
(dired-do-create-files . all-the-icons-dired--refresh-advice)
(dired-do-kill-lines . all-the-icons-dired--refresh-advice)
(dired-insert-subdir . all-the-icons-dired--refresh-advice)
(dired-create-directory . all-the-icons-dired--refresh-advice)
(dired-internal-do-deletions . all-the-icons-dired--refresh-advice)
(dired-narrow--internal . all-the-icons-dired--refresh-advice))
"Alist of advice and advice functions.")

(defun all-the-icons-dired--setup ()
"Setup `all-the-icons-dired'."
(when (derived-mode-p 'dired-mode)
(setq-local tab-width 1)
(advice-add 'dired-readin :around #'all-the-icons-dired--refresh-advice)
(advice-add 'dired-revert :around #'all-the-icons-dired--refresh-advice)
(advice-add 'dired-internal-do-deletions :around #'all-the-icons-dired--refresh-advice)
(advice-add 'dired-insert-subdir :around #'all-the-icons-dired--refresh-advice)
(advice-add 'dired-do-kill-lines :around #'all-the-icons-dired--refresh-advice)
(with-eval-after-load 'dired-narrow
(advice-add 'dired-narrow--internal :around #'all-the-icons-dired--refresh-advice))
(pcase-dolist (`(,sym . ,fn) all-the-icons-dired-advice-alist)
(advice-add sym :around fn))
(all-the-icons-dired--refresh)))

(defun all-the-icons-dired--teardown ()
"Functions used as advice when redisplaying buffer."
(advice-remove 'dired-readin #'all-the-icons-dired--refresh-advice)
(advice-remove 'dired-revert #'all-the-icons-dired--refresh-advice)
(advice-remove 'dired-internal-do-deletions #'all-the-icons-dired--refresh-advice)
(advice-remove 'dired-narrow--internal #'all-the-icons-dired--refresh-advice)
(advice-remove 'dired-insert-subdir #'all-the-icons-dired--refresh-advice)
(advice-remove 'dired-do-kill-lines #'all-the-icons-dired--refresh-advice)
(pcase-dolist (`(,sym . ,fn) all-the-icons-dired-advice-alist)
(advice-remove sym fn))
(all-the-icons-dired--remove-all-overlays))

;;;###autoload
Expand Down