Question

I'm looking for a regexp to highlight differently one asterisk (e.g., red), and two asterisks (e.g., blue), and three asterisks (yellow). I have a working example of three (3) all together. Defining just one, however, would affect everything unless there is a regexp exclusion.

* -- red

** -- blue

*** -- yellow

(defvar lawlist-yellow-jacket-face (make-face 'lawlist-yellow-jacket-face))
(set-face-attribute 'lawlist-yellow-jacket-face nil
  :background "black" :foreground "yellow" :underline "red" :bold t)

(add-hook 'text-mode-hook (lambda ()
  (font-lock-add-keywords nil (list
    (list (concat "lawlist\\|\\*\\*\\*")
      '(0 lawlist-yellow-jacket-face t))
     ))
  ))
Was it helpful?

Solution

If I understand correctly what you are asking, this does it:

(add-hook 'text-mode-hook
          (lambda ()
            (font-lock-add-keywords
             nil
             '(("lawlist\\|\\*\\*\\*"
                (0 lawlist-yellow-jacket-face))
                ("lawlist\\|\\*\\*"
                (0 'link keep))
               ("lawlist\\|\\*"
                (0 'warning keep))))))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top