[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding icon sets to Emacs -- and next steps for icons.el

From: Stefan Kangas
Subject: Adding icon sets to Emacs -- and next steps for icons.el
Date: Tue, 23 Aug 2022 23:45:43 -0700

Hi Emacs,

I've procrastinated on this for long enough, so...

I've just pushed the branch scratch/icons with my work from before Lars
merged his icons.el.  I intend to start finishing this up for merging to
master, including properly merging it with Lars' work.

The idea behind my icons.el is that a user should be able to switch out
all icons at once (to get a consistent look) rather than having to
customize a potentially large number of individual icons.

The work that I've done therefore operate on a different level from
Lars' work: it tries to map an icon name (currently a string) like
"warning" to a concrete file, which could be, e.g.,
"material/alert/warning.svg" or "octicons/alert-16.svg".

The exact file chosen will depend on the available icon sets, the user
option `icons-set-priority', and the font size.[1]

This means you can say:

    (icons-get "content/inventory")
    => #(" " 0 1
          (image :type svg
                 :file ".../etc/images/material/content/inventory.svg"
                 :scale 1.1052631578947367
                 :ascent center
                 :height (1 . em)
                 :transform-smoothing t)))

    (icons-get-filename "content/inventory")
    => "/home/skangas/wip/emacs/etc/images/material/content/inventory.svg"

My idea is to keep Lars' idea of individual customizable icons, but
leave the choice of which image file to the code I've written.
I imagine that the `warnings-suppress' icon definition in warnings.el
should look something like:

    (define-icon warnings-suppress button
      '((image "warning")                 ;;; <<< NEW LINE >>>
        (emoji "⛔")
        (symbol " ■ ")
        (text " stop "))
      "Suppress warnings."
      :version "29.1"
      :help-echo "Click to suppress this warning type")

>From here, "warning" will be fed to my `icons-get', which will be
responsible for producing, e.g., the ".../material/alert/warning.svg"
file from the "materials" icon set, based on whatever knobs we decide to

I have included material icons and octicons as two default sets, to be
distributed with Emacs.  (They would not be considered a part of Emacs
and so don't need to be subject to copyright assignment.)  More icon
sets would be easy to add to either GNU ELPA or core later.

To test this: build the scratch/icons branch, then check the main
toolbar, `M-x list-icons', the `M-x mpc' toolbar, and `M-x compile'.

Note that this is very much WIP still, but any comments are welcome.

[1] Some icon sets provide more than one version of an icon, intended
    for viewing at smaller and larger sizes.  So asking for "warning"
    should give you either "octicons/alert-16.svg" or
    "octicons/alert-24.svg" depending on the size of the default face.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]