reddit / emacs

I made an macro + package for more easily defining org-agenda-category-icon-alist

egregius313 · 2022-04-14 19:05
egregius313 · 2022-04-14 19:06
Hey everyone! I love adding icons to my org agenda, but defining them is a bit of pain. So I made a macro that provides a little domain specific language for declaratively defining them on-top of all-the-icons
nv-elisp · 2022-04-14 19:30
Nice idea. I think many of Org's various user options would benefit from adopting a similar syntax. A few notes: - You have copy-paste assigned the Copyright for your work to John Weigley @ line 3. - Do you need to require org and org-agenda when this file is loaded? Dash as well? Seems like this a fairly simple translation, and could be done without loading any of those libraries. - org-agenda-category icons are already configured as an alist. It would make more sense for a macro to accept a number of plists which make the arguments explicit. You could then account for your icon sets within that plist. e.g. (org-agenda-category-icons! (:category "[tT]est" :icon (faicon sleep) :height 25) ;;etc ) This is more self-descriptive than having the icon set be the key of the data structure. - Does this need to be a macro? I initially wrote [doct](https://www.github.com/progfolio/doct) as a macro, but realized it didn't have to be one. If you feel like you absolutely need a macro, you may want to reconsider the implementation of your macro. It looks like all of the work is done at expansion time. See the following for why this is not ideal: https://www.gnu.org/software/emacs/manual/html_node/elisp/Wrong-Time.html Hope that is helpful, Nick
egregius313 · 2022-04-14 19:47
Thanks for the feedback! 1. Oh shoot, thanks for mentioning the copyright. I was using `use-package` to base the start of my header. 2. Not 100% sure if I can remove `org-agenda`, since I reference `org-agenda-category-icon-alist`. But the `org` and `dash` can probably be removed (I only use dash for the threading macros, which can easily be removed) 3. The macro is updating the `org-agenda-category-alist`, the other alist only holds the functions for building the icons. I am debating the exact best syntax, but the idea is that the sections defined by the keyword define which icon should be chosen, and list the categories that go into it. 4. I do need to rewrite this into generating code instead of automatically defining the icons. But currently it's a macro so that I can use symbols instead of strings when possible.
nv-elisp · 2022-04-14 21:04
For 2. you can "declare" the symbol in your package. e.g. (defvar org-agenda-category-icon-alist) That should silence the byte compiler warning you'll get otherwise. See: https://www.gnu.org/software/emacs/manual/html_node/elisp/Compiler-Errors.html