fcitx toggling helper for evil-mode
需要: 1.evil-mode, 2.Fcitx fcitx-remote 命令行工具(一般在fcitx包里带了)
首先确认 fcitx-remote 可用,测试方法
$ fcitx-remote -o ## 会启动输入法
$ fcitx-remote -c ## 会关闭输入法
如果以上的测试没有问题,那么就可以在 .emacs
或 init.el
里加入
(add-to-list 'load-path "path/to/evil-fcitx")
(require 'evil-fcitx)
正常的打字就可以了。(以下GIF中的IME切换键为)
-
在
insert-mode
时,可以通过 fcitx 预设的输入法切换按键(如CTRL+SPC
)换输入法,若在中文状态下按 ,evil-fcitx 会将输入法切回英文并记录此时处于英文状态 (在 mode-line 里会有一个 [ZH] 的标志),下次进入insert-mode
时 evil-fcitx 会再切回中文输入法。 -
在
normal-mode
时,可以按C-c C-q
清除 [ZH] 状态,这样下次进入insert-mode
里就不会切回中文了。 -
在
normal-mode
时,使用 f/F t/T r / ? 也可以输入中文。例如按下f
后可以切换成中文,输入一个字后输入法会回到中文。
f <Toggle IME>中
t <Toggle IME>文
/ <Toggle IME>にほんご<RET>
有几个可选的选项, 在 evil-fcitx.el 的前几行
;;;;;;;;;; User configs
(defvar force-back-to-default-state-key "C-c C-q")
; Indicator to be displayed in mode-line, like <N>/<I> for Evil-mode
(defvar user-IME-state-indicator "[ZH]")
(defvar default-IME-state-indicator "[EN]")
正统的vim粉还可以看看 fcitx.vim
Requirement: Emacs Evil-mode, Fcitx with fcitx-remote cli tool
(add-to-list 'load-path "path/to/evil-fcitx")
(require 'evil-fcitx)
Just type around, evil-fcitx would be invoked as you enable IME in insert-state.
P.S.Type C-q(or else in variable back-to-default-state-key) when you quit insert state with IME on, and don't want to type English next time you enter insert state.
Sometime there is a need to use f/F t/T r / ? with a non-ascii char/word as argument. You can type:
f <Toggle IME>中
t <Toggle IME>文
/ <Toggle IME>にほんご<RET>
There is an automatically added mode-line-tag, right next to evil-mode-line-tag(the stuff), by default are [EN] [ZH]. Emacs can not get IME info in real time, so the mode line tag will just be like this: [--].
Fcitx would automatically back to English mode.
Vim-like modeling editing is awesome, it uses mode to provide a large enough keystroke space(and save your pinky at the same time). However, the aproch is really unfriendly to non-English users who uses an IME, they have to toggle IME again and again when jumping from mode to mode.
Using fcitx-remote to automatically toggle IME, evil-fcitx could be one more reason for non-English emacs users who uses fcitx IME to taste the power of modeling editing.
Inspired by fcitx.vim, but IME-state is global for now, which means you better back to evil-normal-state before jump to another buffer. To be improved later.
See also fcitx.vim
BTW, Evil Mode does implement something like evil-fcitx (read from evil-core.el :func evil-(de)active-input-method). However, it just work for IMEs which are embedded in Emacs, those IME are not widely accept by Emacs users as far as I know.
The script would grow as using it. I wish it could be a Emacs front-end of Fcitx someday.
- DONE Adding a mode-line tag automatically
- Fully support search non-ASCII char/string in normal state. ..* Support more than two languages other than English.
- State record for every single buffer