By design, the fundamental-mode
is bare bones as other major modes are supposed to derive from this one.
From the info page (elisp) Major Modes
, we have:
This is the major mode command for Fundamental mode. Unlike other mode commands, it does not run any mode hooks (*note Major Mode Conventions::), since you are not supposed to customize this mode.
For that reason,
- We do not have a
fundamental-mode-hook
. - Also
my-minor-mode
does not get enabled ONLY in this major mode buffers inspite of having(global-my-minor-mode 1)
in my config.
Below would work but only if I manually typed M-x fundamental-mode
:
(add-hook 'after-change-major-mode-hook #'my-minor-mode)
It does not help in the below case where a fundamental-mode
buffer (*abcd*) is created by default:
(with-current-buffer (get-buffer-create "*abcd*")
(insert "Hello world"))
Why I want to enable a minor mode in fundamental-mode
?
I like to keep my custom key bindings in my minor mode map. I have this minor mode enabled globally (but it does not get enabled only in fundamental-mode
buffers).
Here's a use case that made this ask this question here. On doing M-x esup
(esup
package), it creates an *esup-log*
buffer with fundamental-mode
as its major mode. But each time I need to enable my minor mode manually in it to use my convenient bindings.
I'd like to enable my-minor-mode
in a truly global fashion, fundamental-mode
or not.
Update 1:
Here is my minor mode definition: modi-mode
.
Update 2:
Based on @npostavs' comment, I reviewed what's different between my minor mode modi-mode
and override-global-mode
in use-package/bind-key.el
. And it turns out that the init value of my mode is nil
and that of override-global-mode
is t
.
If I change the init value of my mode to t
, it too gets enabled in the fundamental-mode buffers! But the act of (global-modi-mode 1)
does not end with the same result. Is that odd? Probably a bug?
fundamental-mode
buffers for me, so perhaps the problem is in your mode's definition.override-global-mode
use-package
implements that.nil
; but I do enable it globally.buffer.c
, it looks likeget-buffer-create
runs thebuffer-list-update-hook
at the very end of its function, perhaps you could attach your own function with conditions to that hook?