Subject: 29.0.50; Hi-lock in dired broken by toggling wdired-mode

From: Michael Heerdegen <[email-masked]>
Date: Wed, 06 Jul 2022 18:22:36 +0200

Hello,

in a dired buffer, M-x hi-lock-face-buffer RET and enter a pattern so
that there are matches.  Then M-x wdired-change-to-wdired-mode and edit
something (insert a char or so).  Hi-Lock highlighting immediately
disappears.  Changing back to normal dired doesn't let highlighting
reappear.  That's not good.  I would like highlighting to stay when
starting or finishing `wdired-mode'.

The (only) reason for this is that when toggling `wdired-mode' the
hi-lock pattern rules added to `font-lock-keywords' are gone (why?).

So this fixes the problem for me:

#+begin_src emacs-lisp
(defun my-wdired-run-font-lock-mode-hook (&rest _)
  "Necessary to get hi-lock survive toggling `wdired-mode'."
  (run-hooks 'font-lock-mode-hook))

(dolist (f `(,#'wdired-change-to-wdired-mode
             ,#'wdired-finish-edit
             ,#'wdired-abort-changes))
  (advice-add f :after #'my-wdired-run-font-lock-mode-hook))
#+end_src

Running `hi-lock-font-lock-hook' instead of the complete
`font-lock-mode-hook' also works.

I would like to know why this is necessary at all, and what a correct
fix that can be installed would look like.

TIA,

Michael.

In GNU Emacs 29.0.50 (build 14, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
 of 2022-07-06 built on drachen
Repository revision: b2df1cc19c2312b27f7bab6b3eb7d339f668113d
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)