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

Error with modeline when using svg-lib #76

Open
bornbanane opened this issue May 20, 2024 · 9 comments
Open

Error with modeline when using svg-lib #76

bornbanane opened this issue May 20, 2024 · 9 comments

Comments

@bornbanane
Copy link

Hello,

Emacs : 29.3
svg-lib : 0.3
nano-modeline : 1.1.0
nano-theme : 0.3.4

I use "nano-theme" and "nano-modeline" and instead of seeing icons in modeline I see text [bootstrap:XXX], I see this for exmple when I am in "capture" in orgmode (org roam dailies capture today).

Looking at the sources I see that svg-lib is required, so I add it via a :
(use-package svg-lib) in my conf and when I restart my emacs my modeline disappears and I get this kind of error :

Error during redisplay: (eval (let* ((nano-modeline-base-face (nano-modeline--base-face 'header)) (left (mapconcat (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) '((nano-modeline-buffer-status "󰕮") " " (nano-modeline-buffer-name "Dashboard")))) (right (mapconcat (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) '((nano-modeline-buttons (("[Journal]" org-roam-dailies-capture-today . "Journal") ("[TAB]" tab-new . "New Tab") ("[DIRED]" ziok-dired . "Dired") ("[Toolbar]" tool-bar-mode . "Toolbar") ("[Menu]" menu-bar-mode . "Menu")) t) " " (nano-modeline-window-dedicated)))) (width (window-width)) (outside fringes-outside-margins) (left-fringe (if outside -1.0 0.0)) (left-margin (if outside 0.0 1.0)) (right-fringe (if outside -1.0 0.0)) (right-margin (if outside -1.0 0.0)) (left-max-size (- width (length right) 2)) (left (if (> (length left) left-max-size) (concat (truncate-string-to-width left left-max-size) (propertize "…" 'face `(:inherit ,nano-modeline-base-face))) left))) (concat (propertize " " 'display `(space :align-to (+ left-margin (,left-fringe . left-fringe) (,left-margin . left-margin)))) (propertize " " 'face 'fringe 'display '(space :width (nano-modeline-left-fringe-width))) left (propertize " " 'face `(:inherit ,nano-modeline-base-face) 'display `(space :align-to (- right-margin (,right-fringe . right-fringe) (,right-margin . right-margin) (nano-modeline-right-fringe-width) ,(length right)))) right (propertize " " 'face 'fringe 'display '(space :width (nano-modeline-right-fringe-width)))))) signaled (wrong-type-argument listp nano-modeline-button-active-face) [25 times]

Here my conf for nano-modeline :

(use-package svg-lib)

(set-face-attribute 'default nil
                    :family "Roboto Mono"
                    :weight 'light
                    :height 140)

(set-face-attribute 'bold nil
                    :family "Roboto Mono"
                    :weight 'regular)

(set-face-attribute 'italic nil
                    :family "Victor Mono"
                    :weight 'semilight
                    :slant 'italic)

(set-fontset-font t 'unicode
                    (font-spec :name "Inconsolata Light"
                               :size 16) nil)

(set-fontset-font t '(#xe000 . #xffdd)
                     (font-spec :name "RobotoMono Nerd Font"
                                :size 16) nil)

(use-package nano-theme
  :config
  (load-theme 'nano t)
)

;;(use-package nano-agenda)


(use-package nano-modeline)
(nano-modeline-text-mode t)
(add-hook 'prog-mode-hook            #'nano-modeline-prog-mode)
(add-hook 'text-mode-hook            #'nano-modeline-text-mode)
(add-hook 'org-mode-hook             #'nano-modeline-org-mode)
(add-hook 'pdf-view-mode-hook        #'nano-modeline-pdf-mode)
;;(add-hook 'mu4e-headers-mode-hook    #'nano-modeline-mu4e-headers-mode)
;;(add-hook 'mu4e-view-mode-hook       #'nano-modeline-mu4e-message-mode)
;;(add-hook 'elfeed-show-mode-hook     #'nano-modeline-elfeed-entry-mode)
;;(add-hook 'elfeed-search-mode-hook   #'nano-modeline-elfeed-search-mode)
(add-hook 'term-mode-hook            #'nano-modeline-term-mode)
;;(add-hook 'xwidget-webkit-mode-hook  #'nano-modeline-xwidget-mode)
(add-hook 'messages-buffer-mode-hook #'nano-modeline-message-mode)
;;(add-hook 'org-capture-mode-hook     #'nano-modeline-org-capture-mode)
(add-hook 'org-agenda-mode-hook      #'nano-modeline-org-agenda-mode)

;; pour tester 
(defun ziok-nano-modeline-org-capture-filename ()
    (buffer-file-name (org-base-buffer (current-buffer))))

(defun ziok-nano-modeline-org-capture-mode ()
  "Nano line for org capture mode"  

  (let* ((filename (ziok-nano-modeline-org-capture-filename))
         (save (format "Save entry to %s" filename))
         (buttons `(("SAVE" . (org-capture-finalize . ,save))
                    ("CANCEL" . (org-capture-kill . "Delete entry"))
                    ("[bootstrap:arrows-expand]" . (delete-other-windows . "expand"))
                    )))
    (funcall nano-modeline-position
             `((nano-modeline-buffer-status "ORG") " "
               (nano-modeline-buffer-name "Capture") " "
               (nano-modeline-org-capture-description))
             `((nano-modeline-buttons ,buttons t) " "
               (nano-modeline-window-dedicated)))))

(add-hook 'org-capture-mode-hook     #'ziok-nano-modeline-org-capture-mode)			   

;; pour le bouton DIRED
(defun ziok-dired () 
  (interactive)
  "Dired button function"
  (dired "/home/francois/orgmode/orgroam")
)
;; ajout de bouton sur le dashboard
(defun ziok-nano-modeline-dashboard-mode ()
  "Nano line for Dashboard"
  
  (let ((buttons '( 
	("[Journal]" . (org-roam-dailies-capture-today . "Journal")) 
	("[TAB]" . (tab-new . "New Tab")) 
	("[DIRED]" . (ziok-dired . "Dired")) 
	("[Toolbar]" . (tool-bar-mode . "Toolbar")) 
	("[Menu]" . (menu-bar-mode . "Menu")) 
	)))	
	(funcall nano-modeline-position
             '((nano-modeline-buffer-status "󰕮") " "
               (nano-modeline-buffer-name "Dashboard"))
             `((nano-modeline-buttons ,buttons t) " "
               (nano-modeline-window-dedicated)))))

(add-hook 'dashboard-mode-hook #'ziok-nano-modeline-dashboard-mode)
(add-hook 'post-command-hook #'force-mode-line-update)

On the other hand, "modelines" that don't use button like the default org one work very well.
And without svg-lib everything is OK but button are juste text [bootstrap:XXX]

PS : C'est un plaisir d'utiliser vos créations 👍

@rougier
Copy link
Owner

rougier commented May 27, 2024

Merci !

For the bootstrap:XXX, the problem seems that svg-lib is unable to create the button for some reason. Can you try to toggle debug on error and report the error (if any) ?

@bornbanane
Copy link
Author

I have activated toggle debug on error (M-x toggle-debug-on-error) but it does not stop and report anything else than the previous error of the inial post.

I have done a capture with orgroam this time to have the error with your default button :

Error during redisplay: (eval (let* ((nano-modeline-base-face (nano-modeline--base-face 'header)) (left (mapconcat (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) '((nano-modeline-buffer-status "ORG") " " (nano-modeline-buffer-name "Capture") " " (nano-modeline-org-capture-description)))) (right (mapconcat (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) '((nano-modeline-buttons (("SAVE" org-capture-finalize . "Save entry to /home/xxxxxx/orgmode/orgroam/daily/2024-05-27.org") ("CANCEL" org-capture-kill . "Delete entry") ("[bootstrap:arrows-expand]" delete-other-windows . "expand")) t) " " (nano-modeline-window-dedicated)))) (width (window-width)) (outside fringes-outside-margins) (left-fringe (if outside -1.0 0.0)) (left-margin (if outside 0.0 1.0)) (right-fringe (if outside -1.0 0.0)) (right-margin (if outside -1.0 0.0)) (left-max-size (- width (length right) 2)) (left (if (> (length left) left-max-size) (concat (truncate-string-to-width left left-max-size) (propertize "…" 'face `(:inherit ,nano-modeline-base-face))) left))) (concat (propertize " " 'display `(space :align-to (+ left-margin (,left-fringe . left-fringe) (,left-margin . left-margin)))) (propertize " " 'face 'fringe 'display '(space :width (nano-modeline-left-fringe-width))) left (propertize " " 'face `(:inherit ,nano-modeline-base-face) 'display `(space :align-to (- right-margin (,right-fringe . right-fringe) (,right-margin . right-margin) (nano-modeline-right-fringe-width) ,(length right)))) right (propertize " " 'face 'fringe 'display '(space :width (nano-modeline-right-fringe-width)))))) signaled (wrong-type-argument listp nano-modeline-button-active-face) [207 times] 

