cute-jumper / ace-pinyin

Jump to Chinese character by pinyin with `avy' or `ace-jump-mode`
87 stars 19 forks source link

Support Chinese word #1

Closed xuchunyang closed 9 years ago

xuchunyang commented 9 years ago

by adding `ace-pinyin-jump-word'.

The "Chinese word" means a sequence of, i.e., one or more, Chinese character(s).

cute-jumper commented 9 years ago

Thanks. Before calling ace-jump-do, usually we need to set some variables as shown in ace-pinyin--jump-imple for example, which I basically copied from the implementation from ace-jump-char-mode. In this case, I think the most important one is to set the ace-jump-current-mode to a non-nil value so that ace-jump-mode would not be called recursively.

Would you mind fixing that?

xuchunyang commented 9 years ago

Is the following enough?

diff --git a/ace-pinyin.el b/ace-pinyin.el
index 961d3ba..d6f5232 100644
--- a/ace-pinyin.el
+++ b/ace-pinyin.el
@@ -144,6 +144,8 @@ Same sigature as `ace-jump-char-mode'"
     (when (string-match-p "[^a-z]" query)
       (error "[AceJump] Non-lower case character")))

+  (if ace-jump-current-mode (ace-jump-done))
+  (setq ace-jump-current-mode 'ace-jump-char-mode)
   (ace-jump-do
    (mapconcat (lambda (char) (nth (- char ?a) ace-pinyin--char-table))
               query "")))

I actually don't know how ace-jump-mode is implemented or how to write plugin for it, so basically, I don't know what I am trying to fixing.

cute-jumper commented 9 years ago

Yes, you can just do that. Thank you. I'll take care of the rest.