emacs-evil / evil

The extensible vi layer for Emacs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help overriding only certain postfixs to "m"

leath-dub opened this issue · comments

Issue type

Question

Environment

Emacs version: 29.3
Operating System: Ubuntu 22.04

Graphical/Terminal: Graphical

Is there a way I can maintain marks behaviour for all keys but some exceptions like "f" for example, i.e I would like to bind "mf" to something while also maintaining normal marks behaviour for all other keys.

I have been able to get the work with rebinding 'motion and disabling "m" in normal mode, however can't for the life of me get it to work without disabling in normal mode

I think advice is the best thing here, as evil-set-marker doesn't use a keymap for the marker input, but rather just uses read-char so you can't selectively "rebind" in the usual way. Something like this would work:

(defun marker-overrides (fn &rest args)
  (pcase (car args)
    (?f (message "called f!"))
    ;; etc...
    (_ (apply fn args))))

(advice-add 'evil-set-marker :around #'marker-overrides)

I think advice is the best thing here, as evil-set-marker doesn't use a keymap for the marker input, but rather just uses read-char so you can't selectively "rebind" in the usual way. Something like this would work:

(defun marker-overrides (fn &rest args)
  (pcase (car args)
    (?f (message "called f!"))
    ;; etc...
    (_ (apply fn args))))

(advice-add 'evil-set-marker :around #'marker-overrides)

thank you so much ! I am only new to emacs.You can just wrap any function and add your own behavior, that's awesome!