Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting text properties in Emacs when using font-lock-defaults

Tags:

emacs

elisp

I am trying to set some background text properties in my Emacs buffer. For instance,

(set-text-properties pos1 pos2 '(face '(:background "cyan")))

But I cannot get it to work. I think I have a clue why it does not work: I am also using a major mode that uses (setq font-lock-defaults '((some-font-lock-keywords))) If I comment out that assignment to font-lock-defaults it works fine.

like image 368
Håkon Hægland Avatar asked Oct 29 '25 22:10

Håkon Hægland


1 Answers

Here's a bit of code that you can paste into *scratch*:

(let ((inhibit-modification-hooks t))
  (make-face 'temp-face)
  (set-face-background 'temp-face "cyan")
  (put-text-property 1 50 'face 'temp-face))
like image 127
abo-abo Avatar answered Nov 01 '25 12:11

abo-abo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!