hlissner / evil-snipe

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

having different scope for `f` and `t` #63

Open liujoey opened 6 years ago

liujoey commented 6 years ago

Hello,

Is there anyway to set scope to visible for s/S, while still using scope line for f/t/F/T? Thank you.

hlissner commented 6 years ago

Not natively, but I believe you could manage it with:

(defun restrict-to-line-scope (orig-fn &rest args)
  (let ((evil-snipe-scope 'line))
    (apply orig-fn args)))
(advice-add #'evil-snipe-f :around #'restrict-to-line-scope)
(advice-add #'evil-snipe-F :around #'restrict-to-line-scope)
(advice-add #'evil-snipe-t :around #'restrict-to-line-scope)
(advice-add #'evil-snipe-T :around #'restrict-to-line-scope)

I'm working on a rewrite of evil-snipe (it was written when I was still new to Elisp). I'll find a way to work this into it.

liujoey commented 6 years ago

Thank you.

Deewiant commented 5 years ago

Note that such advice doesn't propagate through to ; and , even if you set evil-snipe-repeat-scope in it as well. If you want to have a different evil-snipe-repeat-scope for f/t/F/T as well, I think you have to write a different advice function for evil-snipe-repeat that looks at the internal evil-snipe--last variable to determine the scope properly when repeating.