Skip to content

Commit

Permalink
Add rime-commit-and-toggle-input-method function. (DogLooksGood#212)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
ATNewHope authored Jan 23, 2023
1 parent 92eb45b commit 0a50c91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@

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

* 在切换输入法时自动上屏

可将 ~rime-commit-and-toggle-input-method~ 绑定到某个按键上来替代原本 ~toggle-input-method~ 的功能。

* 指定 Rime 共享目录和用户目录

~rime-share-data-dir~ 是 Rime 安装后放置配置的目录,例如 Linux 上默认为 /usr/share/rime-data. 通常使用默认值即可。
Expand Down
4 changes: 4 additions & 0 deletions README_EN.org
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ Default to ~|~ , you can customize it with
(setq rime-cursor "˰")
#+END_SRC

* Commit the first item automatically when toggle input method

Give =rime-commit-and-toggle-input-method= a keybinding to replace what =toggle-input-method= does.

* Shortcut to open Rime configuration file

Use ~rime-open-configuration~.
Expand Down
9 changes: 9 additions & 0 deletions rime.el
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,15 @@ Will resume when finish composition."
tab-line-format nil)
(jit-lock-mode -1))

(defun rime-commit-and-toggle-input-method ()
"Commit the first item if exists, then toggle input method."
(interactive)
(ignore-errors
(when (rime-lib-process-key 32 0)
(let ((commit (rime-lib-get-commit)))
(insert commit)
(rime--clear-state))))
(toggle-input-method))

(require 'rime-predicates)

Expand Down

0 comments on commit 0a50c91

Please sign in to comment.