1 ;; anthy-isearch.el -- Anthy
4 ;; Author: Yusuke Tabata <yusuke@cherbim.icw.co.jp>
10 ;; TOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO many things to be implemented.
11 ;; most of the code is stolen from SKK.
16 (defvar anthy-isearch-mode-map nil)
18 ;;
\e$B8!:wBP>]$NJ8;zNs$H%W%j%(%G%#%C%H$rF~$l$k%P%C%U%!
\e(B
19 (defconst anthy-isearch-working-buffer " *anthy-isearch*")
21 ;;
\e$B8!:wBP>]$NJ8;zNs$r<hF@$9$k
\e(B
22 (defun anthy-isearch-search-string ()
23 (with-current-buffer (get-buffer-create anthy-isearch-working-buffer)
24 (if (string-equal anthy-preedit "")
25 ;;
\e$B%W%j%(%G%#%C%H$,L5$$;~$O
\e(B
28 (narrow-to-region (point-min) anthy-preedit-start)
31 ;;
\e$B8!:wBP>]$NJ8;zNs
\e(B +
\e$BF~NOESCf$NJ8;zNs
\e(B
32 (defun anthy-isearch-search-message ()
33 (with-current-buffer (get-buffer-create anthy-isearch-working-buffer)
36 (defun anthy-isearch-process-search-string (string msg)
37 (setq isearch-string "")
38 (setq isearch-message "")
39 (isearch-process-search-string string msg))
41 (defun anthy-isearch-raw-input ()
42 (with-current-buffer (get-buffer-create anthy-isearch-working-buffer)
43 (self-insert-command 1)))
45 (defun anthy-isearch-wrapper (&rest args)
47 (if current-input-method
48 (with-current-buffer (get-buffer-create anthy-isearch-working-buffer)
50 (anthy-isearch-raw-input))
51 (anthy-isearch-process-search-string
52 (anthy-isearch-search-string)
53 (anthy-isearch-search-message)))
55 (defun anthy-isearch-keyboard-quit (&rest args)
58 (with-current-buffer (get-buffer-create anthy-isearch-working-buffer)
59 (if (not (string-equal "" anthy-preedit))
62 (anthy-isearch-wrapper)
64 (setq isearch-string "")
65 (setq isearch-message "")
68 (defun anthy-isearch-toggle-input-method (&rest args)
70 (isearch-toggle-input-method))
72 (defun anthy-isearch-setup-keymap (map)
75 (define-key map (char-to-string i) 'anthy-isearch-wrapper)
77 (define-key map "\C-g" 'anthy-isearch-keyboard-quit)
78 (substitute-key-definition
79 'isearch-toggle-input-method
80 'anthy-isearch-toggle-input-method
84 (defun anthy-isearch-mode-setup ()
85 ;;
\e$B:G=i$O%-!<%^%C%W$r=`Hw$9$k
\e(B
86 (or (keymapp anthy-isearch-mode-map)
87 (setq anthy-isearch-mode-map
88 (anthy-isearch-setup-keymap (copy-keymap isearch-mode-map))))
90 (setq overriding-terminal-local-map anthy-isearch-mode-map)
91 (with-current-buffer (get-buffer-create anthy-isearch-working-buffer)
95 (defun anthy-isearch-mode-cleanup ()
96 (setq overriding-terminal-local-map nil)
97 (kill-buffer anthy-isearch-working-buffer)
100 (add-hook 'isearch-mode-hook 'anthy-isearch-mode-setup)
101 (add-hook 'isearch-mode-end-hook 'anthy-isearch-mode-cleanup)
102 (setq debug-on-error 't)