Error: Attempt to shape unibyte text

Emacs28,consult--grep检索时,搜索失败,出现了错误提示。

Error running timer: (error “Attempt to shape unibyte text”)
#<subr completing-read-default>: Attempt to shape unibyte text
file-truename: Attempt to shape unibyte text

搜索了下,找到一个相关的issue https://github.com/mickeynp/ligature.el/issues/10

有人遇到了吗?有没有办法绕过。

unibyte 是指只有 ascii 字符,通过搜索 Emacs 的 codebase 可以发现有两个地方可能会触发这个错误:

  1. emacs/composite.c at master · emacs-mirror/emacs · GitHub 当前 buffer 内的 enable-multibyte-charactersnil 会触发。为 nil 时表示当前 buffer 不支持 multibyte 的字符串只支持 ascii。
  2. emacs/composite.c at master · emacs-mirror/emacs · GitHub 在确定字符串是 unibyte (ascii) 的情况下,发现此字符串里的部分字符的取值范围不在 [0, 0x80) 之间。

然后接下来可能需要楼主自己调试 Emacs 了

1 个赞
(setq default-process-coding-system '(utf-8 . utf-8))

OK 了。

不太明白的是,我没设定这个变量时。正常的buffer显示 汉字都正常,只有 consult-grep 的minibuffer候选不能正常显示中文和 ligature 字体。