I'm not good enough in elisp to understand fully what all that means.

Well I found that : https://www.gnu.org/software/emacs/manual/html_node/elisp/Debugging-Redisplay.html

So here the content of the buffer *Redisplay_trace* after evaluating (setq backtrace-on-redisplay-error t)

Error: wrong-type-argument (listp nano-modeline-button-inactive-face)
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 0x107021b139ae86a6>))
  debug-early-backtrace()
  debug-early(error (wrong-type-argument listp nano-modeline-button-inactive-face))
  svg-lib-tag("SAVE" nano-modeline-button-inactive-face)
  nano-modeline--make-svg-button("SAVE" nano-modeline-button-inactive-face active)
  nano-modeline--make-button((:label "SAVE" :state active :help "Save entry to /home/xxxxx/orgmode/orgroam/daily/2024-05-27.org" :hook org-capture-finalize) t)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_5>((:label "SAVE" :state active :help "Save entry to /home/xxxxx/orgmode/orgroam/daily/2024-05-27.org" :hook org-capture-finalize))
  nano-modeline-buttons((("SAVE" org-capture-finalize . "Save entry to /home/xxxxx/orgmode/orgroam/daily/2024-05-27.org") ("CANCEL" org-capture-kill . "Delete entry") ("[bootstrap:arrows-expand]" delete-other-windows . "expand")) t nil)
  apply(nano-modeline-buttons ((("SAVE" org-capture-finalize . "Save entry to /home/xxxxx/orgmode/orgroam/daily/2024-05-27.org") ("CANCEL" org-capture-kill . "Delete entry") ("[bootstrap:arrows-expand]" delete-other-windows . "expand")) t))
  (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))
  (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element))))((nano-modeline-buttons (("SAVE" org-capture-finalize . "Save entry to /home/xxxxx/orgmode/orgroam/daily/2024-05-27.org") ("CANCEL" org-capture-kill . "Delete entry") ("[bootstrap:arrows-expand]" delete-other-windows . "expand")) t))
  mapconcat((lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) ((nano-modeline-buttons (("SAVE" org-capture-finalize . "Save entry to /home/xxxxx/orgmode/orgroam/daily/2024-05-27.org") ("CANCEL" org-capture-kill . "Delete entry") ("[bootstrap:arrows-expand]" delete-other-windows . "expand")) t) " " (nano-modeline-window-dedicated)))
  (let* ((nano-modeline-base-face (nano-modeline--base-face 'header)) (left (mapconcat (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) '((nano-modeline-buffer-status "ORG") " " (nano-modeline-buffer-name "Capture") " " (nano-modeline-org-capture-description)))) (right (mapconcat (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) '((nano-modeline-buttons (("SAVE" org-capture-finalize . "Save entry to /home/xxxxx/orgmode/orgroam/daily/2024-05-27.org") ("CANCEL" org-capture-kill . "Delete entry") ("[bootstrap:arrows-expand]" delete-other-windows . "expand")) t) " " (nano-modeline-window-dedicated)))) (width (window-width)) (outside fringes-outside-margins) (left-fringe (if outside -1.0 0.0)) (left-margin (if outside 0.0 1.0)) (right-fringe (if outside -1.0 0.0)) (right-margin (if outside -1.0 0.0)) (left-max-size (- width (length right) 2)) (left (if (> (length left) left-max-size) (concat (truncate-string-to-width left left-max-size) (propertize "…" 'face `(:inherit ,nano-modeline-base-face))) left))) (concat (propertize " " 'display `(space :align-to (+ left-margin (,left-fringe . left-fringe) (,left-margin . left-margin)))) (propertize " " 'face 'fringe 'display '(space :width (nano-modeline-left-fringe-width))) left (propertize " " 'face `(:inherit ,nano-modeline-base-face) 'display `(space :align-to (- right-margin (,right-fringe . right-fringe) (,right-margin . right-margin) (nano-modeline-right-fringe-width) ,(length right)))) right (propertize " " 'face 'fringe 'display '(space :width (nano-modeline-right-fringe-width)))))
  eval((let* ((nano-modeline-base-face (nano-modeline--base-face 'header)) (left (mapconcat (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) '((nano-modeline-buffer-status "ORG") " " (nano-modeline-buffer-name "Capture") " " (nano-modeline-org-capture-description)))) (right (mapconcat (lambda (element) (if (stringp element) (propertize element 'face nano-modeline-base-face) (apply (car element) (cdr element)))) '((nano-modeline-buttons (("SAVE" org-capture-finalize . "Save entry to /home/xxxxx/orgmode/orgroam/daily/2024-05-27.org") ("CANCEL" org-capture-kill . "Delete entry") ("[bootstrap:arrows-expand]" delete-other-windows . "expand")) t) " " (nano-modeline-window-dedicated)))) (width (window-width)) (outside fringes-outside-margins) (left-fringe (if outside -1.0 0.0)) (left-margin (if outside 0.0 1.0)) (right-fringe (if outside -1.0 0.0)) (right-margin (if outside -1.0 0.0)) (left-max-size (- width (length right) 2)) (left (if (> (length left) left-max-size) (concat (truncate-string-to-width left left-max-size) (propertize "…" 'face `(:inherit ,nano-modeline-base-face))) left))) (concat (propertize " " 'display `(space :align-to (+ left-margin (,left-fringe . left-fringe) (,left-margin . left-margin)))) (propertize " " 'face 'fringe 'display '(space :width (nano-modeline-left-fringe-width))) left (propertize " " 'face `(:inherit ,nano-modeline-base-face) 'display `(space :align-to (- right-margin (,right-fringe . right-fringe) (,right-margin . right-margin) (nano-modeline-right-fringe-width) ,(length right)))) right (propertize " " 'face 'fringe 'display '(space :width (nano-modeline-right-fringe-width))))))
  redisplay_internal\ \(C\ function\)()

