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

Modifier prefix (like C-M-) #179

Open
Kungsgeten opened this issue Jan 5, 2020 · 4 comments
Open

Modifier prefix (like C-M-) #179

Kungsgeten opened this issue Jan 5, 2020 · 4 comments
Milestone

Comments

@Kungsgeten
Copy link

Hi! I'm trying out switching from bind-key to general in my Emacs config. I use a keyboard with QMK firmware, which basically lets the keyboard do all sort of crazy things. One thing I have is something called the "Meh key", which is a single key that simulates holding C-M-S when held down. Since I tend to forget which keys it actually simulates, I've written this in my init:

(defun meh (string)
  "Add the meh key prefix to STRING."
  (concat "C-M-S-" string))

Which I then can run like this:

(general-define-key
   (meh "f") 'projectile-next-project-buffer)

I just wondered if there's a more elegant way to do this, for instance with general-create-definer?

@noctuid
Copy link
Owner

noctuid commented Jan 8, 2020

It's been on my todo list for a while to have :prefix support this directly. You could write a macro to go through all the keys and add the prefix to them, but there's not a better alternative currently. I'll try to look into it sometime next week; feel free to ping me after that as I may forget.

@noctuid
Copy link
Owner

noctuid commented Jan 24, 2020

I'm thinking about the best syntax for this. I can't just treat `:prefix "C-M-S-" as a modifier since it could also be those letters and hyphens. I'm thinking one of these:

(general-def
  :prefix '("C-M-S-" :modifier t)
  "f" #'projectile-next-project-buffer)

(let ((general-prefix-ending-in-hypen-is-modier t))
  (general-def
    :prefix "C-M-S-"
    "f" #'projectile-next-project-buffer))

The variable could be set globally or around a general-create-definer and would treat letters followed directly by hyphens as modifiers (e.g. "-" and "-a" and "C -" would not be considered modifiers). Any preference?

@noctuid noctuid added this to the 2.0 milestone Jul 2, 2021
@noctuid noctuid mentioned this issue Jul 2, 2021
@Kungsgeten
Copy link
Author

Just made some changes to my init and checked if there had been any updates here :) From a user perspective I think something like this would be nice:

(general-create-definer meh
  :modifier "C-M-S")

Maybe prefix-command and prefix-map could be supported too (or have modifier variants).

@noctuid
Copy link
Owner

noctuid commented Nov 22, 2021

I will use this feature too, but it's not high priority for me. I think it will still be a little complicated with another keyword. I'm not planning on adding support until #497 (not anytime soon) but will accept a PR for it if anyone wants to make one.

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

No branches or pull requests

2 participants