Skip to content

Commit 258ee6d

Browse files
authored
Merge pull request #85 from gudzpoz/master
Spacemacs hybrid mode support
2 parents fa12ae7 + 116dac9 commit 258ee6d

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

README.org

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ its all in English.
227227
#+END_SRC
228228

229229
Tips:
230-
1. For ~spacemacs~, if it works in the ~hybrid~ mode, some of the ~evil~ related
231-
features may not work. Change to ~vim~ mode instead.
230+
1. For ~spacemacs~ users, if you are using ~hybrid~ mode, you might need to add
231+
~evil-hybrid-state-exit-hook~ to ~sis-respect-evil-hooks~ and
232+
~evil-hybrid-state-entry-hook~ to ~sis-context-hooks~.
232233
2. Make sure your ISM is availabe (in your ~$PATH~) before call ~sis~ command.
233234

234235
** About /inline english mode/

README.zh.org

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ brew install macism
192192
#+END_SRC
193193

194194
提示:
195-
1. 对于 ~spacemacs~,如果在 ~hybrid~ 模式下工作,某些与 ~evil~ 相关的功能可能无法正常工作。请改用 ~vim~ 模式。
195+
1. 对于 ~spacemacs~ 用户,如果你使用 ~hybrid~ 模式,你可能需要将
196+
~evil-hybrid-state-exit-hook~ 添加至 ~sis-respect-evil-hooks~ ,将
197+
~evil-hybrid-state-entry-hook~ 添加至 ~sis-context-hooks~.
196198
2. 在调用 ~sis~ 命令之前,请确保你的 ISM 可用(在你的 ~$PATH~ 中)。
197199

198200
** 关于 /内联英文模式/

sis.el

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ nil means obtained from the envrionment.")
8080
(defvar sis-respect-evil-normal-escape t
8181
"<escape> to english in normal state when the /respect mode/ is enabled.")
8282

83+
(defvar sis-respect-evil-hooks '(evil-insert-state-exit-hook)
84+
"List of hook symbols that will be configured to cause input source to go
85+
to english under /respect mode/. When changing this, one might also want
86+
to add the corresponding entry hooks to `sis-context-hooks'.")
87+
8388
(defvar sis-respect-minibuffer-triggers (list)
8489
"Commands trigger to set input source in minibuffer.
8590
@@ -159,8 +164,10 @@ Each detector should:
159164
"Hooks trigger the set of input source following context.")
160165

161166
(defvar sis-context-triggers
162-
(list '('+org/insert-item-below 'sis--context-line nil)
163-
'('+org/insert-item-above 'sis--context-line nil))
167+
(and (featurep 'doom)
168+
(modulep! :lang org)
169+
(list '('+org/insert-item-below 'sis--context-line nil)
170+
'('+org/insert-item-above 'sis--context-line nil)))
164171
"Commands trigger the set of input source following context.
165172
166173
Each trigger should be a list: (FN PRE-FN-DETECTOR POST-FN-DETECTOR).
@@ -1010,7 +1017,8 @@ Possible values: \\='normal, \\='prefix, \\='sequence.")
10101017
(defun sis--respect-evil ()
10111018
"Respect evil."
10121019
(when (featurep 'evil)
1013-
(add-hook 'evil-insert-state-exit-hook #'sis-set-english)
1020+
(dolist (hook sis-respect-evil-hooks)
1021+
(add-hook hook #'sis-set-english))
10141022
;; evil's advice cause a lot of trouble
10151023
;; let sis to manage input method
10161024
(advice-add 'evil-activate-input-method :override
@@ -1086,7 +1094,8 @@ Possible values: \\='normal, \\='prefix, \\='sequence.")
10861094
(sis--try-disable-auto-refresh-mode)
10871095
;; for evil
10881096
(when (featurep 'evil)
1089-
(remove-hook 'evil-insert-state-exit-hook #'sis-set-english)
1097+
(dolist (hook sis-respect-evil-hooks)
1098+
(remove-hook hook #'sis-set-english))
10901099
(advice-remove 'evil-activate-input-method #'sis--do-nothing-advice)
10911100
(advice-remove 'evil-deactivate-input-method #'sis--do-nothing-advice)
10921101
(advice-remove 'ad-Advice-toggle-input-method #'sis--original-advice)

0 commit comments

Comments
 (0)