alphapapa / org-super-agenda

Supercharge your Org daily/weekly agenda by grouping items
GNU General Public License v3.0
1.35k stars 107 forks source link

insert icons in headings using `all-the-icons`? #117

Closed xeijin closed 4 years ago

xeijin commented 4 years ago

If there's another way to do this that my inexperience means I'm missing, happy to be corrected.

From what I can see the keywords that display text (like :name only accept strings/characters, not a function that returns a string.

This means that when I try and insert an icon from all-the-icons I instead get an error (as it's insertion function returns a string with text properties).

The icon sets actually have different faces (which are different physical font files) so I can't simply re-define the face: org-super-agenda-header.

Would it be possible to amend :name so we can add a little iconography :) ?

xeijin commented 4 years ago

An example using format (I've tried other variations too):

(:name (format "%s due this week\n" (all-the-icons-insert-faicon "anchor"))
           :order 1
           ;:sort '(deadline)
           :deadline t
           )

gives me the error:

org-super-agenda--group-items: Wrong type argument: characterp, format

However with the :title keyword it does seem to work:

:title (format "%s due this week\n" (all-the-icons-insert-faicon "anchor"))

image

xeijin commented 4 years ago

think I have managed it (albeit not pretty)

the following (produced by the appropriate insertion function, e.g. (all-the-icons-octicon "pulse"):

  :title #(" Pulse Agenda " 0 1
  (rear-nonsticky t display
                  (raise -0.1)
                  font-lock-face
                  (:family "github-octicons" :height 1.0)
                  face
                  (:family "github-octicons" :height 1.0)))

  :super-groups
  '(
;    :sort '(deadline todo)
    (:name #(" due this week\n" 0 1
             (rear-nonsticky t display
                             (raise -0.24)
                             font-lock-face
                             (:family "Material Icons" :height 1.2)
                             face
                             (:family "Material Icons" :height 1.2)))

           :order 1
           ;:sort '(deadline)
           :deadline t
           ))

will produce:

image

feel free to close if you think this suffices/is appropriate

alphapapa commented 4 years ago

The value of org-super-agenda-groups is not evaluated, so if you want to use a function's return value in it, you should construct the list either without using quote, or you should use backquoting and unquoting/splicing.

Or, as you cleverly discovered, you can use the readable form of a string with text-properties.

Note that in your earlier comment:

An example using format (I've tried other variations too): gives me the error:

org-super-agenda--group-items: Wrong type argument: characterp, format

However with the :title keyword it does seem to work:

The :super-groups argument is passed to org-super-agenda, while the :title argument to org-ql-search is handled by org-ql. They don't have the same semantics.