hlissner / evil-snipe

2-char searching ala vim-sneak & vim-seek, for evil-mode
MIT License
336 stars 25 forks source link

Allow for customization of repeat keys #59

Closed NightMachinery closed 6 years ago

NightMachinery commented 6 years ago

I am using Spacemacs, and here the default search keys are n and N. I am using this workaround in the meantime:

  (setq evil-snipe-override-local-mode-map
    (let ((map (make-sparse-keymap)))
      (evil-define-key* 'motion map
                        "f" #'evil-snipe-f
                        "F" #'evil-snipe-F
                        "t" #'evil-snipe-t
                        "T" #'evil-snipe-T)
      (when evil-snipe-override-evil-repeat-keys
        (evil-define-key* 'motion map
                          "n" #'evil-snipe-repeat
                          "N" #'evil-snipe-repeat-reverse))
      map))

  (setq evil-snipe-parent-transient-map
    (let ((map (make-sparse-keymap)))
      (define-key map "n" #'evil-snipe-repeat)
      (define-key map "N" #'evil-snipe-repeat-reverse)
      map))

Is this workaround safe, BTW? I load it in my init.el, and it works.

hlissner commented 6 years ago
      (when evil-snipe-override-evil-repeat-keys
        (evil-define-key* 'motion map
                          "n" #'evil-snipe-repeat
                          "N" #'evil-snipe-repeat-reverse))

This bit may be more destructive than you intended. It will overwrite the default commands bound to n/N if you use evil-snipe-override-mode, effectively replacing whatever Spacemacs binds to n/N (or evil-ex-search-next/evil-ex-search-previous; which are evil's defaults).

I think binding n/N in evil-snipe-parent-transient-map should be good enough, however, these keys are only available directly after a snipe.

Hope that helps!