I write a simple emacs mode. How do I explicitly specify that all things in e.g. square brackets should be colored. Must be smth like that:
( (if thing is in square brackets) . font-lock-string-face)
I assume you're writing a major mode, but font-lock-add-keywords
works also in minor
modes. Check out its documentation with C-h f RET font-lock-add-keywords
.
(define-derived-mode my-mode text-mode "mymode"
;; some init code
(font-lock-add-keywords nil '(("\\[\\(.*\\)\\]"
1 font-lock-warning-face prepend)))
;; some more init code
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With