(重新设计)中英文混打:OS输入法管理包 smart-input-source

我这里可以。。
我在这个界面 C-g,输入法自动切回原文档的中文。 不过我是M-x运行的magit-file-dispatch

这些还是要你自己定义这三个变量。

这个是同一个buffer内的切换
比如你当前的是a.txt
你magit-log啥的,其实还是在a.txt里面操作
这个时候,sis默认是不管的。
你自己往那几个变量里面加相关的触发函数(可以借助sis-log-mode)。

不过。。。。跟前面的about-emacs 一样,
都卡在同一个现象上,
如果我能分析清楚为什么会发生那个现象
处理起来就会更简洁,用户需要自己介入的配置会更少。

使用 commit: 6a01cd 测试 更名后isearch-forward 不能自动切换成英语了, commit: 257f4b 这个是未更名前的,正常的

我明天fix一下~~,应该问题不大。

请问pyim可以使用这个包吗

可以。所有的emacs输入法,都可以挂。

好的,试一下看看,再来反馈

切换到中文输入法的时候,C-@不能设置标记了。

有人碰到这样问题吗

之前把(push “M-SPC” sis-prefix-override-keys)放在 (sis-global-respect-mode t) 之后,所以没生效,放在之前就可以了。这个变量是不是用 defcostom 来定义更好呀。

是否是中文输入法快捷冲突了 我用的 RIME 里面快捷键与 C-@ 冲突

{accept: "Control+Shift+2", toggle: ascii_mode, when: always}

跟defcustom没关系。

必须放前面。
因为mode启动的时候,会有一些初始化,依赖当前的 sis-prefix-override-keys

应该fix了。我这里测试正常。

修复了~~

你的run-with-timer是最佳方案 :+1:

更新最新版 COMMIT : 2c02cb5 启动出错

Error (use-package): sis/:config: Wrong type argument: listp, “black”

我这里没什么问题。我觉得可能跟cursor color有关,但是我试了相关设置,都没问题。

  • emacs --debug-init 给我看下报错详情,
  • sis的配置给我

@opsnull

干净的解决了。
现在应该都是可以的:magit-dispatch 自动切换到英文,完了再自动切回中文。

=== 更新 ====
发现还有不完美的地方,我现在只处理一级命令,
所以 magit-file-dispatch->magit-log-buffer-file之后会自动切回中文。

但是,我看还有多级的需求。
所以,这块还可以再改进。

===== 更新========
这块主要是magit做了魔法,
我这里将做针对性的处理,
会处理得很彻底。

=== 更新 ======
对magit的处理,现在完美了~~~~ :tada:

debug

