ch11ng / exwm

Emacs X Window Manager
2.85k stars 134 forks source link

One keypress redirected to emacs after opening a prompt from emacsclient #253

Open Stebalien opened 7 years ago

Stebalien commented 7 years ago

After running the following from a normal terminal emulator:

emacsclient -e '(read-string "prompt: ")'

exwm-input--during-command will remain true causing EXWM to redirect the next keypress to emacs (instead of sending it to the terminal emulator).

ch11ng commented 7 years ago

The command didn't create a new terminal/frame so it had to use an existing one. Perhaps you should use emacsclient -t -e '(read-string "prompt: ")' instead.

Stebalien commented 7 years ago

Ah, sorry, I meant: After running..., and then hitting enter to close the prompt, EXWM redirects the next keypress to Emacs instead of to the focused X window.

Basically, I'm using emacs as an askpass, dmenu, and zenity replacement so I want to use the existing frame.

QiangF commented 7 years ago

@Stebalien How do you send the string to X window, can you share your settings? You may be interested with https://github.com/carnager/rofi-pass.

Stebalien commented 7 years ago

@QiangF I'm not; I'm just trying to prompt the user for input using emacs. For example, here's my dmenu replacement:

https://gist.github.com/e1eb4b167757a0fe171b857ccc1478b3

ch11ng commented 7 years ago

Usually pre-command-hook / post-command-hook is run before/after a command is invoked. But in this case post-command-hook is not after exit-minibuffer is invoked which causes the problem. This is quite strange.

Stebalien commented 7 years ago

It also looks like the command loop never resets this-command to nil (it stays as exit-minibuffer). For now, I've just removed all exwm-input--during-command logic because it seems to work for me (but that's obviously not a real solution. Hopefully I'll get around to reporting this upstream sometime soon.

Stebalien commented 7 years ago

Ok, that breaks y-or-n-p. A better work around is to replace the exwm-input--during-command check with (and exwm-input--during-command (null (eq real-this-command 'exit-minibuffer))).

ch11ng commented 7 years ago

It might have something to do with recursive editing. Actually it's not mandatory or recommended to use pre-command-hook/post-command-hook to detect whether Emacs is executing a command. If someone comes up with a better solution, we'll surely adopt that.

Stebalien commented 7 years ago

Unless I'm mistaken, you should be able to check this-real-command but that doesn't work fix this because it never gets set back to nil after executing exit-minibuffer (hence my workaround). Am I misusing that variable?

ch11ng commented 7 years ago

I think I tried real-this-command before but I can't recall why I didn't use that. real-this-command not get reset seems to be a bug.