Input-method during isearch
Nikolai Weibull
now at disu.se
Mon Mar 2 19:03:20 CET 2015
On Sun, Mar 1, 2015 at 9:29 PM, Gordon Gustafson <gordon3.14 at gmail.com> wrote:
> Ideally you should search with evil's /, which already uses the
> current input method, rather than try to hack something together
> yourself (you can always rebind it to C-s if you feel like that's what
> you want.
Does it? I haven’t gotten it to work.
> If you still want to build this yourself, look into the
> macro evil-without-input-method-hooks, which is used in evil-search.el
> to implement this behavior for evil's search. Long story short, evil
> has hooks that prevent you from using an input method in normal state,
> and evil-without-input-method-hooks is probably the best way to get
> around them.
Evil also advices toggle-input-method.
Anyway, I feel that my solution of faking being in insert state while
isearch-forward-regexp is being run should solve the issue, but as I
mentioned, evil-state is re-entering normal state somewhere and I
can’t figure out when/how. Evil’s solution in
evil-search-incrementally is better, but it doesn’t work for me. I’m
actually getting
Invalid function: evil-without-input-method-hooks
when I try using / in 20150219.53. Re-evaluating both it and
rewriting and then re-evaluating evil-search-incrementally as
(defun evil-search-incrementally (forward regexp-p)
"Search incrementally for user-entered text."
(let ((evil-search-prompt (evil-search-prompt forward))
(isearch-search-fun-function 'evil-isearch-function)
(point (point))
search-nonincremental-instead)
(setq isearch-forward forward)
(evil-save-echo-area
(evil-without-input-method-hooks
(activate-input-method evil-input-method)
(if forward
(isearch-forward regexp-p)
(isearch-backward regexp-p))
(evil-push-search-history isearch-string forward)
(deactivate-input-method))
…
seems to solve the problem. Only setting current-input-method isn’t
enough, as isearch-process-search-multibyte-characters checks
isearch-input-method-function, which is set to whatever
input-method-function was set to.
> On 3/1/15, Nikolai Weibull <now at disu.se> wrote:
>> Hi!
>>
>> I'm trying to get input-method to work during isearch. It works if,
>> for example, isearch-forward-regexp is started in insert mode, as evil
>> doesn't disable input-method then. However, when started in normal
>> mode, it won't work, as evil disables input-method in that state.
>> I've tried
>>
>> (defun now-evil--isearch-forward-regexp-around (fn &rest args)
>> (let ((s evil-state))
>> (if (or (not evil-local-mode) (evil-state-property s :input-method))
>> (apply fn args)
>> (evil-change-state 'insert)
>> (unwind-protect
>> (apply fn args)
>> (evil-change-state s)))))
>> (advice-add 'isearch-forward-regexp :around
>> 'now-evil--isearch-forward-regexp-around)
>>
>> to get around this limitation, but it doesn't work. It seems that
>> evil is entering normal state somewhere between here and when isearch
>> is started.
>>
>> What am I doing wrong?
>>
>> Thanks!
>>
>> _______________________________________________
>> implementations-list mailing list
>> implementations-list at lists.ourproject.org
>> https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
>>
>
> _______________________________________________
> implementations-list mailing list
> implementations-list at lists.ourproject.org
> https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
More information about the implementations-list
mailing list