Debugger entered--Lisp error: (wrong-type-argument listp "black")
  apply(#f(compiled-function (color-name) "Set the text cursor color of the selected frame to COLOR-NAME.\nWhen called interactively, prompt for the name of the color to use.\nThis works by setting the `cursor-color' frame parameter on the\nselected frame.\n\nYou can also set the text cursor color, for all frames, by\ncustomizing the `cursor' face." (interactive #f(compiled-function () #<bytecode 0x100b50d>)) #<bytecode 0x1000b8df9>) "black")
  set-cursor-color("black")
  sis--update-cursor-color()
  run-hooks(sis-change-hook)
  sis--update-state(english)
  sis-global-respect-mode(t)
  (progn (sis-ism-lazyman-config "1033" "2052" (quote im-select)) (sis-global-cursor-color-mode t) (sis-global-respect-mode t) (sis-global-inline-mode t) (global-set-key (kbd "<f9>") (quote sis-log-mode)) (setq sis-default-cursor-color "green yellow" sis-other-cursor-color "#FF2121" sis-inline-tighten-tail-rule (quote all) sis-inline-with-english t sis-inline-with-other t) (setq sis-respect-go-english-triggers (list (quote isearch-forward) (quote isearch-backward)) sis-respect-restore-triggers (list (quote isearch-exit) (quote isearch-abort))) t)
  (condition-case err (progn (sis-ism-lazyman-config "1033" "2052" (quote im-select)) (sis-global-cursor-color-mode t) (sis-global-respect-mode t) (sis-global-inline-mode t) (global-set-key (kbd "<f9>") (quote sis-log-mode)) (setq sis-default-cursor-color "green yellow" sis-other-cursor-color "#FF2121" sis-inline-tighten-tail-rule (quote all) sis-inline-with-english t sis-inline-with-other t) (setq sis-respect-go-english-triggers (list (quote isearch-forward) (quote isearch-backward)) sis-respect-restore-triggers (list (quote isearch-exit) (quote isearch-abort))) t) ((debug error) (funcall use-package--warning18 :config err)))
  (prog1 (condition-case err (progn (sis-ism-lazyman-config "1033" "2052" (quote im-select)) (sis-global-cursor-color-mode t) (sis-global-respect-mode t) (sis-global-inline-mode t) (global-set-key (kbd "<f9>") (quote sis-log-mode)) (setq sis-default-cursor-color "green yellow" sis-other-cursor-color "#FF2121" sis-inline-tighten-tail-rule (quote all) sis-inline-with-english t sis-inline-with-other t) (setq sis-respect-go-english-triggers (list (quote isearch-forward) (quote isearch-backward)) sis-respect-restore-triggers (list (quote isearch-exit) (quote isearch-abort))) t) ((debug error) (funcall use-package--warning18 :config err))) (let ((elapsed (float-time (time-subtract (current-time) now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Configuring package sis" elapsed) (message "%s...done" "Configuring package sis"))))
  (let ((now (current-time))) (message "%s..." "Configuring package sis") (prog1 (condition-case err (progn (sis-ism-lazyman-config "1033" "2052" (quote im-select)) (sis-global-cursor-color-mode t) (sis-global-respect-mode t) (sis-global-inline-mode t) (global-set-key (kbd "<f9>") (quote sis-log-mode)) (setq sis-default-cursor-color "green yellow" sis-other-cursor-color "#FF2121" sis-inline-tighten-tail-rule (quote all) sis-inline-with-english t sis-inline-with-other t) (setq sis-respect-go-english-triggers (list (quote isearch-forward) (quote isearch-backward)) sis-respect-restore-triggers (list (quote isearch-exit) (quote isearch-abort))) t) ((debug error) (funcall use-package--warning18 :config err))) (let ((elapsed (float-time (time-subtract (current-time) now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Configuring package sis" elapsed) (message "%s...done" "Configuring package sis")))))
  (if (not (require (quote sis) nil t)) (display-warning (quote use-package) (format "Cannot load %s" (quote sis)) :error) (let ((now (current-time))) (message "%s..." "Configuring package sis") (prog1 (condition-case err (progn (sis-ism-lazyman-config "1033" "2052" (quote im-select)) (sis-global-cursor-color-mode t) (sis-global-respect-mode t) (sis-global-inline-mode t) (global-set-key (kbd "<f9>") (quote sis-log-mode)) (setq sis-default-cursor-color "green yellow" sis-other-cursor-color "#FF2121" sis-inline-tighten-tail-rule (quote all) sis-inline-with-english t sis-inline-with-other t) (setq sis-respect-go-english-triggers (list (quote isearch-forward) (quote isearch-backward)) sis-respect-restore-triggers (list (quote isearch-exit) (quote isearch-abort))) t) ((debug error) (funcall use-package--warning18 :config err))) (let ((elapsed (float-time (time-subtract ... now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Configuring package sis" elapsed) (message "%s...done" "Configuring package sis"))))))
  (prog1 (if (not (require (quote sis) nil t)) (display-warning (quote use-package) (format "Cannot load %s" (quote sis)) :error) (let ((now (current-time))) (message "%s..." "Configuring package sis") (prog1 (condition-case err (progn (sis-ism-lazyman-config "1033" "2052" (quote im-select)) (sis-global-cursor-color-mode t) (sis-global-respect-mode t) (sis-global-inline-mode t) (global-set-key (kbd "<f9>") (quote sis-log-mode)) (setq sis-default-cursor-color "green yellow" sis-other-cursor-color "#FF2121" sis-inline-tighten-tail-rule (quote all) sis-inline-with-english t sis-inline-with-other t) (setq sis-respect-go-english-triggers (list ... ...) sis-respect-restore-triggers (list ... ...)) t) ((debug error) (funcall use-package--warning18 :config err))) (let ((elapsed (float-time ...))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Configuring package sis" elapsed) (message "%s...done" "Configuring package sis")))))) (let ((elapsed (float-time (time-subtract (current-time) now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Loading package sis" elapsed) (message "%s...done" "Loading package sis"))))
  (let ((now (current-time))) (message "%s..." "Loading package sis") (prog1 (if (not (require (quote sis) nil t)) (display-warning (quote use-package) (format "Cannot load %s" (quote sis)) :error) (let ((now (current-time))) (message "%s..." "Configuring package sis") (prog1 (condition-case err (progn (sis-ism-lazyman-config "1033" "2052" ...) (sis-global-cursor-color-mode t) (sis-global-respect-mode t) (sis-global-inline-mode t) (global-set-key ... ...) (setq sis-default-cursor-color "green yellow" sis-other-cursor-color "#FF2121" sis-inline-tighten-tail-rule ... sis-inline-with-english t sis-inline-with-other t) (setq sis-respect-go-english-triggers ... sis-respect-restore-triggers ...) t) ((debug error) (funcall use-package--warning18 :config err))) (let ((elapsed ...)) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Configuring package sis" elapsed) (message "%s...done" "Configuring package sis")))))) (let ((elapsed (float-time (time-subtract (current-time) now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Loading package sis" elapsed) (message "%s...done" "Loading package sis")))))
  (condition-case err (let ((now (current-time))) (message "%s..." "Loading package sis") (prog1 (if (not (require (quote sis) nil t)) (display-warning (quote use-package) (format "Cannot load %s" (quote sis)) :error) (let ((now (current-time))) (message "%s..." "Configuring package sis") (prog1 (condition-case err (progn ... ... ... ... ... ... ... t) (... ...)) (let (...) (if ... ... ...))))) (let ((elapsed (float-time (time-subtract ... now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Loading package sis" elapsed) (message "%s...done" "Loading package sis"))))) ((debug error) (funcall use-package--warning18 :catch err)))
  eval-buffer(#<buffer  *load*-131101> nil "d:/Q/360/Emacs/winrc/emacsrc/.emacs" nil t)  ; Reading at buffer position 60795
  load-with-code-conversion("d:/Q/360/Emacs/winrc/emacsrc/.emacs" "d:/Q/360/Emacs/winrc/emacsrc/.emacs" nil nil)
  load("D:/Q/360/Emacs/winrc/emacsrc/.emacs")
  eval-buffer(#<buffer  *load*> nil "c:/Users/John/AppData/Roaming/.emacs" nil t)  ; Reading at buffer position 661
  load-with-code-conversion("c:/Users/John/AppData/Roaming/.emacs" "c:/Users/John/AppData/Roaming/.emacs" t t)
  load("~/.emacs" t t)
  #f(compiled-function () #<bytecode 0x1000baab9>)()
  command-line()
  normal-top-level()

sis 配置

(use-package sis
  :quelpa (sis :fetcher github :repo "laishulu/emacs-smart-input-source")
  :config
  (sis-ism-lazyman-config "1033" "2052" 'im-select) ; 输入码 1033/英文,2052/中文小狼毫
   (sis-global-cursor-color-mode t)
   (sis-global-respect-mode t)
   (sis-global-inline-mode t) ; 中文输入法状态下,中文后<spc>自动切换英文,结束后自动切回中文
   (global-set-key (kbd "<f9>") 'sis-log-mode) ; 开启日志

   (setq sis-default-cursor-color "green yellow" ; 英文光标色
	 sis-other-cursor-color "#FF2121" ; 中文光标色传统的中国红,又称绛色
	 ;; sis-inline-tighten-head-rule 'all ; 删除头部空格,默认1,删除一个空格,1/0/'all
	 sis-inline-tighten-tail-rule 'all ; 删除尾部空格,默认1,删除一个空格,1/0/'all
	 sis-inline-with-english t ; 默认是t, 中文context下输入<spc>进入内联英文
	 sis-inline-with-other t) ; 默认是nil,而且prog-mode不建议开启, 英文context下输入<spc><spc>进行内联中文
   ;; `C-s/r' 默认优先使用英文
   (setq sis-respect-go-english-triggers
	 (list 'isearch-forward 'isearch-backward) ; isearch-forward 命令时默认进入en
	 sis-respect-restore-triggers
	 (list 'isearch-exit 'isearch-abort)) ; isearch-forward 恢复, isearch-exit `<Enter>', isearch-abor `C-g'
   )

fix了~~

请测试反馈。

最新版的 sis 报错:

Error running timer ‘sis–auto-refresh-timer-restart’: (wrong-type-argument stringp (“#ffffff”))

debug:

Debugger entered--Lisp error: (wrong-type-argument stringp ("#ffffff"))
  modify-frame-parameters(#<frame *Messages* – Doom Emacs 0x11f4c30> ((cursor-color "#ffffff")))
  #f(compiled-function (color-name) "Set the text cursor color of the selected frame to COLOR-NAME.\nWhen called interactively, prompt for the name of the color to use.\nThis works by setting the `cursor-color' frame parameter on the\nselected frame.\n\nYou can also set the text cursor color, for all frames, by\ncustomizing the `cursor' face." (interactive #f(compiled-function () #<bytecode 0x1dae3e9>)) #<bytecode 0x1daa69>)(("#ffffff"))
  apply(#f(compiled-function (color-name) "Set the text cursor color of the selected frame to COLOR-NAME.\nWhen called interactively, prompt for the name of the color to use.\nThis works by setting the `cursor-color' frame parameter on the\nselected frame.\n\nYou can also set the text cursor color, for all frames, by\ncustomizing the `cursor' face." (interactive #f(compiled-function () #<bytecode 0x1ea9bc5>)) #<bytecode 0x1daa69>) ("#ffffff"))
  set-cursor-color("#ffffff")
  sis--update-cursor-color()
  run-hooks(sis-change-hook)
  sis--update-state(nil)
  sis--save-to-buffer()
  sis--auto-refresh-timer-function()
  sis--auto-refresh-timer-restart()
  apply(sis--auto-refresh-timer-restart nil)
  timer-event-handler([t 0 0 200000 t sis--auto-refresh-timer-restart nil idle 0])

配置如下:

(use-package sis
  :hook (after-init . (lambda ()
                        ;; enable the /cursor color/ mode
                        (sis-global-cursor-color-mode t)
                        ;; enable the /respect/ mode
                        (sis-global-respect-mode t)
                        ;; enable the /follow context/ mode for all buffers
                        (sis-global-follow-context-mode t)
                        ;; enable the /inline english/ mode for all buffers
                        (sis-global-inline-mode t)))
  :config
  ;; (push "M-<SPC>" sis-prefix-override-keys)
  (sis-ism-lazyman-config nil nil
                          (cond ((executable-find"fcitx5") 'fcitx5)
                                ((executable-find "fcitx") 'fcitx))))

启动时报错

Error in post-command-hook (sis--respect-post-command-handler): (void-function sis--respect-force-restore-after-cmd)