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

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

Re: Dired - highlight the name of the directory in directory headers


From: Michael Heerdegen
Subject: Re: Dired - highlight the name of the directory in directory headers
Date: Wed, 18 Nov 2020 19:42:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Sebastian Tennant <sdt@sebyte.me> writes:

> Hello all,
>
> I thought it would be easy to highlight the name of the directory in
> directory headers in Dired buffers.  For example:
>
>   /home/bob/Notes:
>             ^^^^^
> My first approach was to use font-lock-add-keywords:
>
> (font-lock-add-keywords 'dired-mode '("\\([^/]+\\):\n" . (1 'bold)))
>
> but try as I might I could not get this to work.

One problem with your code is that `font-lock-add-keywords' expects a
_list_ of keywords.

I think it's also better to match the end of the line instead of the
newline char.

Dired uses this:

  (list dired-subdir-regexp '(1 dired-header-face))

I think it's best to start with that.  It has the advantage that it
doesn't accidentally match file names including a colon.

Michael.




reply via email to

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