1. Frank Fischer
  2. evil
Issue #206 open

F<space> (evil-find-char-backward) triggers an error when holding Shift key

Alonso Andres
created an issue

I'm using Aquamacs, and an error is triggered when searching backwards for a space character while still holding the Shift key (i.e. I hold Shift to produce the uppercase F command, and keep holding Shift when I press the Space bar).

I do this quite a lot, so to me this was really annoying, as I had to remember to release the shift key before pressing space, while in vim it just works fine. :)

So I tried to patch it myself, and here is what I was able to come up:

diff --git a/evil-common.el b/evil-common.el
index aa5393c..d5d2089 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -573,6 +573,10 @@ Translates it according to the input method."
               (setq seq (read-key-sequence prompt nil t)
                     char (aref seq 0)
                     cmd (key-binding seq))
+              (if (not cmd)
+                (setq
+                  char (event-basic-type char)
+                  cmd (key-binding (vector char))))
               (while (arrayp cmd)
                 (setq char (aref cmd 0)
                       cmd (key-binding cmd)))

Explanation: when evil-read-key can't find a command when the user is using modifier keys (shift in my case), this patch tries to find the command for the "cleaned up" key, without any modifiers. This is done in event-basic-type, which will convert the "shift+space" char to just "space". So now the "shift+space" issue isn't happening anymore to me.

I'm not sure this is the best approach and if this would be configurable somewhere else in emacs... but anyway, I hope this patch is useful and if it's not, at least you know about this issue to hopefully make evil handle it nicely.

Thanks for this nice piece of work!

Comments (2)

  1. Log in to comment