utf-8 - Emacs 中的 Rgrep 使用 ripgrep

标签 utf-8 emacs grep utf-16 ripgrep

我们如何自定义 Emacs 的 rgrep 以使用 ripgrep(rg 可执行文件)——使其能够同时使用 Latin 1、UTF-8 和 UTF-16 进行搜索?

这个想法是重用 Emacs 的标准 rgrep 命令,这样我们也可以使用 next-error 和 previous-error...

我不知道如何完全集成(对于基本目录)和(对于匹配的文件)说明符等。

(grep-apply-setting 'grep-find-template
                    "rg -uu -g <F> <R> <D>")

将产生(在 *.txt 文件中搜索时)

rg -uu -g \( -iname \*.txt \) test .
error: Invalid value for '--max-count <NUM>': invalid digit found in string

Grep exited abnormally with code 1 at Sun Aug  6 00:23:58

最佳答案

grep-find-template 用于将 grep 命令与 find 结合使用。这对我有用:

(grep-apply-setting 'grep-find-template "find <D> <X> -type f <F> -exec rg <C> --no-heading -H  <R> /dev/null {} +")

如果您想使用 rg 而不使用 find,则必须使用 lgrep 并自定义:

(grep-apply-setting 'grep-template "rg --no-heading -H -uu -g <F> <R> <D>")

关于utf-8 - Emacs 中的 Rgrep 使用 ripgrep,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45526670/

相关文章:

python - 检查我的提交在 emacs/git 中是否有 'import pdb'?

encoding - 使用 PhpStorm/WinSCP 和 SFTP 的文件名编码错误

r - Emacs ESS 模式 TAB 停止缩进

emacs 自定义命令行参数

正则表达式,仅包含 1 个字符的 grep 行

regex - Grep 语法困境

linux - 从 bash 搜索 jar 或 tar

c# - 如何将经过 UTF-8 编码两次的字符串解码为简单的 UTF-8?

php - MYSQL - 使用 CRYPT 进行散列时出现特殊字符问题

python - 打开 URL 时解码响应