font-lock-add-keywords lets users highlight keywords. Can you also specify an alternative text? For example, in C source code, besides using a special face, we may wish to visualize ! as not, && as and, etc.
Asked
Active
Viewed 72 times
1
Eleno
- 1,448
- 11
- 17
1 Answers
0
As indicated by @Drew and @Lindydancer, Prettify Symbols Mode - available with vanilla Emacs - allows for sequences of characters to be displayed by a custom character sequence, by customizing the prettify-symbols-alist buffer-local variable. Examples:
(push '("&&" . "∧") prettify-symbols-alist) ; Single character replacement.
(push '("&&" . (?a ?n ?d)) prettify-symbols-alist) ; String replacement.
Eleno
- 1,448
- 11
- 17
prettify-symbols-modecomes close, but it can replace matches with just one character, it seems. – Eleno Mar 31 '20 at 21:37display-property, or some such. – Drew Mar 31 '20 at 21:38compose-region." Well,compose-regionaccepts strings, so my guess is that you can use a string, if not something like(?a ?n ?d)might work. (If someone has more time than I do, feel tree to try this and post an answer.) – Lindydancer Apr 01 '20 at 08:27(?a ?n ?d), but the replacement works by compressing the characters in the same box. Thanks anyway. – Eleno Apr 01 '20 at 11:43