Native & OS 输入法管理包『sis』使用交流

可以自定义背景色,有个face变量。

双空格或者回车,都会关闭region,自动切回中文啊。

如果你不想inline mode中编辑英文句子,
设成但空格自动关闭region,会更方便。

当然如果你已经很烦躁不想再体会,
那我也不再继续解释。

发现 sis-default-cursor-color是black,貌似在doom theme加载完之前sis就初始化了,导致开始输入法后光标就变成黑色了。

然后发现光标自动变色根本不工作,懒得研究,直接把 global cursor color mode关了。

Doom Emacs + 最新版sis + macOS + Squirrel。

用的sis-global-cursor-color-mode 升级29.1之后,光标变色延迟很多,目测1秒多,有遇到的吗

GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0

有的,表现为不只是光标颜色变换卡顿,移动光标也会卡顿,tg 的群友一起定位之后大概应该是 color cursor 有问题,禁用这个就可以恢复流畅。按理说 30 应该也有这个问题,但是我目前用 30 下没有卡顿。

2 个赞

作者大大你好,我系统相关信息如下:Debian12, emacs版本是28.2,fcitx5版本是5.0.21,使用的配置是陈斌大佬的配置,其中使用了Evil,安装了sis,按照如下在~/.custom.el中的配置启用sis

