基于 ripgrep 的代码搜索和重构工具

挫见:在浏览器和服务器间传递任何参数都没有编码问题,因为浏览器把所有中文参数做了url编码,emacs在调用命令行工具时是否可以也效仿浏览器做法用url编码,我用(url-encode-url)处理了flycheck不支持中文文件名的问题, 但ripgrep估计没有url编码支持

请问color-rg-rerun是重复上一次搜索吗?

(setcar compilation-arguments
            (color-rg-build-command keyword dir globs literal no-ignore case-sensitive file-exclude))

我运行的时候compilation-arguments为nil

不是,是生成了color-Rg buffer后,重新搜索一遍,更新结果。你想要的是类似ivy-resume吧,目前还没有实现的函数可以直接用

哦,谢谢,那我HACK下不关掉color-rg,也可以暂时用下。

您好,macos Big Sur在emacs中使用color-rg 的view mode 中,命令color-rg-jump-prev-keyword 在有些行结果数中间的行会卡住,不知道为什么呢?比如说 color-rg 过滤结果Buffer的一半位置卡住

emacs -Q 模式,只载入exec-path-from-shell.el和 color-rg.el,emacs 27 和 28 都不行。 录了一个gif。。有点大没传上来

最好有重现文件或目录,方便我调查原因

这个问题我也遇到了,不知道您是否解决了

@manateelazycat 懒猫大神,我也遇到了 @CheungHsu

您好,macos Big Sur在emacs中使用color-rg 的view mode 中,命令color-rg-jump-prev-keyword 在 有些行 结果数中间的行 会卡住,不知道为什么呢?比如说 color-rg 过滤结果Buffer的一半位置卡住

emacs -Q 模式,只载入exec-path-from-shell.el和 color-rg.el,emacs 27 和 28 都不行。 录了一个gif。。有点大没传上来

类似的问题,我 emacs -Q 进行了测试,只 (require 'color-rg),在一个单一的 .org 文件执行命令 color-rg-search-input-in-current-file, 仍会出现这个问题。

测试的 org 文件在链接获得:https://drive.google.com/file/d/1lWFmrhXbFEIZICW-ZsuFiHPRYqK-UVPA/view?usp=sharing

在文件中搜索 rsync 关键词,命令 color-rg-search-input-in-current-file

文件无法访问

不好意思,忘记设置访问权限了,现在这个链接应该可以访问了

更新一下最新的版本应该就可以了,是 color-rg-max-column 默认太小的原因,我从 300 调成 3000了。

我在有些文件夹ok,在有些不行,所以转向了occur+wgrep+iedit。现在我来设置一下max-column试一试.

@manateelazycat 我还发现一个按键绑定的问题,我用的vim键位风格,所以默认绑定有点别扭。我自己交换一下键位舒服一点,貌似与vim风格更妥帖

  :bind (:color-rg-mode-map
         ("h" . color-rg-jump-prev-file)
         ("l" . color-rg-jump-next-file))

按键自己定义吧,没有绝对的舒服,特别是对于 emacser, 一万个人有一万种按键

好的。看了你的那个用submodule管理的方法,magit-submodule-add/remove真的很方便!

wsl Linux挺好用的,速度比cygwin emacs快很多。

http://kimi.im/2021-01-28-emacs-inside-manjaro-wsl2-windows

没有问题了,多谢懒猫大神!

就正常使用 color-rg-search-input 返回错误,不知道什么原因 图片

toggle-on-debug 命令看看哪行代码错了?

我手机上打字,你看看minibuffer补全是啥名字吧。

图片

Debugger entered–Lisp error: (wrong-type-argument hash-table-p nil) gethash((“unknown”) nil) compilation-get-file-structure((“unknown”) nil) compilation-internal-error-properties((“unknown”) 15 nil nil nil 0 nil) compilation-error-properties(nil 2 nil nil nil 0 nil) compilation-parse-errors(1 #<marker at 479 in color-rg>) compilation–parse-region(1 #<marker at 479 in color-rg>) compilation–ensure-parse(479) #f(compiled-function (proc string) “Process filter for compilation buffers.\nJust inserts the text,\nhandles carriage motion (see comint-inhibit-carriage-motion'),\nand runs compilation-filter-hook’.” #<bytecode 0x158bd17e4ab9>)(# #(“/home/sniper/.emacs.d/site-lisp/color-rg/color-rg…” 0 52 (xterm-color t font-lock-face (:foreground “#d3869b”)) 53 56 (xterm-color t font-lock-face (:foreground “#98971a”)) 74 97 (xterm-color t font-lock-face (:foreground “#d65d0e”)) 98 101 (xterm-color t font-lock-face (:foreground “#98971a”)) 142 165 (xterm-color t font-lock-face (:foreground “#d65d0e”)) 167 171 (xterm-color t font-lock-face (:foreground “#98971a”)) 181 204 (xterm-color t font-lock-face (:foreground “#d65d0e”)))) funcall(#f(compiled-function (proc string) “Process filter for compilation buffers.\nJust inserts the text,\nhandles carriage motion (see comint-inhibit-carriage-motion'),\nand runs compilation-filter-hook’.” #<bytecode 0x158bd17e4ab9>) # #(“/home/sniper/.emacs.d/site-lisp/color-rg/color-rg…” 0 52 (xterm-color t font-lock-face (:foreground “#d3869b”)) 53 56 (xterm-color t font-lock-face (:foreground “#98971a”)) 74 97 (xterm-color t font-lock-face (:foreground “#d65d0e”)) 98 101 (xterm-color t font-lock-face (:foreground “#98971a”)) 142 165 (xterm-color t font-lock-face (:foreground “#d65d0e”)) 167 171 (xterm-color t font-lock-face (:foreground “#98971a”)) 181 204 (xterm-color t font-lock-face (:foreground “#d65d0e”)))) my-advice-compilation-filter(#f(compiled-function (proc string) “Process filter for compilation buffers.\nJust inserts the text,\nhandles carriage motion (see comint-inhibit-carriage-motion'),\nand runs compilation-filter-hook’.” #<bytecode 0x158bd17e4ab9>) # “\33[0m\33[35m/home/sniper/.emacs.d/site-lisp/color-rg/…”) apply(my-advice-compilation-filter #f(compiled-function (proc string) “Process filter for compilation buffers.\nJust inserts the text,\nhandles carriage motion (see comint-inhibit-carriage-motion'),\nand runs compilation-filter-hook’.” #<bytecode 0x158bd17e4ab9>) (# “\33[0m\33[35m/home/sniper/.emacs.d/site-lisp/color-rg/…”)) compilation-filter(# “\33[0m\33[35m/home/sniper/.emacs.d/site-lisp/color-rg/…”)