Issue #279 invalid

Evil command . repeats wrong commands

epich
created an issue

Use the Emacs config below. Input some text in a file. Hit . command to verify it works. Next execute the or command. Now when I use . again, no insertion is made. Actually what . is executing is revert-buffer again, even though I defined it as a motion.

(add-to-list 'load-path "~/.emacs.d/evil") ; only without ELPA/el-get
(require 'evil)
(evil-mode 1)
(setq revert-without-query (quote (".*")))
(define-key evil-normal-state-map "o" nil)
(define-key evil-visual-state-map "o" nil)
(define-key evil-motion-state-map "or" 'revert-buffer)

Comments (4)

  1. Frank Fischer repo owner

    Putting something in the evil-motion-state-map is not sufficient to declare it as a motion. In fact, revert-buffer is barely a motion, so I would put it in normal state map.

    Anyway, the correct way to modify a command's repeat-behavior is to use one of the evil-declare-* functions (where * is motion, repeat, not-repeat, ignore-repeat, change-repeat, insert-at-point-repeat, abort-repeat). The best choice in this case should be (evil-declare-abort-repeat 'revert-buffer), I think, which cancels any currently active recording process (i.e. in normal state the command is not repeated, if called from insert state then the current recording is aborted).

  2. epich reporter

    In fact, revert-buffer is barely a motion, so I would put it in normal state map.

    revert-buffer makes less sense in evil-normal-state-map because it means something in Dired, which initializes to the motion state for me.

    Putting something in the evil-motion-state-map is not sufficient to declare it as a motion.

    I don't want it to be a motion, I want the key binding to be available in buffers that initialize to motion state.

  3. Frank Fischer repo owner

    Fair enough, but putting something in motion map is still not sufficient to declare it a motion and that was my point ;)

    Of course, if you have a good reason for revert-buffer being in motion state map, then that's okay.

  4. epich reporter

    I found (evil-declare-ignore-repeat 'revert-buffer) gives the behavior I expect. I suppose I'll do that for all the commands I add to evil-motion-state-map. I wonder if other users will stumble on this gotcha when adding commands to evil-motion-state-map.

    Thanks for your help!

  5. Log in to comment