Open TheBB opened 11 years ago
Original comment by Anonymous:
Hey, I'm the one who posted the question that this issue mostly likely came from (http://stackoverflow.com/questions/15169428/). The problem is that evil's incremental searches are performed in normal mode, which, to my knowledge, cannot be used with an input method. This is a quick hack I came up with that switches to insert-state just before performing a search. Since it switches to normal-state directly after the search is finished, the only indicator that you temporarily switch to insert-state is a different cursor while you are performing the search.
#!elisp
(evil-define-motion evil-search-forward ()
(format "Search forward for user-entered text.
Searches for regular expression if `evil-regexp-search' is t.%s"
(if (and (fboundp 'isearch-forward)
(documentation 'isearch-forward))
(format "\n\nBelow is the documentation string \
for `isearch-forward',\nwhich lists available keys:\n\n%s"
(documentation 'isearch-forward)) ""))
:jump t
:type exclusive
:repeat evil-repeat-search
(progn ;MADE CHANGES HERE
(evil-insert-state)
(evil-search-incrementally t evil-regexp-search)
(evil-normal-state)
))
(evil-define-motion evil-search-backward ()
(format "Search forward for user-entered text.
Searches for regular expression if `evil-regexp-search' is t.%s"
(if (and (fboundp 'isearch-forward)
(documentation 'isearch-forward))
(format "\n\nBelow is the documentation string \
for `isearch-forward',\nwhich lists available keys:\n\n%s"
(documentation 'isearch-forward)) ""))
:jump t
:type exclusive
:repeat evil-repeat-search
(progn ;MADE CHANGES HERE
(evil-insert-state)
(evil-search-incrementally nil evil-regexp-search)
(evil-normal-state)
))
I'm not sure if this is where I shoud be posting 'contributions' like this, but I figured it was a good place to start. :)
Any updates on this?
I too ran into the same problem. Any updates or hints would be appreciated.
I found a solution for myself in using the Evil custom search.
Look like evil-search
let take into account current input method in Evil:
(evil-search-module 'evil-search)
When I'm in vi-search mode (after pressing /
in normal mode),
C-\ allows to change the input method.
@PRESFIL It works fine! Thank you. However, the input method toggle still does not work in isearch
(C-s). You gave me a hint, so I'll have to look into this. Thanks again!
@PRESFIL Thanks to your help, I found a way to enable input method toggle in isearch
as well. This is possible in the following way.
(add-hook 'isearch-mode-hook
(lambda (&rest _)
(remove-hook 'input-method-activate-hook 'evil-activate-input-method t)))
(add-hook 'isearch-mode-end-hook
(lambda (&rest _)
(add-hook 'input-method-activate-hook 'evil-activate-input-method nil t)))
In my case, I also added (deactivate-input-method)
to isearch-mode-end-hook
to return the original input method after isearch
.
(add-hook 'isearch-mode-hook
(lambda (&rest _)
(evil-put-property 'evil-state-properties 'normal :input-method t)))
(add-hook 'isearch-mode-end-hook
(lambda (&rest _)
(when current-input-method (toggle-input-method))
(evil-put-property 'evil-state-properties 'normal :input-method nil)))
@whitemuu 's solution works flawlessly. Thank you.
Originally reported by: Xin Wang (Bitbucket: dram, GitHub: dram)
Input method can not be toggled on in isearch mode when evil is enabled. It works if evil is disabled.
In evil 1.0.1, emacs 24.3.