Hi all, I wasn't able to google a clear examples of how to do this. For example, I'd like to highlight all text between double-quotes. -- Le
>>>>> Le Wang <l26wang@gmail.com> writes: > I wasn't able to google a clear examples of how to do this. For example, > I'd like to highlight all text between double-quotes. Typically it looks something like this: (font-lock-add-keywords org-mode (list (list (concat "\\(\"[^\"]+\"\\)") 1 highlight-face t))) Where `highlight-face' is the face you'd like to use. The regexp doesn't handle cases where \" legitimately occurs in a string, either. The part between the \\(\\) is what gets colorized. John
>>>>> John Wiegley <jwiegley@gmail.com> writes: >>>>> Le Wang <l26wang@gmail.com> writes: >> I wasn't able to google a clear examples of how to do this. For example, >> I'd like to highlight all text between double-quotes. > Typically it looks something like this: > (font-lock-add-keywords org-mode [...] Sorry, that should be 'org-mode, to name the symbol, not attempt to use its value. John
Thanks for the hint, I tried this, but all my beautiful salad bowl
colours went away.
(font-lock-add-keywords 'org-mode '(("\"\\(\\(?:.\\|\n\\)*?[^\\]\\)\""
0 font-lock-string-face)))
Notice that I made a bad attempt to handle escaped quotation mark in
the string. Does anyone know a better solution to handle escaped
characters in font-lock?
On Wed, Aug 24, 2011 at 9:17 AM, John Wiegley <jwiegley@gmail.com> wrote:
>>>>>> John Wiegley <jwiegley@gmail.com> writes:
>
>>>>>> Le Wang <l26wang@gmail.com> writes:
>>> I wasn't able to google a clear examples of how to do this. For example,
>>> I'd like to highlight all text between double-quotes.
>
>> Typically it looks something like this:
>
>> (font-lock-add-keywords org-mode
> [...]
>
> Sorry, that should be 'org-mode, to name the symbol, not attempt to use its
> value.
>
> John
>
>
>
--
Le
Hi, I want to add custom keywords to be highlighted. I used (font-lock-add-keywords nil '(("books" . org-level-4)) t) but nothing happens after I restart orgmode or call 'font-lock-update'. -- Daniel Fleischer
Hi, Daniel Fleischer <danflscr@gmail.com> writes: > Hi, I want to add custom keywords to be highlighted. I used > (font-lock-add-keywords nil '(("books" . org-level-4)) t) > > but nothing happens after I restart orgmode or call 'font-lock-update'. The following works for me, in an org mode buffer: ,---- | (font-lock-add-keywords nil '(("books" . 'org-level-4)) t) `---- (I added a quote before the face name). No need to call font-lock-update or restart: any new or modified text gets the new fontification. Bruno > -- > Daniel Fleischer
Bruno Barbier [2021-12-21 Tue 20:35] wrote: > The following works for me, in an org mode buffer: > > ,---- > | (font-lock-add-keywords nil '(("books" . 'org-level-4)) t) > `---- > No need to call font-lock-update or restart: any new or modified text > gets the new fontification. Thanks, it works with the quote. -- Daniel Fleischer