(sis-ism-lazyman-config "1" "2" 'fcitx5)
(setq sis-inline-with-english t) ; 默认是t, 中文context下输入<spc>进入内联英文
(setq sis-inline-with-other t) ; 默认是nil

;; enable the /cursor color/ mode
(sis-global-cursor-color-mode t)
;; enable the /respect/ mode
(sis-global-respect-mode t)
;; enable the /context/ mode for all buffers
(sis-global-context-mode t)
;; enable the /inline english/ mode for all buffers
(sis-global-inline-mode t)

启用之后我遇到了一个问题,使用j,k,l,h移动光标有一些延迟,向左,向右,向下移动都没有太大的感觉,但是向上移动就有特别明显的卡顿,如动图最后那一哆嗦。还望作者大大指点一下我。 2kpgk-yo8x0

Contacting host: melpa.org:443 [2 times]
Parsing tar file...done
Extracting...done
  INFO     Scraping files for loaddefs...done
  GEN      sis-autoloads.el
Error loading autoloads: (user-error Local variables entry is missing the suffix)
Checking d:/Q/360/Emacs/winrc/emacsrc/.emacs.d/elpa/sis-20230305.1006...
File mode specification error: (user-error Local variables entry is missing the suffix)
File local-variables error: (user-error Local variables entry is missing the suffix)
Compiling d:/Q/360/Emacs/winrc/emacsrc/.emacs.d/elpa/sis-20230305.1006/sis-autoloads.el...
Checking d:/Q/360/Emacs/winrc/emacsrc/.emacs.d/elpa/sis-20230305.1006... [2 times]
Compiling d:/Q/360/Emacs/winrc/emacsrc/.emacs.d/elpa/sis-20230305.1006/sis.el...done
Wrote d:/Q/360/Emacs/winrc/emacsrc/.emacs.d/elpa/sis-20230305.1006/sis.elc
Checking d:/Q/360/Emacs/winrc/emacsrc/.emacs.d/elpa/sis-20230305.1006...
Done (Total of 1 file compiled, 1 failed, 1 skipped)
Package ‘sis’ installed.
Operation [ Install 1 ] finished
Error running timer ‘sis--respect-post-cmd-timer-fn’: (wrong-number-of-arguments (lambda (buffer) (sis--string-match-p "^magit.*:" (buffer-name buffer))) 0)

安装的最新版本怎么会有这些错误信息? 配置如下:

(use-package sis
  :after yasnippet
  :init
  (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'
  :config
  (sis-ism-lazyman-config nil t 'w32)
  (sis-global-cursor-color-mode t)
  (sis-global-respect-mode t)
  (sis-global-inline-mode t) ; 中文输入法状态下,中文后<spc>自动切换英文,结束后自动切回中文
  ;; 特殊定制
  (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>进行内联中文
  ;; 特殊buffer禁用sis前缀,使用Emacs原生快捷键  setqsis-prefix-override-buffer-disable-predicates
  (setq sis-prefix-override-buffer-disable-predicates
	(list 'minibufferp
              (;; magit 的keymap是基于text property的,优先级比sis更高。进入 magit 后,disable sis的映射
               lambda (buffer)
               (sis--string-match-p "^magit.*:" (buffer-name buffer)))
              (;; special buffer
               lambda (buffer) ; special buffer,所有*打头的buffer,但是不包括*Scratch* *New, *About GNU等buffer
               (and (sis--string-match-p "^\*" (buffer-name buffer))
		    (not (sis--string-match-p "^\*About GNU Emacs" (buffer-name buffer))) ; *About GNU Emacs" 仍可使用 C-h/C-x/C-c 前缀
		    (not (sis--string-match-p "^\*sdcv" (buffer-name buffer))) ; ???
		    (not (sis--string-match-p "^\*new\*"
                                              (downcase (buffer-name buffer))))
		    (not (sis--string-match-p "^\*scratch\*" ; *Scratch*  仍可使用 C-h/C-x/C-c 前缀
                                              (downcase (buffer-name buffer)))))))))

这个代码格式化预览的时候没问题,发出去怎么变了?

@goumao 非常感谢,现在不用频繁切换输入法了,使用中发现还有个小问题,例如在「元素ID」中元素后面插入不会切换到中文输入法

我在 Windows 11 22H2 + emacs 29.1 上使用 sis 的 w32 设置,可以从中文切换到英文,但无法从英文切换回中文。

一番研究后发现是 w32-set-ime-open-status 这个方法的问题:
(w32-set-ime-open-status nil) 可以从中文切换到英文,但 (w32-set-ime-open-status t) 并不能从英文切换到中文,有没有大佬可以指点一下该怎么解决这个问题?


在另一个帖子里发现了相同的问题,应该就是微软win11的输入法中改了些什么东西,使用兼容模式就可以没有问题的进行切换。其他的解决方案也可以看这个帖子下的。

话说这个切换能不能在状态栏上加个标志显示现在在中英哪个状态下面? :joy:

可以设置光标颜色来区分。比如下面这样,default 就是英文下的颜色。

(setq sis-default-cursor-color "#cf7fa7"
           sis-other-cursor-color "orange")

@LuciusChen 的答案是标准答案,通过光标颜色来区分。
你要是一定要在状态栏加标志的话,也不是不行。

光标颜色是这样加的,
(add-hook 'sis-change-hook #'sis--update-cursor-color)
类似地,你自己给'sis-change-hook加一个hook函数。

Error loading autoloads: (user-error Local variables entry is missing the suffix)

安装 这个版本后 sis-20230305.1006 会出现上面的错误?

windows 11 GNU Emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-08-02

@goumao

最近发现 sis 在 macOS 上会和 Emacs 的 Global mark ring 冲突,造成 global-mark-ring 变量无法保存,一直是空的。

重现步骤可以看这个 issue:

在org-mode里用M-S-RET切换列表/heading的时候会切成英文,而C-S-RET就不会。

有空我研究一下

1 个赞

M-S-RETC-S-RET 分别映射到了什么函数?

C-S-<return> runs the command
org-insert-todo-heading-respect-content (found in
org-mode-map), which is an interactive byte-compiled Lisp
function in ‘org.el’.

It is bound to C-S-<return>.
M-S-<return> runs the command org-insert-todo-heading (found
in org-mode-map), which is an interactive byte-compiled Lisp
function in ‘org.el’.

It is bound to M-S-<return> and M-S-RET.

我观察到按M-S-RET的时候执行的是切换而不是切换至英文,可能和输入法的shift切换有关。

你要有需求的话,就自定义 sis-context-triggers这个变量。

('+org/insert-item-below 'sis--context-line nil)

意思是,在'+org/insert-item-below函数执行前后,分别用你指定的函数来检测上下文,nil的话让检测链上后面的函数去决定,非nil的话就确定你想切换到什么输入法。本例中,在函数'+org/insert-item-below 执行前用'sis--context-line 检测上下文,'+org/insert-item-below 执行后不检测。

1 个赞

找到问题所在了,可能是输入法为了适配C-S-<tab>的快捷键,对于C-S一律忽略掉其中的Shift,而没有对M-S进行同样的处理,导致当我按下M-S-<return>的时候,先触发emacs内置函数,松开Shift之后输入法识别为一次长按Shift的过程,触发输入法内置的中英文状态切换快捷键。

解决方法也很简单,关掉输入法内置的Shift,改用Windows内置的Ctrl+Space切换中英文状态。