[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Introducing face in comments for various modes
From: |
Stefan Monnier |
Subject: |
Re: Introducing face in comments for various modes |
Date: |
Sun, 11 Dec 2022 12:40:21 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
BTW, there is a related convention in ELisp code where comments that
start in column 0 and which are introduced with 3 or more semi-colons
are considered sectioning headers (where ";;;" means a top-level
header, ";;;;" a subheader, ";;;;;" a subsubheader, ...).
I'd be happy if Emacs were changed to highlighting those.
Stefan
Heime [2022-12-11 15:35:41] wrote:
> 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))
- Introducing face in comments for various modes, Heime, 2022/12/11
- Re: Introducing face in comments for various modes,
Stefan Monnier <=
- Re: Introducing face in comments for various modes, Heime, 2022/12/11
- Re: Introducing face in comments for various modes, Heime, 2022/12/11
- Re: Introducing face in comments for various modes, Thibaut Verron, 2022/12/12
- Re: Introducing face in comments for various modes, Heime, 2022/12/12
- Re: Introducing face in comments for various modes, Thibaut Verron, 2022/12/12
- Re: Introducing face in comments for various modes, Heime, 2022/12/12
- Re: Introducing face in comments for various modes, Thibaut Verron, 2022/12/12
- Re: Introducing face in comments for various modes, Heime, 2022/12/12
- Re: Introducing face in comments for various modes, Thibaut Verron, 2022/12/12
- Re: Introducing face in comments for various modes, Heime, 2022/12/12