When I use Emacs with Evil mode for some time, I sometimes get to a point, where I have no choice to what I want to delete when pressing d
(or calling evil-delete
). The current line gets deleted without that I have pressed d
for the line a second time. Same behavior is shown when pressing c
or calling evil-change
. Both are acting like having pressed dd
or cd
instead.
Certainly I have accidentally pressed some keyboard shortcuts to activate this mapping, but I have no clue how to find out what is happening there. At the moment my only chance is to restart Emacs to get back to normal behavior. If I only knew what happens, maybe I would be able to switch back to normal behavior without restarting Emacs.
Asked
Active
Viewed 1,250 times
11

Michael Dahl
- 111
- 5
-
2This sounds as if you have accidentally enabled capslock. You should be able to verify this with `F1 l`. The other option of debugging is instrumenting the relevant functions to log their internal state and inspect the log whenever running into that situation. – wasamasa Oct 05 '17 at 10:11
-
1@wasamasa I am sure, that I have not enabled capslock. Than even other keys would behave different from normal, which is not the case. Could you explain, how to log state in the relevant functions? I assume I have to edit the evil source for that? – Michael Dahl Oct 06 '17 at 09:14
-
1This happens to me in Spacemacs (develop branch) now and then. I have capslock remapped to control, so @wasamasa's hypothesis can't be correct. `F1 l` switches me to a different frame. The only solution I have found is to quit and restart emacs. – ken Jun 28 '18 at 22:12
1 Answers
16
I noticed the d key deleting a line on a single press as well. I am using Spacemacs v0.300.0@26.1 on the develop branch. I do not know if this is your case, but I had an incomplete search in progress.
Steps to reproduce:
- In command mode, initiate a search by pressing the / key
- With the mouse, click on any text in your buffer
- Press the d key a single time and a line will be deleted
Steps to resolve:
- With the mouse, click on your incomplete search
- Either cancel the search by pressing the DEL key until the search is cleared OR complete the search by pressing the RET key
- The behavior of the d key should return to normal (at least it did for me)
Update 2019-05-14
I stumbled upon a solution from @trey-jackson. For spacemacs users, plunking Trey's solution:
(defun stop-using-minibuffer ()
"kill the minibuffer"
(when (and (>= (recursion-depth) 1) (active-minibuffer-window))
(abort-recursive-edit)))
(add-hook 'mouse-leave-buffer-hook 'stop-using-minibuffer)
in .spacemacs
under dotspacemacs/user-config
seems to resolve the problem.

Lee Read
- 161
- 1
- 5
-
1Good catch! This appears to boil down to an unhandled case in `evil-operator-range` where it falls back to regular motions. Now, if you have any ideas how to detect this state, that would be nice. – wasamasa Mar 12 '19 at 07:56
-
Thanks @wasamasa, one work-around is to stop using the mouse! I am pretty new to emacs, so delving into evil code is beyond me right now. Is [this](https://github.com/emacs-evil/evil) the right place to raise an issue? – Lee Read Mar 30 '19 at 15:01
-