Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customisation to disable sticky god-literal-key #135

Open
doneself opened this issue Oct 21, 2021 · 10 comments
Open

Add customisation to disable sticky god-literal-key #135

doneself opened this issue Oct 21, 2021 · 10 comments

Comments

@doneself
Copy link

when i type "x space 4 j", get the message "god-mode-lookup-command: God: Unknown key binding for ‘C-x 4 j‘"
what did I do wrong?

dired-jump-other-window is an autoloaded interactive compiled Lisp
function in ‘dired-x.el’.

It is bound to C-x 4 C-j.

@darth10
Copy link
Collaborator

darth10 commented Oct 21, 2021

Hi @doneself!
xSPC4j actually translates to C-x4j due to sticky literal key behaviour which uses SPC by default.
If you want to disable this behaviour, set god-literal-key to nil in your configuration.

(setq god-literal-key nil)

@doneself
Copy link
Author

When the value of god-literal-key is set to nil, i don't know how to use god-mod to execute the command (dired-jump-other-window). Because dired-jump-other-window is bound to C-x 4 C-j.

@darth10
Copy link
Collaborator

darth10 commented Oct 21, 2021

Ah yes, my bad.
There needs to be some indirection to disable sticky literal key behaviour then.
Would that work for you? If yes, I can implement that fairly quickly.

I suppose a temporary workaround would be to bind dired-jump-other-window to C-x4j.

@darth10 darth10 changed the title when i type "x space 4 j", result key binding is ‘C-x 4 j‘ Add customisation to disable sticky god-literal-key Oct 21, 2021
@darth10 darth10 removed the question label Oct 21, 2021
@doneself
Copy link
Author

OK, thank you for your help and guidance.

@darth10
Copy link
Collaborator

darth10 commented Oct 21, 2021

I've given this a bit of thought, and there are a couple options to help users with similar key bindings.
C-x4C-j has a modifier key (C-) that's used in a key sequence after a key without a modifier key (4), but it's still a valid key sequence and doesn't break key binding conventions.

We could define a customisation to either:

  • Toggle sticky literal key if the literal key is entered again
    (xSPC4SPCjC-x4C-j), or
  • Disable sticky literal key behaviour altogether, so that the literal key only applies to the first subsequent key
    (xSPC4jC-x4C-j).

I'll leave this open for folks to discuss what the best option would be to implement in God mode.

@doneself
Copy link
Author

doneself commented Oct 22, 2021 via email

@federkamm
Copy link

I could adopt to a toggling god-literal-key equally well as to a non-sticky one, but without beeing able to enter either of C-x x C-x or C-x x x, god-mode would be pretty much broken for me :-(

For now, I fix this for me with the non-sticky version, since that's what's easier for me to do from within my config file with:

(defun advice/god-mode-clear-literal-sequence-flag (&rest _)
  (setq god-literal-sequence nil))
(advice-add 'god-key-string-after-consuming-key :before
            #'advice/god-mode-clear-literal-sequence-flag)

@viniciussbs
Copy link

I like the idea of pressing SPC again to toggle sticky behavior. Another suggestion: let the user map a second key for a non-sticky version of SPC. E.g: ,. So:

  • x SPC 4 SPC jC-x 4 C-j
  • x , 4 jC-x 4 C-j

This would attend @doneself . And also @federkamm, see:

  • x , x xC-x x C-x
  • x SPC x xC-x x x

I think this second non-stick key should not be defined be default, letting the user define it if they want.

What do you think?

@darth10
Copy link
Collaborator

darth10 commented Feb 27, 2023

Another suggestion: let the user map a second key for a non-sticky version of SPC. E.g: ,.

Thanks for chiming in, @viniciussbs!
That's a good option, with the caveat that they can't enter bindings with ,/C-,.
I'm slightly inclined to implement pressing SPC again toggles the sticky literal key.

@federkamm
Copy link

federkamm commented Aug 13, 2023

I came back here to see if anything happened since. I also like the idea best to make SPC toggle the sticky behavior because it would be a non-breaking change. I wouldn't need a non-sticky literal key alternative, then.

As far as I can tell, this would only requires to change the t in (setq god-literal-sequence t) in line 316 in function god-key-string-after-consuming-key to (not god-literal-sequence).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants