emacs-citar / citar

Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
GNU General Public License v3.0
501 stars 54 forks source link

Using `nerd-icons` for `citar-symbols` leads to use of default values (`F`, `N`, `L`) instead #781

Closed stewmehr closed 1 year ago

stewmehr commented 1 year ago

Describe the bug When trying to include nerd-icons (I have used all-the-icons before with no issues), the entries in citar-symbols fall back to the default values of F, N, L.

To Reproduce Steps to reproduce the behavior:

  1. Install nerd-icons, e.g. via
    (use-package nerd-icons
    :straight (nerd-icons
               :type git
               :host github
               :repo "rainstormstudio/nerd-icons.el"))
  2. Modify config to use citar-symbols
    (use-package citar
    ;; ...
    ;; other config
    ;; ...
    :custom
    (citar-symbols
     `((file ,(nerd-icons-faicon "nf-fa-file_pdf_o" :face 'nerd-icons-lred :v-adjust -0.1) . " ")
       (note ,(nerd-icons-sucicon "nf-custom-orgmode" :face 'nerd-icons-lgreen :v-adjust -0.1) . " ")
       (link ,(nerd-icons-octicon "nf-oct-link" :face 'nerd-icons-lblue :v-adjust 0.01) . " "))))
  3. Open up citar notes via M-x citar-open-notes
  4. The pop-buffer that opens up contains letters F, N, and L instead of their replacements defined above.

Expected behavior I would expect the letters to be replaced by their respective glyphs.

Screenshots

Screenshot 2023-05-17 at 11 11 57

Emacs version: 28.2

Additional context I am well aware that this issue does very little to improve the functionality of this great package and only covers aesthetics. When browsing the list of old issues, I had really hoped for this to be a duplicate of #667. But: I was surprised to see that the default values are displayed instead of empty spaces or broken glyphs. This seemed weirder to me than a simple missing font/wrong scaling on my end so I would like to learn more about this.

Below, I attach the value of describe-variable citar-symbols - in my Emacs, the three glyphs in question are displayed perfectly fine in the *Help* buffer (not sure if this works when pasting them here, so please ~take my word for it~ see additional screenshot below):

citar-symbols is a variable defined in ‘citar.el’.

Its value is shown below.

Configuration alist specifying which symbol or icon to pick for a bib entry.
This leaves room for configurations where the absense of an item
may be indicated with the same icon but a different face.

To avoid alignment issues make sure that both the car and cdr of a symbol have
the same width.

  You can customize this variable.

Value:
((file
  #("" 0 1
    (face #1=(:family #2="Symbols Nerd Font Mono" :height 1.0 :inherit nerd-icons-lred)
      font-lock-face #1# display
      (raise -0.1)
      rear-nonsticky t))
  . " ")
 (note
  #("" 0 1
    (face #3=(:family #2# :height 1.0 :inherit nerd-icons-lgreen)
      font-lock-face #3# display
      (raise -0.1)
      rear-nonsticky t))
  . " ")
 (link
  #("" 0 1
    (face #4=(:family #2# :height 1.0 :inherit nerd-icons-lblue)
      font-lock-face #4# display
      (raise 0.01)
      rear-nonsticky t))
  . " "))
Original value was 
((file "F" . " ")
 (note "N" . " ")
 (link "L" . " "))
Screenshot 2023-05-17 at 11 28 53
bdarcus commented 1 year ago

I think the merger of "indicators" obsoleted that defcustom, and I just haven't removed it.

Can you take that a look at that section of the README and report back?

stewmehr commented 1 year ago

Of course that fixes it! Got rid of that part in my :custom block and defined some citar-indicator-* vars in my :config block instead.

Should re-read the docs whenever I absent-mindedly update a package, I just didn't connect the dots this time and thought it was due to switching from all-the-icons to nerd-icons.

Thank you very much! 🙂

EDIT: I'll leave my adjusted config for posteriority

(use-package citar
    ;; ...
    ;; other config
    ;; ...
    :config
    (defvar citar-indicator-files-icon
      (citar-indicator-create
       :symbol (nerd-icons-faicon
                "nf-fa-file_pdf_o"
                :face 'nerd-icons-lred)
       :function #'citar-has-files
       :padding " "
       :tag "has:files"))
    (defvar citar-indicator-notes-icon
      (citar-indicator-create
       :symbol (nerd-icons-sucicon
                "nf-custom-orgmode"
                :face 'nerd-icons-lgreen)
       :function #'citar-has-notes
       :padding " "
       :tag "has:notes"))
    (defvar citar-indicator-links-icon
      (citar-indicator-create
       :symbol (nerd-icons-octicon
                "nf-oct-link"
                :face 'nerd-icons-lblue)
       :function #'citar-has-links
       :padding " "
       :tag "has:links"))
    (defvar citar-indicator-cited-icon
      (citar-indicator-create
       :symbol (nerd-icons-octicon
                "nf-oct-book"
                :face 'nerd-icons-lred)
       :function #'citar-is-cited
       :padding " "
       :tag "is:cited"))
    (setq citar-indicators
          (list citar-indicator-files-icon
                citar-indicator-notes-icon
                citar-indicator-links-icon
                citar-indicator-cited-icon))
    ;; ...
)