0

Given this headline:

** Title
Title Title Title

The headline has the face "org-level-2" applied. This face has been applied by means of a regexp, using font-lock.

Let's assume that "org-level-2" is set as follows:

((t
 (:height 1.5
  :weight bold 
  :extend nil 
  :foreground "black")))

Now, I'd like to apply a custom face for all occurrence of "Title":

(defface my-face
  '((t :foreground "red"))
  "test")

(font-lock-add-keywords nil
  `(("Title" . 'my-face)))

The word "Title" in the headline should have a relative height of 1.5, a bold weight and a red foreground. However, it is just red, with normal size and normal weight.

I'd like both faces to "mix" together. How can I achieve this?

Is font-lock the way to go if i want to remap faces based on regexp?

1
  • I think your question isn't really Org-mode specific. Consider removing that part, or at least tag org-mode.
    – Drew
    Jun 1, 2023 at 13:30

1 Answer 1

1

To make my-face inherit from org-level-2, you can add :inherit 'org-level-2 to the definition of my-face. This way my-face will have the right size and weight.

2
  • Thank you for replying! However, I'd like "my-face" to mix with whatever face is already applied, not just org-level-2. Sort of like applying multiple faces to the same text.
    – cidra
    Jun 1, 2023 at 12:00
  • Then I think you have to deal with the text properties of the occurrences of Title. Jun 1, 2023 at 16:57

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.