3

Before loading EVIL for vim emulation in emacs, I have the following in my .emacs file:

(activate-input-method "english-dvorak")
(setq default-input-method "english-dvorak")

However, when I type / to start an incremental search with EVIL, the default input method is not used. Why is this? How can I make it so EVIL uses default-input-method whenever I am typing letters on screen?

I was able to hack in proper support for the f and t commands by mapping the qwerty characters to dvorak before the rest of the those function's code executed, but I still haven't been able to get my searches with / to use dvorak.

Gordon Gustafson
  • 40,133
  • 25
  • 115
  • 157
  • C-h f toggle-input-method should help. – aartist Apr 03 '13 at 14:17
  • This works fine for me. Are you using vanilla search? Does it work if you start emacs with `-Q`? – Thomas Apr 04 '13 at 01:01
  • @Thomas I apologize, my problem was actually more complex that I thought, and I have updated the question to reflect this. The solution above actually works fine in vanilla emacs, but it does NOT work in EVIL. – Gordon Gustafson Apr 04 '13 at 17:28

2 Answers2

2

I've tested the following configuration on my PC and it seem to make Dvorak to be on everywhere in Emacs:

;; Main setup for  all the buffers
(defadvice switch-to-buffer (after activate-input-method activate)
  (activate-input-method "english-dvorak"))

;; Sets up Dvorak for the minibuffer
(add-hook 'minibuffer-setup-hook (lambda () (set-input-method "english-dvorak")))

;; Sets up Dvorak for *scratch* buffer (used Qwerty on my PC otherwise)
(save-excursion
  (set-buffer (get-buffer "*scratch*"))
  (set-input-method "english-dvorak"))
Aleksei Zyrianov
  • 2,294
  • 1
  • 24
  • 32
  • I apologize, my problem was actually more complex that I thought, and I have updated the question to reflect this. I followed the procedure I originally outlined and the problem disappeared, although it looks like your advice would also do the trick. :) – Gordon Gustafson Apr 04 '13 at 17:24
0

The problem is that Evil's incremental searches are performed in normal-state, which, to my knowledge, cannot be used with an input method. This is a quick hack that switches to insert-state just before performing a search to allow the use of input methods. Since it switches to back normal-state immediately after the search is finished, the only quirk is a different cursor in the buffer while you are performing the search.

 (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)
    ))
Gordon Gustafson
  • 40,133
  • 25
  • 115
  • 157