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
479 stars 53 forks source link

Request for Nerd Icons Integration in Citar #797

Closed LuciusChen closed 11 months ago

LuciusChen commented 11 months ago

Is your feature request related to a problem? Please describe.

I'm currently using citar for managing and interacting with my bibliographic references in Emacs. However, I would like to use the nerd-icons package (https://github.com/rainstormstudio/nerd-icons.el) to display appropriate icons for different types of references in citar. Currently, citar does not seem to have support for nerd-icons.

Describe the solution you'd like

I would like to see built-in support for nerd-icons in citar. Specifically, this would mean that citar could display different icons based on the type of each reference when displaying reference lists. The mapping of reference types to icons would ideally be customizable.

Describe alternatives you've considered

I've considered using all-the-icons, which is a similar package to nerd-icons. However, I prefer the look and feel of nerd-icons, and it would be great if I could use it directly with citar.

Additional context

I believe that adding support for nerd-icons would make citar more flexible and visually appealing for users who prefer this icon set. I appreciate your consideration of this feature request.

bdarcus commented 11 months ago

Hi!

As a general rule, I don't want to add any icon dependency. I considered, for example, all-the-icons at the very beginning, but decided against it, in part because different people have different preferences.

In fact, reducing dependencies is a general priority here; hence why we split off citar-embark, and citar-org-roam is in a separate repository.

The comment was me forgetting we already have way to do this; see comment below.

~What may be reasonable is somehow adding support for users to configure this themselves, as they can now for the "indicators". That would leave room for small ancillary packages for this.~

~I'll need to think about what that would entail. Perhaps a way to convert the plain text reference type strings into symbols; as you say, configurable (an alist defcustom, for example)?~

~But it's not a high-priority for me personally, and I don't have much time to work on it. But happy to consider a PR.~

~Or if you want to look into what would be required to add that and report your findings here, that could also be helpful.~

bdarcus commented 11 months ago

One wrinkle on this:

Perhaps a way to convert the plain text reference type strings into symbols; as you say, configurable (an alist defcustom, for example)?

Citar supports three different input formats (bibtex, biblatex, and CSL JSON), and hence lists of types. Also, they can be mixed within the same list of files.

bdarcus commented 11 months ago

@LuciusChen - another idea just occurred to me, which will probably work without any code changes in citar.

You could write a function to add to citar-display-transform-functions, and then do something like this in your template:

${=type=:12%icon} 

So in this idea, the post-processing code would replace the type string with the icon.

The function might be something so simple as this (using all-the-icons; not sure about nerd icons):

(defun citar-icon-reftypes (reftype) 
  (pcase reftype
    ("book" (all-the-icons-material "book")))
   ....

I think the bigger challenge is finding the right icons for all the types. From a quick search for "article" icons, for example, none of the sets seem to have one, which is a bad sign.

Another issue is that the reftype would only be visual; you couldn't filter on it. So would need to add it back as invisible.

bdarcus commented 9 months ago

@LuciusChen here's a config for nerd-icons indicators.

https://github.com/emacs-citar/citar/wiki/Indicators#nerd-icons