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.

  • 2
    This 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 5 '17 at 10:11
  • @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 6 '17 at 9:14
  • This 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

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:

  1. In command mode, initiate a search by pressing the / key
  2. With the mouse, click on any text in your buffer
  3. Press the d key a single time and a line will be deleted

Steps to resolve:

  1. With the mouse, click on your incomplete search
  2. Either cancel the search by pressing the DEL key until the search is cleared OR complete the search by pressing the RET key
  3. 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))

(add-hook 'mouse-leave-buffer-hook 'stop-using-minibuffer)

in .spacemacs under dotspacemacs/user-config seems to resolve the problem.

  • 1
    Good 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 7: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 the right place to raise an issue? – Lee Read Mar 30 '19 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.