redguardtoo / emacs.d

Fast and robust Emacs setup.
http://blog.binchen.org
GNU General Public License v3.0
2.39k stars 619 forks source link

counsel-etags-grep-current-directory这个函数能否搜索中文? #1055

Closed oxsardbest closed 10 months ago

oxsardbest commented 10 months ago

就是,dd这个按键对应的功能,输入中文直接查询会返回空内容,英文倒是没问题,ivy您hack过了,:加首字母没问题,但是不知道,dd怎么查中文。

redguardtoo commented 10 months ago

以下函数已在我配置中定义.

(defun my-grep-pinyin-in-current-directory ()
  "Grep pinyin in current directory."
  (interactive)
  ;; grep Chinese using pinyinlib.
  ;; In ivy filter, trigger key must be pressed before filter chinese
  (require 'counsel-etags)
  (let* ((counsel-etags-convert-grep-keyword
          (lambda (keyword)
            (cond
             ((> (length keyword) 0)
              (require 'pinyinlib)
              ;; only grep simplified Chinese
              (pinyinlib-build-regexp-string keyword t nil t))
             (t
              keyword)))))
    (counsel-etags-grep-current-directory)))

windows下使用需要开启utf-8支持, 因为windows默认命令行使用utf-16编码.

oxsardbest commented 10 months ago

抱歉,果然已经实现了,点赞