god-mode
god-mode copied to clipboard
god-mode does not work with "un-initialized" `projectile-mode-map`
Until projectile-mode-map
prefix binding (e.g. C-c p p
) has been called manually (i.e. without god-mode) at least once, the calling the enhanced binding with god-mode enabled (i.e. c SPC p p
) does not work.
Once the prefix binding has been entered manually (without using god-mode) at least once, then calling it from god-mode with the enhanced binding starts to work too.
Choosing and executing one of the subcommands in the projectile-mode-map
is not even necessary, it is enough to just enter the prefix binding (e.g. C-c p p
) and then terminate the minibuffer with C-g
.
This supersedes issue #155 I've opened/closed before.
It depends on how you initialise God mode.
As mentioned in the README, calling the god-mode
function only affects future buffers.
To change both active and future buffers, you should call god-mode-all
instead on loading your emacs configuration.
I do use god-mode-all
, with the binding set.
The issue happens once Emacs is initialised, then I turn god-mode on using the binding.
After this the indicators show that god-mode is turned on, yet c SPC p p
does not do anything.
Interestingly, if I add god-mode-all
to the emacs-init-hook
, god-mode does not get turned on after initialised.
Sorry, I can't seem to recreate this, although I'm using after-init-hook
.
Calling god-mode-all
through after-init-hook
, or through doom-after-modules-config-hook
if you're using Doom Emacs, works fine.
I can use the c SPC p
prefix to call any projectile functions as soon as my Emacs starts up.
Would it be possible to share your Emacs config?
I can't find anything related to God mode in your .emacs.d
repository.
Apologies, realised my github didn't contain the config I was working with.
Here is the version which reproduces the problem for me. The god-mode
version in my config uses the latest commit 607aff1
.
Also, I've disabled doom-modeline
, but the problem still remains.
Since I am not using Doom Emacs, only the individual doom-modeline
package, I don't have a doom-after-modules-config-hook
.
Regarding the after-init-hook
problem: I've accidentally added the -hook
suffix in my use-package
declaration. After fixing it, god-mode
is indeed enabled on startup. Yet, this doesn't resolve the problem with the projectile
key-map binding.
Actually, I've encountered another issue.
For some reason enabling god-mode on startup using the after-init-hook
, causes the god-mode-enable-function-key-interaction
to be ignored. Even though I've set it to be nil
, when I try to press F11
after startup, I get the message: God: Unknown key binding for ‘C-<f11>‘
.
The behaviour is present in my earlier config.
If I remove god-mode from the after-init-hook
, then F11
works fine.
or some reason enabling god-mode on startup using the
after-init-hook
, causes thegod-mode-enable-function-key-interaction
to be ignored. Even though I've set it to benil
, when I try to pressF11
after startup, I get the message:God: Unknown key binding for ‘C-<f11>‘
.
Just had a quick look, and it looks like you're setting god-mode-enable-function-key-interaction
too late.
Try setting it in the :init
part of use-package
, instead of in :custom
.
I've not yet investigated the issue with projectile and God mode. I'll get to that soon, but if you find anything, please post on this issue.
I've also tried using emacs-startup-hook
instead of after-init-hook
, which claims to be run later, and starts god-mode correctly, yet still captures the F11 key.
When I don't automatically start god-mode with either of the hooks, then setting god-mode-enable-function-key-interaction
using :custom
works fine, and F11 key registers correctly.
Uh, oh... just noticed somehow I've been using the wrong name for the function-key option!
It is named god-mode-enable-function-key-translation
, not -interaction
.
It seems I didn't notice the issue, because I usually press F11
as the first thing on my Emacs startup, and since I used the wrong hook, god-mode didn't get enabled on initialization... so F11
was working fine. But when I manually started god-mode afterwards, it turned out that function key translation wasn't disabled (because I was setting the wrong variable).
Sorry, my bad!
Not a problem.
So the F11
issue is not a bug, but you're still having a problem calling projectile functions on start-up from what I understand?
Yes, indeed. The issue with initializing projectile key-binding still exists.
Okay, looking at your config, it's because projectile key bindings aren't exposed through your package configuration that uses :bind-keymap
.
Can you try this config for projectile and let me know if you're still having the issue?
(use-package projectile
:hook
(projectile-grep-finished . (lambda () (pop-to-buffer next-error-last-buffer)))
:bind-keymap
("C-c p" . projectile-command-map)
:init
(require 'projectile)
:config
(dolist (dir (list "node_modules" "target"))
(add-to-list 'projectile-globally-ignored-directories dir))
(projectile-mode))
This is sort of what Doom Emacs does too.
I don't understand. My config is exactly the same as what you wrote.
Haha not exactly.
There's a call to (require 'projectile)
you're missing.
I copied your config and added these lines:
(use-package projectile
:hook
(projectile-grep-finished . (lambda () (pop-to-buffer next-error-last-buffer)))
:bind-keymap
("C-c p" . projectile-command-map)
+ :init
+ (require 'projectile)
:config
(dolist (dir (list "node_modules" "target"))
(add-to-list 'projectile-globally-ignored-directories dir))
(projectile-mode))
Adding the :init (require 'projectile)
doesn't seem to solve the issue for me.
This seems to have solved it though:
(use-package projectile
:demand t
:hook
(projectile-grep-finished . (lambda () (pop-to-buffer next-error-last-buffer)))
:bind
("C-c p" . projectile-command-map)
:config
(dolist (dir (list "node_modules" "target"))
(add-to-list 'projectile-globally-ignored-directories dir))
(projectile-mode))
The difference is that I've used :bind
instead of :bind-keymap
, and added the :demand t
.
Not sure I understand what benefit :bind-keymap
gives over plain :blind
, but it seems the fact that it tries to do funny things, with loading the keymap and then using the binding again as prefix argument, could interfere with god-mode? At any rate, with :bind
the behaviour is more straightforward, such that the :demand
flag can circumvent the delayed loading.
...not sure how you've added those nice highlights on your code examples though! ;)
Still, it might worth looking into why god-mode
does not work well with use-package
's :bind-keymap
option.