Re: How to add font-lock keywords

2021-12-23 Thread 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



Re: How to add font-lock keywords

2021-12-21 Thread Bruno Barbier


Hi,

Daniel Fleischer  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



How to add font-lock keywords

2021-12-11 Thread Daniel Fleischer
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



[O] how to add font-lock keywords

2011-08-23 Thread Le Wang
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



Re: [O] how to add font-lock keywords

2011-08-23 Thread John Wiegley
 Le Wang l26w...@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




Re: [O] how to add font-lock keywords

2011-08-23 Thread John Wiegley
 John Wiegley jwieg...@gmail.com writes:

 Le Wang l26w...@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




Re: [O] how to add font-lock keywords

2011-08-23 Thread Le Wang
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 jwieg...@gmail.com wrote:
 John Wiegley jwieg...@gmail.com writes:

 Le Wang l26w...@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