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

Support dired-subtree (No icons showed in dired-subtree) #3

Open
milanglacier opened this issue Apr 22, 2023 · 2 comments
Open

Support dired-subtree (No icons showed in dired-subtree) #3

milanglacier opened this issue Apr 22, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@milanglacier
Copy link

example setup

(require 'package)
(setq package-user-dir "~/Downloads/emacs-package-dir")

(setq package-list '(dired-subtree))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

(add-to-list 'load-path "~/Downloads/open-project-fork/nerd-icons.el")
(add-to-list 'load-path "~/Downloads/open-project-fork/nerd-icons-dired")

(unless package-archive-contents
  (package-refresh-contents))

(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

(require 'nerd-icons)
(require 'nerd-icons-dired)
(require 'dired-subtree)

(add-hook 'dired-mode-hook #'nerd-icons-dired-mode)

(define-key dired-mode-map (kbd "TAB") #'dired-subtree-toggle)

(load-theme 'modus-operandi t)

step to reproduce:

  1. open any directory by C-x d
  2. move point to a folder and tap TAB key, the subtree is expanded.
  3. No icons showed in the subtree.

Screen Shot 2023-04-21 at 21 23 20

@rainstormstudio rainstormstudio added the enhancement New feature or request label Apr 22, 2023
@rainstormstudio rainstormstudio changed the title No icons showed in dired-subtree Support dired-subtree (No icons showed in dired-subtree) Apr 22, 2023
@zhenhua-wang
Copy link

This should add icons to the dired subtrees

  (advice-add 'dired-subtree-toggle :after (lambda ()
                                             (interactive)
                                             (when nerd-icons-dired-mode
                                               (revert-buffer))))

@milanglacier
Copy link
Author

milanglacier commented Aug 6, 2023

This should add icons to the dired subtrees

  (advice-add 'dired-subtree-toggle :after (lambda ()
                                             (interactive)
                                             (when nerd-icons-dired-mode
                                               (revert-buffer))))

Thanks for the insight! This hack works for me!

Using a anonymous function in an advice makes it hard to be removed later, I have made a slightly modification of this piece of code to make it less intrusive:

(defun my:dired-subtree-add-nerd-icons ()
    (interactive)
    (revert-buffer))


(defun my:dired-subtree-toggle-nerd-icons ()
    (when (require 'dired-subtree nil t)
        (if nerd-icons-dired-mode
                (advice-add #'dired-subtree-toggle :after #'my:dired-subtree-add-nerd-icons)
            (advice-remove #'dired-subtree-toggle #'my:dired-subtree-add-nerd-icons))))

(use-package nerd-icons-dired
    :hook ((dired-mode . nerd-icons-dired-mode)
           (nerd-icons-dired-mode . my:dired-subtree-toggle-nerd-icons)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants