The change-major-mode-hook
appears to be running after the new major mode has already been enabled. How would one go about running a function just before the change of major mode occurs?
Example: A buffer with major-mode-abc
has minor-mode-xyz
active, and that minor-mode is responsible for placing certain overlays. When changing to major-mode-def
, it is necessary to execute the function remove-overlays
if minor-mode-xyz
was active prior to changing major modes. The new major-mode-def
also activates minor-mode-xyz
again and immediately draws new overlays (this is a good thing); however, those new overlays (that I wanted to keep) get erased by the 'change-major-mode-hook 'remove-overlays nil t
. I would rather that that the remove-overlays
function be run with a hook associated with minor-mode-xyz
, rather than as part of enabling major-mode-def
.