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

super keybindings not working under windows #1375

Open
treopop opened this issue Jul 29, 2022 · 2 comments
Open

super keybindings not working under windows #1375

treopop opened this issue Jul 29, 2022 · 2 comments

Comments

@treopop
Copy link

treopop commented Jul 29, 2022

None of the super keybindings are being recognized by Emacs despite setting prelude-super-keybindings to t.
I found that adding the following lines to prelude-windows.el (just below the modifier keys section) resolves the problem:

(when prelude-super-keybindings
  (w32-register-hot-key [s-])
  (w32-register-hot-key [A-]))  ; same for Alt-Tab etc

This disables all Windows hotkeys except Win+L. Alternatively, it is possible to register only the ones that are used in Emacs. Not sure what the preference here is. Personally I don't like to have e.g. windows explorer pop up accidentally, but of course I can always override any more specific default settings in my personal folder.

Tested with Emacs 28.1 on Win11 (21H2)

@bbatsov
Copy link
Owner

bbatsov commented Jul 30, 2022

The super keybindings were mostly intended for macOS, to avoid conflicts with Windows global keybindings and the keybindings in most Linux desktops (like GNOME), that have similar keybindings to Windows making heavy use of the Win key.

I guess it makes sense to make them behave better on Windows now that there's a flag to enable/disable them. Or at least to document this better.

@treopop
Copy link
Author

treopop commented Jul 30, 2022

I agree, documenting it for windows users would already help. The main problem, at least for me, was that I expected it to work and couldn't quickly figure out why it didn't. However the current settings already do affect the Win key when pressed solely. The windows start menu doesn't open, which added to the confusion.

Also I realize that prelude so far requires Emacs 25.1 or newer, while w32-register-hot-key was only introduced with 26.1.

IMHO the best default settings are the ones that are least surprising. Here is an idea for the section in prelude-windows.el:

(when prelude-super-keybindings
  (if (version< emacs-version "26.1")
      (message "Super keybindings on Windows only available for Emacs 26.1 or newer")
    (progn
      ;; Teach Emacs how to interpret various modifier keys
      (setq w32-pass-lwindow-to-system nil)
      (setq w32-lwindow-modifier 'super) ; Left Windows key

      (setq w32-pass-rwindow-to-system nil)
      (setq w32-rwindow-modifier 'super) ; Right Windows key

      (setq w32-pass-apps-to-system nil)
      (setq w32-apps-modifier 'hyper) ; Menu/App key

      ;; register all prelude super hotkeys defined in prelude-mode.el
      ;; unused bindings like [s-e] still will open windows explorer
      (w32-register-hot-key [s-p])
      (w32-register-hot-key [s-r])
      ;; ...
      ;; maybe there is a way to do this without manually duplicating
      ;; the s- key bindings defined in prelude-mode.el?
      )))

To disable windows hot-keys completely while working in Emacs, I can put (w32-register-hot-key [s-]) in my personal settings.

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

No branches or pull requests

2 participants