我在archlinux上用emacs,配置是在purcell配置的基础上改的。使用过程中发现consult-fd,consult-find,consult-grep等各种consult搜索命令可以直接搜英文内容,但是无法直接搜中文。请问该怎么解决呢?
中文得打两个字以上才行
谢谢你,我刚刚试了,要打3个字以上的中文就可以搜索出来,1个和两个字都搜索不出来。
安装这个pinyinlib 包,可以用拼音搜索中文。
(use-package pinyinlib
:after orderless
:autoload pinyinlib-build-regexp-string
:init
(defun completion--regex-pinyin (str)
(orderless-regexp (pinyinlib-build-regexp-string str)))
(add-to-list 'orderless-matching-styles 'completion--regex-pinyin))
是不是你设置了最少3个字符才开始搜索啊…
好的,我试试,非常感谢!
果然 consult-async-min-input 被设置成了3,导致3个字符才开始搜索(无论英文还是中文字符),谢谢你,破案了!
发现遇到同样的情况。这个能够设置对中英文使用不同的参数吗?现在搜索中文如果不够三个字还得用空格补。
在consult.el 里面魔改了下,现在OK了,但是不知道在不改consult的情况下怎么实现。
(defun contains-non-ascii-p (str)
"Return t if STR contains any non-ASCII characters."
(string-match-p "[^\x00-\x7F]" str))
(defun consult--async-split (async &optional split)
...
(funcall async
;; Pass through if the input is long enough!
(if (or force (>= async-len consult-async-min-input) (contains-non-ascii-p async-str))
async-str
;; Pretend that there is no input
""))))
...
1 个赞
用advice-add
(defun consult--async-split! (async &optional split)
...)
(advice-add 'consult--async-split :override #'consult--async-split!)
2 个赞
(setq consult-async-min-input 2)
搜索“测试”可以成功