0

I am making some small customizations to my org-agenda view.

For the face called "Org Agenda Done", I am adding a strikethrough and changing the color.

The color I want to use is already defined as the foreground color for "Org Agenda Dimmed Todo Face".

Is there a way to define the color of "Org Agenda Done" using the value of "Org Agenda Dimmed Todo Face"?

Right now, I only see the option to define the color of the face with a hex value.

enter image description here

2
  • You could inherit from the other face, and add your own properties. (However, if the other face defines a lot of extra attributes besides the foreground face this doesn't work.) Nov 3, 2022 at 17:50
  • @Lindydancer interesting — do you have examples of how to do this? I'm still getting used to working in Lisp. thank you! Nov 3, 2022 at 17:58

3 Answers 3

4

You can get and set face attributes using the functions described in the Face Attributes Functions section of the Emacs Lisp Reference manual.

E.g.:

(set-face-foreground 'org-agenda-done
                     (face-foreground 'org-agenda-dimmed-todo-face))

You can put this in your init file but you have to make sure that the faces are already defined. They are defined in the file org-faces.el[c], so you have to make sure that that file is loaded:

(require 'org-faces)
(set-face-foreground ...)
3
  • Where would this code live? Nov 15, 2022 at 14:05
  • 1
    Edited the answer with the additional info.
    – NickD
    Nov 15, 2022 at 17:20
  • Thanks — I needed the require statement that I didn't have before. Nov 15, 2022 at 21:16
2

When defining your face, you can inherit from another face (or even faces). Note that if the original face should change after you have defined your face, your face will also change accordingly.

For example:

(defface my-extra-warning-face
  '((t :inherit font-lock-warning-face :background "green"))
  "My extra warning face.")
2

The customize interface accepts both color names and hex values. You can also press the button for choosing a color, the interface will show you a list of color names with their hex values. You can just search for the color name (C-s) of the Org Agenda Dimmed Todo Face face foreground color and select it.

4
  • When I click the "choose" button, I'm given a list of colors, but they are from the color spectrum, not colors defined by modes like "org-mode". This means that "Org Agenda Dimmed Todo Face" is not available in that list. Is there some way to get it to show up there? Nov 15, 2022 at 14:04
  • It's possible, but it is not easy. Can't you just look up the color name/value using (face-foreground 'org-agenda-dimmed-todo-face)? And then search for that... Nov 15, 2022 at 14:27
  • I'm using the Dracula theme, and the color listed isn't one of the listed colors, unfortunately. Nov 15, 2022 at 17:02
  • Ah well, then you can enter the color manually by typing, or even better, use @NickD's solution... Nov 15, 2022 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.