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

nil icon name when dashboard-set-heading-icons turned on #459

Open
sunng87 opened this issue May 8, 2023 · 23 comments
Open

nil icon name when dashboard-set-heading-icons turned on #459

sunng87 opened this issue May 8, 2023 · 23 comments

Comments

@sunng87
Copy link

sunng87 commented May 8, 2023

When dashboard-set-heading-icons turned on, I'm getting error: unable to find icon with name nil in icon set with both nerd-icons and all-the-icons. Not sure if it's because additional headings in dashboard-widgets like ls-directory.

@jcs090218
Copy link
Member

jcs090218 commented May 8, 2023

What's the value of your variable dashboard-icon-type? It should either be 'all-the-icons or 'nerd-icons.

@sunng87
Copy link
Author

sunng87 commented May 9, 2023

I've tested with both all-the-icons and nerd-icons, the error persists until I turned off heading icons and keeps only file icons. So I believe it has something to do with heading icon set.

@mikaelspringer
Copy link

I experience the same thing. When I set dashboard-set-heading-icons to t, I get the error message and no icons are shown in *dashboard*. When I set dashboard-set-heading-icons to nil, the error message disappear and icons are shown again in dashboard.

One other strange thing is that when I do M-x customize-group dashboard a lot of the icon related variables are marked CHANGED outside Customize. (mismatch). I know for sure I haven't changed them.

@jcs090218
Copy link
Member

What's the value of variable dashboard-heading-icons? It seems like it's nil and it shouldn't be. 🤔

It could be an issue regarding the order you load this package, it should be something similar to:

