ch11ng / exwm

Emacs X Window Manager
2.85k stars 134 forks source link

Selecting text by combining line-editing commands with shift in exwm-input-set-simulation-keys doesn't seem to work #713

Open nhmacuk opened 4 years ago

nhmacuk commented 4 years ago

Combining (working) expressions with shift in exwm-input-set-simulation-keys as below, results in the key combination to not work. For example, for C-S-left, which-key reports: "". Changing to "C-LEFT" also does not seem to work (inspired by https://github.com/ch11ng/exwm/issues/474). All other expressions work as desired, including expressions which include shift such as ([?\C-\S-i] . [S-tab]).

            ([?\C-v] . [next])
            ([?\C-\S-v] . [S-next])
            ([?\C-p] . [C-up]) ;; [up] was changed to [C-up] to work with evil-mode
            ([?\C-\S-p] . [C-S-up])
            ([?\C-n] . [C-down])
            ([?\C-\S-n] . [C-S-down])
            ([?\C-g] . [escape])
            ([?\M-<] . [C-home])
            ([?\M-\S-<] . [C-S-home])
            ([?\M->] . [C-end])
            ([?\M-\S->] . [C-S-end])
            ([?\C-b] . [left])
            ([?\C-\S-b] . [S-left])
            ([?\C-f] . [right])
            ([?\C-\S-f] . [S-right])
            ([?\C-a] . [home])
            ([?\C-\S-a] . [S-home])
            ([?\C-e] . [end])
            ([?\C-\S-e] . [S-end])
            ([?\M-v] . [prior])
            ([?\M-\S-v] . [S-prior])
            ([?\C-d] . [delete])
            ([?\C-k] . [S-end delete])
            ([?\C-m] . [return])
            ([?\C-\S-m] . [S-return])
            ([?\C-i] . [tab])
            ([?\C-\S-i] . [S-tab])
            ([?\M-w] . [?\C-c])
            ([?\C-w] . [?\C-x])
            ([?\C-2] . [?\C-w])
            ([?\C-y] . [?\C-v])
            ([?\C-?] . backspace) ;; changed earlier
            ([?\C-/] . [?\C-z])
            ([?\C-s] . [?\C-f])
            ([?\M-f] . [C-right])
            ([?\M-b] . [C-left])
            ([?\M-\S-f] . [C-S-right])
            ([?\M-\S-b] . [C-S-left])
            ([?\M-d] . [C-S-right delete])
ch11ng commented 4 years ago

([?\M-\S-b] . [C-S-left])

The problem is probably with [?\M-\S-b]. It should be [?\M-B]. Please try the method in https://github.com/ch11ng/exwm/issues/712#issuecomment-586693398.

nhmacuk commented 4 years ago

It seems that the INS button from the easy customisation as described in https://github.com/ch11ng/exwm/issues/712#issuecomment-586693398 seems missing for me: image .

M-x exwm-input-set-simulation-key does seem to work! If possible it would be nice to be able to use either the form of the easy customisation, or the configuration within the .init file.

Changing the shift + line commands to below doesn't seem to work:

([?\C-V] . [S-next])
             ([?\C-P] . [C-S-up])
             ([?\C-N] . [C-S-down])
             ([?\C-B] . [S-left])
             ([?\C-F] . [S-right])
             ([?\C-A] . [S-home])
             ([?\C-E] . [S-end])
             ([?\M-V] . [S-prior])
             ([?\M-F] . [C-S-right])
             ([?\M-B] . [C-S-left])

Also, how would that translate other (already "shifted") keys such as the '<' and '>'?

             ([?\M-\S-<] . [C-S-home])
             ([?\M-\S->] . [C-S-end])
ch11ng commented 4 years ago

Not sure why the buttons are missing. Which version of Emacs were you using?

Changing the shift + line commands to below doesn't seem to work

Which one(s)?

Also, how would that translate other (already "shifted") keys such as the '<' and '>'?

You can try evaluating (key-description (list (read-key))) followed by some key whenever you feel unsure. In this case, it's M-\< instead of M-S-\<.

nhmacuk commented 4 years ago
ch11ng commented 4 years ago

I just realized you didn't expand that entry. Click the leading small triangle and it'll show you everything I mentioned.

  • All of them it seemed back then, but I as soon as possible. Would I need to test them one-by-one (like by commenting out the ones I am not testing) or would that be unnecessary?

Usually keybindings don't interfere with each other so that's not necessary.

nhmacuk commented 4 years ago

Ah, I think it's because I already filled in the form by writing the config in my init file. It seems the separate fields to fill in disappeared because of that: image I will untangle my config in my init.org and see if the fields appear and will fill them according to my init.org's exwm-input-set-simulation-keys config. Would be nice to get it to work from within the init file too.

nhmacuk commented 4 years ago

My work-around atm is to manually insert my key through the prompt from exwm-input-set-simulation-key and then copy the code generated in the customize-buffer into my dot file.

medranocalvo commented 4 years ago

Hmm... I'm not sure if that's alright. I mean, it's fine but not optimal.

Have you tried the trick @ch11ng proposed?

(key-description (list (read-key)))

It seems to work fine here.

I think we should add it to the Wiki.

ch11ng commented 4 years ago

It seems key representation is where most users get stuck when configuring EXWM. But it's standard in Emacs and we probably should not reinvent something else. We already have this in the wiki:

Besides, it's rather simple to find the representation of a key event by evaluating (read-key) or (read-event) when you are not sure.

Any ideas how to improve it?

nhmacuk commented 4 years ago

Hey, yes I tried that, but sadly when entering the names printed after issuing (key-description (list (read-key))) doesn't give me the expected result. The numeric codes generated by the prompt do somehow however. It seems to me that the numeric codes and the names don't completely match up.

medranocalvo commented 4 years ago

@nhmacuk, the result of that command must be passed to the kbd macro.

(setq exwm-input-simulation-keys
    `(([?\C-b] . [left])
      (,(kbd "M-B") . [whatever])))       

Note the quasi-quote (backtick and comma).

@ch11ng, I'll think about it.

Vivien-lelouette commented 2 years ago

Hello,

I found this post when trying to implement Emacs-like binding using simulation keys.

I had kind of a hard time to figure out the "alt-shift-b" or "alt-shift-f" binding.

I now have a working setup, so as I found this issue quite easily during my searches here is my current setup:

(setq exwm-input-simulation-keys
    '(
      ([?\M-b] . [C-left])
      ([?\M-f] . [C-right])
      ([?\C-b] . [left])
      ([?\C-f] . [right])
      ([?\C-p] . [up])
      ([?\C-n] . [down])
      ([?\C-a] . [home])
      ([?\C-e] . [end])

      ([?\M-B] . [C-\S-left])
      ([?\M-F] . [C-\S-right])
      ([?\C-\S-b] . [S-left])
      ([?\C-\S-f] . [S-right])
      ([?\C-\S-p] . [S-up])
      ([?\C-\S-n] . [S-down])
      ([?\C-\S-a] . [S-home])
      ([?\C-\S-e] . [S-end])

      ([?\C-s] . [?\C-f])
      ([?\C-x ?\C-s] . [?\C-s])
      ([?\M-v] . [prior])
      ([?\C-v] . [next])

      ([?\M-d] . [C-delete])
      ([?\C-d] . [delete])
      ([?\C-k] . [S-end ?\C-x])

      ([?\C-y] . [?\C-v])
      ([?\M-w] . [?\C-c])
      ([?\C-w] . [?\C-x])
      ([?\s-g] . [escape])))

Note that the last "super-g" binding might not be useful to everybody.

I think this kind of setup should be documented in the wiki. The current exemple is too simple for new Emacs/EXWM users :).