binding to "cp" without breaking "c"
monnier at iro.umontreal.ca
Thu Jun 19 04:12:07 CEST 2014
>> I'm very much not familiar with Evil, so this may be completely
>> inapplicable, but an option might be to do the following:
>> - don't bind `c' to `evil-change'.
>> - instead, add various `c <foo>' bindings, to `evil-change' and change
>> it so it uses last-command-event or this-single-command-keys to know
>> which binding triggered it (instead of using something like
>> `read-event' to wait for the next event).
> This approach has some disadvantages:
> * a count after the operator but before the motion would not work
> anymore (something like c2w)
Not sure how ugly it would end up, indeed.
But you could very well handle it with something like:
(define-key map "c" operator-arg-map)
(let ((map (make-sparse-keymap)))
(dotimes (i 10)
(define-key map (vector (+ i ?0)) map))
(define-key map [?w] 'my-command)
(defun my-command (keys)
(interactive (list (this-single-command-keys)))
... analyze keys to extract the count and the motion...
It would probably introduce other changes to the behavior that you
didn't intend, and such "recursive maps" are sufficiently rare that you
might bump into Emacs bugs, so yes... not necessarily a good idea.
OK, going back to lurk mode before I start rambling about set-transient-map.
More information about the implementations-list