I hope that can help.

@rougier
Copy link
Owner

rougier commented Jun 24, 2024

Can you try in a scratch buffer:

(require 'svg-lib)
(insert (propertize "HOME" 'display (svg-lib-tag "[material:home] HOME")))

@bornbanane
Copy link
Author

Hi, sorry for late answer.

emacs-svglibs

@rougier
Copy link
Owner

rougier commented Aug 28, 2024

You get no error alongside? Can you also try to remove .emacs.d/.cache/svg-lib?

@bornbanane
Copy link
Author

Hi,

I think I found what was the problem.

I was trying to search for any errors, then I check the svg-lib.el inside my .emacs.d/elpa/svg-lib-0.3 directory and found that the file is way older than the one on git.

I did not have any mention of Version 0.3.1 inside of it.

Then I checked on ELPA to see if i have an old version, but when i download the package directly from there it's still an old version. https://elpa.gnu.org/packages/svg-lib.html -> https://elpa.gnu.org/packages/svg-lib-0.3.tar

So I installed svg-lib with a git clone of repo and in my config before nano-modline use-package :

(add-to-list 'load-path "~/.emacs.d/svg-lib")
(require 'svg-lib)

Now i don't have any error. But the modeline still show the text [bootstrap:arrows-expand], I checked your code (i'm still a newcomer with elisp) and found out that (package-installed-p 'svg-lib) return nil (

(buttons (if (and use-svg (package-installed-p 'svg-lib))
) . So the code show only text and not the button.

Now (insert (propertize "HOME" 'display (svg-lib-tag "[material:home] HOME"))) is correctly showing a square with the icon and text.

How can I install svg-lib correctly ?

@rougier
Copy link
Owner

rougier commented Sep 6, 2024

Not sure actually. It's weird that svg-lib is installed but package-installed-p 'svg-lib) reports not install. Is that correct?
Can you have a look at the variable package-activated-list?

@Cerebus
Copy link

Cerebus commented Dec 4, 2024

Same problem here, but no workaround.

  • svg-lib is installed (via use-package)
  • package-installed-p reports it installed
  • it's in package-activated-list
  • inserting a propertized string into a scratch buffer renders correctly.

@rougier
Copy link
Owner

rougier commented Jan 6, 2025

You mean you cannot display svg tags inside the mode line ?

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

3 participants