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

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

Dired - highlight the name of the directory in directory headers


From: Sebastian Tennant
Subject: Dired - highlight the name of the directory in directory headers
Date: Wed, 18 Nov 2020 16:56:24 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

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.

I then thought I would add a function to dired-mode-hook:

 (defun highlight-directory-name-in-headers ()
   (hi-lock-face-buffer "\\([^/]+\\):\n" 'bold 1))
 (add-hook 'dired-mode-hook 'highlight-directory-name-in-headers t)

but that didn't work either.

In the end, I got the mode hook to 'work' by delaying the call to
hi-lock-face-buffer:

 (defun highlight-directory-name-in-headers ()
   (run-at-time
    0.1 nil 'hi-lock-face-buffer "\\([^/]+\\):\n" 'bold 1))

but this is an ugly kludge if ever I saw one.

How should it be done?

sebyte
-- 
Dorothy Annan Trevor Tennant database - DATTdb
http://dattdb.info



reply via email to

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