* Dired - highlight the name of the directory in directory headers
@ 2020-11-18 16:56 Sebastian Tennant
2020-11-18 18:42 ` Michael Heerdegen
2020-11-18 23:08 ` Drew Adams
0 siblings, 2 replies; 4+ messages in thread
From: Sebastian Tennant @ 2020-11-18 16:56 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Dired - highlight the name of the directory in directory headers
@ 2020-11-18 17:45 Sebastian Tennant
0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Tennant @ 2020-11-18 17:45 UTC (permalink / raw)
To: help-gnu-emacs
Hello all,
I reached for a timer because I've been working with them recently
but, of course, using advice is aprroximately one hundred times
better:
(advice-add
'dired-mode :after
(lambda (&rest args)
(hi-lock-face-buffer "\\([^/]+\\):\n" 'bold 1))
'((name . highlight-directory-name-in-headers)))
I'd still love to know why adding an 'ordinary' function to
dired-mode-hook doesn't work.
sebyte
--
Dorothy Annan Trevor Tennant database - DATTdb
http://dattdb.info
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-18 23:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-18 16:56 Dired - highlight the name of the directory in directory headers Sebastian Tennant
2020-11-18 18:42 ` Michael Heerdegen
2020-11-18 23:08 ` Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2020-11-18 17:45 Sebastian Tennant
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.