hlissner / evil-snipe

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

Prevent rebinding `s` in Info-mode #48

Closed jlee-made closed 6 years ago

jlee-made commented 7 years ago

When I enable evil-snipe and then C-h i, I find that info's usual s binding to search now starts evil-snipe instead. I want to keep the old binding in that mode.

I'm not able to work around that using Info-mode-hook to call turn-off-evil-snipe-override-mode and/or turn-off-evil-snipe-mode either. However, using those functions interactively after entering info, I can use the s binding again.

Can you provide some way to keep that old binding?

I was able to reproduce this using emacs 25.1 and no configuration other than basically pointing emacs at where my elpa packages is on disk, then enabling evil and evil-snipe.

hlissner commented 7 years ago

Sorry for the late reply. Does this fix your problem?:

(add-to-list 'evil-snipe-disabled-modes 'Info-mode)

jlee-made commented 7 years ago

I beat you in slow response :-)

It didn't help, unfortunately. Are you able to reproduce? As I say, I could reproduce just by enabling evil and evil-snipe after starting with -q. Do you not see the problem if you try that?

hlissner commented 7 years ago

I can easily reproduce it, and I understand why it happens (the evil-snipe-disabled-modes check in turn-on-evil-snipe-*mode occurs before the major-mode is set), but I don't understand why the check happens so soon. I'm looking into it though.

hlissner commented 7 years ago

Correction, turn-on-evil-snipe-*mode don't seem to be called at all, skipping the evil-snipe-disabled-modes check entirely. Seems like I've misunderstood how define-globalized-minor-mode works. Back to the drawing board!

hlissner commented 7 years ago

Reopening: still not sure if it fixed the issue. Still looking into it.

braham-snyder commented 7 years ago

The docstring for define-globalized-minor-mode could really use improvement regarding the fact that the function (usually) automatically associates MODE with MODE-map (regardless of whether that map already exists)--even the docstring for define-minor-mode (which the former function references) doesn't actually convey that.

Anyway, there are very likely better ways of fixing it than this (hence no PR), but, at the least, here's a proof-of-concept (that ought to not break anyone's existing configuration):

(defvar evil-snipe-mode-global-map
  (let ((map (make-sparse-keymap)))
    map))
(defvar evil-snipe-override-mode-global-map
  (let ((map (make-sparse-keymap)))
    map))

;;;###autoload
(define-globalized-minor-mode evil-snipe-mode
  evil-snipe-local-mode turn-on-evil-snipe-mode
  :keymap evil-snipe-mode-global-map)

;;;###autoload
(define-globalized-minor-mode evil-snipe-override-mode
  evil-snipe-override-local-mode turn-on-evil-snipe-override-mode
  :keymap evil-snipe-override-mode-global-map)

(provide 'evil-snipe)
;;; evil-snipe.el ends here
hlissner commented 6 years ago

As of https://github.com/hlissner/evil-snipe/commit/3b333c2d85d8306505d0fac4ce99c038aae6533f this issue should be resolved (so long as you add Info-mode to evil-snipe-disabled-modes or attach turn-off-evil-snipe-mode to Info-mode-hook).

Feel free to reopen this if that isn't the case.