Subject: bug#40714: Reinitialising the major mode disables which-function-mode.

From: Alan Mackenzie <[email-masked]>
Date: Sun, 19 Apr 2020 11:12:33 +0000

Hello, Emacs.

In a typical buffer, say an emacs-lisp-mode buffer, with
which-function-mode enabled and working, do

    M-x emacs-lisp-mode

.  which-function-mode is no longer working.

#########################################################################

The cause of this is that the enablement of w-f-m is stored in a buffer
local variable which-func-mode.  This local variable gets killed on
reinitialising the major mode.  There is nothing to set it to non-nil
again.

When visiting a file, which-func-mode gets set in a file-find-hook
function called which-func-ff-hook.

Suggested fix: Move which-func-ff-hook to after-change-major-mode-hook
(renaming it, of course).

-- 
Alan Mackenzie (Nuremberg, Germany).