(setq dashboard-set-heading-icons t)
(require 'dashboard)  ; it will auto configure it for you

or set them all manually:

(require 'dashboard)
(setq dashboard-set-heading-icons t)
(setq dashboard-icon-type 'all-the-icons)
(setq dashboard-heading-icons '((recents   . "history")
                                (bookmarks . "bookmark")
                                (agenda    . "calendar")
                                (projects  . "rocket")
                                (registers . "database")))

@sunng87
Copy link
Author

sunng87 commented May 9, 2023

After checking customize-variable, I found dashboard-heading-icons is set to nil.

@knaveightt
Copy link

Hello everyone - will also raise that I am experiencing the same issue. After reviewing this thread, I also tried to set the icons manually as well, but to no avail. Here is the exact config I am using, utilizing use-package for reference. Willing to try alternative approaches based on feedback:

  (use-package dashboard
    :config
    (dashboard-setup-startup-hook)
    (setq dashboard-items '((recents  . 5)
			    (bookmarks . 5)
			    (projects . 5)
			    (agenda . 5)
			    (registers . 5)))
    (setq dashboard-set-heading-icons t)
    (setq dashboard-icon-type 'all-the-icons)
    (setq dashboard-heading-icons '((recents   . "history")
                                    (bookmarks . "bookmark")
                                    (agenda    . "calendar")
                                    (projects  . "rocket")
                                    (registers . "database"))))  

@jcs090218
Copy link
Member

Hi, @knaveightt! What kind of error did you get? It seems like you configure the package correctly. 🤔

@knaveightt
Copy link

Hi @jcs090218 ! Before setting the dashboard-heading-icons manually, I was also receiving the unable to find icon with name nil in icon set error that @sunng87 received too. Once setting the dashboard-heading-icons manually, I no longer received the error message, but still no icons showed in the dashboard :(
screenshot

@jcs090218
Copy link
Member

The insertion logic is here:

(when (and (dashboard-display-icons-p) dashboard-set-heading-icons)

Do your environment support icons? Are you using a terminal? 🤔

@ricardoricho
Copy link
Contributor

Hi @knaveightt your config looks good, I checked the code and there are some evaluations at loading time (maybe we have to fix that).
Moving the setting of icons variables to the init could fix the problem.

  (use-package dashboard
    :config
    (dashboard-setup-startup-hook)
    :init
    (setq dashboard-items '((recents  . 5)
			    (bookmarks . 5)
			    (projects . 5)
			    (agenda . 5)
			    (registers . 5)))
    (setq dashboard-set-heading-icons t)
    (setq dashboard-set-file-icons t)
    (setq dashboard-icon-type 'all-the-icons)
    (setq dashboard-heading-icons '((recents   . "history")
                                    (bookmarks . "bookmark")
                                    (agenda    . "calendar")
                                    (projects  . "rocket")
                                    (registers . "database"))))  

Please, let me know if that works. Maybe you have to add (require 'all-the-icons) or with (use-package all-the-icons :demand t)

@knaveightt
Copy link

Hi @jcs090218 and @ricardoricho,

Almost got there, I think! For reference, I am on a Windows 10 machine that (should) support icons, I am able to manually place them using various all-the-icons functions.

With the above suggestion of moving many of the setq commands to :init (and setting :demand for all-the-icons), I am now seeing the 'circle' icons for Agenda items. However I am still not seeing icons for the dashboard headers:

Screenshot-Emacs-Dashboard

@xenobis
Copy link

xenobis commented Jul 2, 2023

Hi all,

if you still have problems displaying icons for headers and files, etc., please have a look at my pull request #467. As long as it is not merged into the master, you can simply replace the file "dashboard-widgets.el" in the package folder "dashboard-20230512.1839" with the same file from the pull request. You also have to delete the corresponding *.elc file, e.g. "dashboard-widgets.elc", so that the changes have an impact.

@sebastiaanspeck
Copy link
Contributor

sebastiaanspeck commented Aug 9, 2023

A cleaner solution, for now, would be:

(defun dashboard-replace-displayable (str &optional rep)
  "Replace non-displayable character from STR.
Optional argument REP is the replacement string of non-displayable character."
  (if (stringp str)
      str
    ""))

If you change it in dashboard-widget.el and you run M-x byte-compile-file you don't need to delete the .elc-file

@team-epk
Copy link

team-epk commented Aug 9, 2023

I was having this issue, and I was able to fix it by changing two lines in dashboard-widget.el

(defcustom dashboard-set-heading-icons t ;; this used to say "nil"
  "When non nil, heading sections will have icons."
  :type 'boolean
  :group 'dashboard)

(defcustom dashboard-set-file-icons t ;; this also used to say "nil"
  "When non nil, file lists will have icons."
  :type 'boolean
  :group 'dashboard)

Whether or not this is a good idea, I don't know. But this is where it seemed to be getting the idea that something was nil, and nothing I did to my init.el seemed to work. This did.

@seagle0128
Copy link
Contributor

My workaround:

(advice-add #'dashboard-replace-displayable :override #'identity)

@LukeDRussell
Copy link

LukeDRussell commented Nov 15, 2023

I've been having the same problem for a while. I think I've got a fix. The proposed fixes above didn't help me.

Essentially, I've moved the customizations (i.e. setq) into use-package's :custom section. Before this change, I had all the variables being set under :config - just like the folks above.

(use-package dashboard
    :config
        (dashboard-setup-startup-hook)
    :custom
        (dashboard-startup-banner 'logo)
        (dashboard-banner-logo-title nil)
        (dashboard-center-content t)
        (dashboard-icon-type 'nerd-icons)
        (dashboard-set-heading-icons t)
        (dashboard-set-file-icons t)
        (dashboard-set-footer nil)
        (dashboard-projects-backend 'project-el)
        (dashboard-display-icons-p t)
        (dashboard-items '(
            (recents . 5)
            (agenda . 5)
            (projects . 5)
            (bookmarks . 5)
)))

Screenshot from 2023-11-15 20-20-39

Forgive me for getting any of the terms incorrect, I'm an emacs newbie.

@seagle0128
Copy link
Contributor

I think it has been fixed in 3fce60c.

@LukeDRussell
Copy link

It was still broken for me in the last week, until I moved the config into :custom section.

@knaveightt
Copy link

Hi All - I entered this thread back around May, and just recently tried @LukeDRussell's suggestion (as well as recently moving from all-the-icons to nerd-icons for my setup). It seems to work now for me!

@jonBoone
Copy link

jonBoone commented Nov 27, 2023

FYI, I'm using dash.el 2.20.0 through use-package and straight. I am able to get the icons to work properly with:

(use-package dashboard
  :straight t
  :init
  (setq dashboard-display-icons-p    t
        dashboard-icon-type          'nerd-icons
        dashboard-set-file-icons     t
        dashboard-set-footer         nil
        dashboard-set-headings-icons t)
  :config
  (dashboard-setup-startup-hook))

@christophermadsen
Copy link

I've been having the same problem for a while. I think I've got a fix. The proposed fixes above didn't help me.

Essentially, I've moved the customizations (i.e. setq) into use-package's :custom section. Before this change, I had all the variables being set under :config - just like the folks above.

(use-package dashboard
    :config
        (dashboard-setup-startup-hook)
    :custom
        (dashboard-startup-banner 'logo)
        (dashboard-banner-logo-title nil)
        (dashboard-center-content t)
        (dashboard-icon-type 'nerd-icons)
        (dashboard-set-heading-icons t)
        (dashboard-set-file-icons t)
        (dashboard-set-footer nil)
        (dashboard-projects-backend 'project-el)
        (dashboard-display-icons-p t)
        (dashboard-items '(
            (recents . 5)
            (agenda . 5)
            (projects . 5)
            (bookmarks . 5)
)))

Moving the icon statements to the :custom keyword fixes it for me as well.
Windows 10
Emacs 29.1

My dashboard.el config

(use-package dashboard
  :ensure t
  :config
  (dashboard-setup-startup-hook)
  :diminish
  (dashboard-mode page-break-lines-mode)
  :custom
  (dashboard-center-content t)
  (dashboard-startup-banner 4)
  (dashboard-items '((recents . 10)))
  (dashboard-icon-type 'nerd-icons)
  (dashboard-set-heading-icons t)
  (dashboard-set-file-icons t)
  :custom-face
  (dashboard-heading ((t (:foreground "#f1fa8c" :weight bold))))
  :hook
  (after-init . dashboard-setup-startup-hook))

(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")))
(setq dashboard-banner-logo-title "Aah, you're back. Drink your coffee while it's warm . . .")
(setq dashboard-startup-banner "~/.emacs.d/coffee-isometric-dashboard.png")

And here's a final image of what the icons look like.
image

@rosstimson
Copy link

I'd tried a bunch of 'fixes' for this over the months to no avail, @christophermadsen's suggestion to shift everything into :custom is what finally did the trick. Many thanks.

@christophermadsen
Copy link

I'd tried a bunch of 'fixes' for this over the months to no avail, @christophermadsen's suggestion to shift everything into :custom is what finally did the trick. Many thanks.

Really happy it's also fixed for you! But it was @LukeDRussell who came up with the solution :)

Tiv0w added a commit to Tiv0w/.emacs.d that referenced this issue Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests