emacs-bind-map
emacs-bind-map copied to clipboard
Ensure overriding minor mode is enabled in the correct buffer
Hook onto window-state-change-functions instead of buffer-list-update-hook, since the latter does not guarantee that a just-created buffer is actually current. So, a command like the following would create, display, and select a buffer wherein the ensure-override-mode-func is never executed:
(defun display-results ()
(interactive)
(let ((buffer (get-buffer-create "*results*")))
(with-current-buffer buffer
(insert "I ran a command, and here are the results..."))
(display-buffer buffer '(display-buffer-same-window))))
This change also has the nice side benefit of skipping the hook if a buffer is never displayed, or the window displaying it is never selected.