Subject: Re: bug#56423: 29.0.50; Hi-lock in dired broken by toggling wdired-mode

From: Michael Heerdegen <[email-masked]>
Date: Wed, 06 Jul 2022 21:19:35 +0200

Michael Heerdegen <[email-masked]> writes:

> [...] and `font-lock-set-defaults' finds that
>
>   (derived-mode-p font-lock-major-mode)
>
> fails so that it recomputes the `font-lock-keywords' from the
> defaults.  I guess we could prevent that happening?

This patch seems to fix the issue.  Good idea?

From 26baa6c65e934b110499c77255c5c54a89acd116 Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <[email-masked]>
Date: Wed, 6 Jul 2022 21:16:19 +0200
Subject: [PATCH] WIP: Fix wdired vs. hi-lock Bug#56423

---
 lisp/wdired.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/wdired.el b/lisp/wdired.el
index a5858ed190..7c8969431f 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -261,6 +261,7 @@ wdired-change-to-wdired-mode
   (add-hook 'before-change-functions #'wdired--before-change-fn nil t)
   (add-hook 'after-change-functions #'wdired--restore-properties nil t)
   (setq major-mode 'wdired-mode)
+  (setq font-lock-major-mode 'wdired-mode)
   (setq mode-name "Editable Dired")
   (add-function :override (local 'revert-buffer-function) #'wdired-revert)
   (set-buffer-modified-p nil)
@@ -457,6 +458,7 @@ wdired-change-to-dired-mode
   (force-mode-line-update)
   (setq buffer-read-only t)
   (setq major-mode 'dired-mode)
+  (setq font-lock-major-mode 'dired-mode)
   (setq mode-name "Dired")
   (dired-advertise)
   (remove-hook 'kill-buffer-hook #'wdired-check-kill-buffer t)
--
2.30.2

TIA,

Michael.