3

Here's a code that works for setting a string foreground:

(defface test-face
  '((t (:height 1.2 :foreground "green")))
  "doc.")
(setq asdf (propertize "asdf" 'face 'test-face))
(add-face-text-property 0 (length asdf) '(:foreground "red") nil asdf)

asdf will still have the height 1.2 through test-face while gaining a red foreground, instead of green.

But this doesn't work:

(add-face-text-property 0 (length asdf) '(:height 1.0) nil asdf)

While the text properties will change, when inserting asdf into a fundamental-mode buffer, it will still have the height 1.2. How can I set the height to 1.0, while preserving the face?

  • Might this be a bug? – Malabarba Jun 19 '15 at 15:44
  • It could be a bug, it could be "by design". Even if it's a bug, I need a fix that works for the current Emacs, since I want to use this in swiper. – abo-abo Jun 19 '15 at 15:59
1

Turns out the text height stacks the modifiers, so this works:

(add-face-text-property
 0 (length asdf)
 `(:height ,(/ 1 1.2)) nil asdf)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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