all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Heime <heimeborgia@protonmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Special hilighting for comments
Date: Sat, 10 Dec 2022 22:44:33 +0300	[thread overview]
Message-ID: <Y5ThodMQ7x8ktgYG@protected.localdomain> (raw)
In-Reply-To: <dGYJ5YQdgCLczokDrVh3OgFRkZExt0YlbyNarXu1lbW7UA5v8dnIUoJCbG6kQ4WV76YIjYihtwfr7S7jzUjP_hwVYvI6V2iw2NeQzbVHYH0=@protonmail.com>

* Heime <heimeborgia@protonmail.com> [2022-12-10 20:12]:

;; [Highlighted line]

> > 
> > This works well:
> > 
> > (highlight-regexp "^;; \\[.*$")
> 
> Would it be possible to change only the foreground to some specified
> colour? 

Always use {C-h f FUNCTION-NAME} to find description of the function.

{C-h f highlight-regexp RET} tells you:

(highlight-regexp REGEXP &optional FACE SUBEXP LIGHTER)

Set face of each match of REGEXP to FACE.
Interactively, prompt for REGEXP using ‘read-regexp’, then FACE.
Use the global history list for FACE.  Limit face setting to the
corresponding SUBEXP (interactively, the prefix argument) of REGEXP.
If SUBEXP is omitted or nil, the entire REGEXP is highlighted.

That means you can use FACE for which you may define foreground and
background.

To find some interesting face I did following:

{M-x list-faces-display RET}

then I found one like 'custom-invalid and did following:

(highlight-regexp "^;; \\[.*$" 'custom-invalid)

So that one 

;; [Highlights this line]

To define your special face:

(info "(elisp) Defining Faces")

Use the function `defface'. Here is example from Emacs library:

(defface ansi-color-black
  '((t :foreground "black" :background "black"))
  "Face used to render black color code."
  :group 'ansi-colors
  :version "28.1")

Now that means it should not be hard to replicate it and create your
own face with foreground and background and then to use the function
`highlight-regexp' as above shown or as:

(highlight-regexp "^;; \\[.*$" 'my-face)

-- 
Jean

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

In support of Richard M. Stallman
https://stallmansupport.org/



  parent reply	other threads:[~2022-12-10 19:44 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-10  2:42 Special hilighting for comments Heime
2022-12-10  6:12 ` Marcin Borkowski
2022-12-10  6:23   ` Heime
2022-12-10  8:13     ` Eli Zaretskii
2022-12-10  8:14 ` Eli Zaretskii
2022-12-10  8:30   ` Heime
2022-12-10  8:49     ` Eli Zaretskii
2022-12-10 10:53       ` Heime
2022-12-10 11:15         ` Eli Zaretskii
2022-12-10 11:26           ` Heime
2022-12-10 14:21             ` Eli Zaretskii
2022-12-10 14:28               ` Heime
2022-12-10 15:52             ` Jean Louis
2022-12-10 17:11               ` Heime
2022-12-10 17:16                 ` Eli Zaretskii
2022-12-10 17:39                   ` Heime
2022-12-10 17:57                     ` Thibaut Verron
2022-12-10 18:32                     ` Eli Zaretskii
2022-12-12  0:59                       ` Heime
2022-12-10 19:44                 ` Jean Louis [this message]
2022-12-11  2:10                   ` Heime
2022-12-11  2:37                     ` Heime
2022-12-11  4:23                       ` Jean Louis
2022-12-11  5:06                         ` Heime
2022-12-11  9:06                           ` Jean Louis
2022-12-11  6:54                       ` tomas
2022-12-11  6:59                         ` Heime
2022-12-11  7:24                           ` tomas
2022-12-11  7:33                             ` Heime
2022-12-11  7:47                               ` tomas
2022-12-11  7:52                                 ` Heime
2022-12-11  8:55                                   ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y5ThodMQ7x8ktgYG@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.