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

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

Introducing face in comments for various modes


From: Heime
Subject: Introducing face in comments for various modes
Date: Sun, 11 Dec 2022 15:35:41 +0000

The following uses `hi-lock` to change the foreground of comments matching
a regexp.  This is implemented for emacs-lisp files where comments start 
with ";;".  

I would like to extend this for other programming languages besides emacs-lisp
files, using the relevant comment character automatically for that language.

(defface elfa-face
  '((t :foreground "magenta"))
  "Face for comment headings.")

(defun elfa-regexp (&optional actm)
  "Identify comment category ';; [Category]'."
   (highlight-regexp
      "^;;\s+\\[.+\\].*$" 'elfa-face))

(defun elfa-category ()
  "TODO."
  (interactive)
  (add-to-list 'auto-mode-alist '("\\.el\\'" . hi-lock-mode))
  (add-hook 'emacs-lisp-mode-hook 'hi-lock-mode t)
  (add-hook 'hi-lock-mode-hook 'elfa-regexp))






reply via email to

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