请教consult-ripgrep的过滤规则

请教各位, consult-ripgrep 查找完之后,如果我想屏蔽拥有某个字符的结果行,应该怎么操作 在哪可以查看它的完整的过滤规则呢

如果没有主动修改或被其他包修改的,直接查找consult包主文件consult.el:

lines from buffer: consult.el:

    251:(defcustom consult-grep-args
    259:(defcustom consult-git-grep-args
    267:(defcustom consult-ripgrep-args
    275:(defcustom consult-find-args
    282:(defcustom consult-locate-args
    289:(defcustom consult-man-args

其中 consult-ripgrep-args:

(defcustom consult-ripgrep-args
  "rg --null --line-buffered --color=never --max-columns=1000 --path-separator /\
   --smart-case --no-heading --line-number ."
  "Command line arguments for ripgrep, see `consult-ripgrep'.
The dynamically computed arguments are appended.
Can be either a string, or a list of strings or expressions."
  :type '(choice string (repeat (choice string expression))))

前置一个感叹号可以过滤字符:

1 个赞

感谢解答,不过我这还是没法过滤。我的配置是官网直接抄的,没有改动过的。还有我想知道的是consult-ripgrep的过滤方法呢 :joy:

刚测试了下,!在 consult-ripgrep 可以使用。

不过我这儿consult模块自定义的内容比较多,不敢说其他人也可以使用。

更新:往楼下翻几层可以找到使 “!” 在consult 中生效的办法:orderless。

README也没提供 ! 的说明,总之以个人测试为准。

搜索模块语法直达:

明白了,感谢前辈解惑,起码知道了是可以过滤的。具体要怎么实现我自己再摸索摸索 :joy:

可能是结合了 orderless ,可以看 wiki 的示例。

确实应该是 orderless 的配置

  (defun without-if-bang (pattern _index _total)
    (cond
     ((equal "!" pattern)
      '(orderless-literal . ""))
     ((string-prefix-p "!" pattern)
      `(orderless-without-literal . ,(substring pattern 1)))))
  (add-to-list 'orderless-style-dispatchers #'without-if-bang)

2 个赞

按楼上配置确实可以,再次感谢各位前辈解答 :+1: :+1: :+1: