help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New function: rcd-highlight-list


From: Jean Louis
Subject: Re: New function: rcd-highlight-list
Date: Tue, 18 May 2021 23:14:33 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* tomas@tuxteam.de <tomas@tuxteam.de> [2021-05-18 22:06]:
> > Yes, it is not for all circumstances. It will also not support too
> > many keywords as it uses hi-lock-face-defaults list
> 
> Perhaps the function `regexp-quote' is built for you :)

Good to know how to avoid ".*" regexp problems.

(defun rcd-highlight-list (list)
  "Uses LIST to highlight strings in buffer."
  (hi-lock-mode)
  (let* ((list (delete "" list))
        (highlights hi-lock-face-defaults))
    (while list
      (highlight-regexp (regexp-quote (pop list)) (pop highlights)))))

(rcd-highlight-list '("regexp-quote" ".*")) ⇒ it works well!


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]