Skip to content

Commit 0a50c91

Browse files
authored
Add rime-commit-and-toggle-input-method function. (#212)
* Add `rime-commit-and-toggle-input-method` function. * Fix not usable when didn't do toggle-input-method yet for the first time during every Emacs startup.
1 parent 92eb45b commit 0a50c91

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

README.org

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@
227227

228228
默认行为为自动关闭,设置 ~rime-deactivate-when-exit-minibuffer~ 为 nil 取消该行为。
229229

230+
* 在切换输入法时自动上屏
231+
232+
可将 ~rime-commit-and-toggle-input-method~ 绑定到某个按键上来替代原本 ~toggle-input-method~ 的功能。
233+
230234
* 指定 Rime 共享目录和用户目录
231235

232236
~rime-share-data-dir~ 是 Rime 安装后放置配置的目录,例如 Linux 上默认为 /usr/share/rime-data. 通常使用默认值即可。

README_EN.org

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ Default to ~|~ , you can customize it with
160160
(setq rime-cursor "˰")
161161
#+END_SRC
162162

163+
* Commit the first item automatically when toggle input method
164+
165+
Give =rime-commit-and-toggle-input-method= a keybinding to replace what =toggle-input-method= does.
166+
163167
* Shortcut to open Rime configuration file
164168

165169
Use ~rime-open-configuration~.

rime.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,15 @@ Will resume when finish composition."
11661166
tab-line-format nil)
11671167
(jit-lock-mode -1))
11681168

1169+
(defun rime-commit-and-toggle-input-method ()
1170+
"Commit the first item if exists, then toggle input method."
1171+
(interactive)
1172+
(ignore-errors
1173+
(when (rime-lib-process-key 32 0)
1174+
(let ((commit (rime-lib-get-commit)))
1175+
(insert commit)
1176+
(rime--clear-state))))
1177+
(toggle-input-method))
11691178

11701179
(require 'rime-predicates)
11711180

0 commit comments

Comments
 (0)