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

猫哥, 你截图的右侧那些小色块是什么东西呀?

mac的一个取色工具

噢噢噢 :grin:

你的问题修复了吗?

1赞

我在试用这个插件时遇到了和Shadow-e190一样的问题; 提了个ISSUE:

网络有点问题,github上的图似乎无法上传,补在这里;

搜索结果:

替换后color-rg这个buffer的内容

替换后文件的内容:

20200223_2025_capture

这个替换利用的函数好像是:isearch-query-replace 如果不做设置,需要再次确认如: 表示全部替换

具体快捷按键如下:

Type Space or ‘y’ to replace one match, Delete or ‘n’ to skip to next,

RET or ‘q’ to exit, Period to replace one match and exit,

Comma to replace but not move point immediately,

C-r to enter recursive edit (C-M-c to get out again),

C-w to delete match and recursive edit,

C-l to clear the screen, redisplay, and offer same replacement again,

! to replace all remaining matches in this buffer with no more questions,

^ to move point back to previous match,

u to undo previous replacement,

U to undo all replacements,

E to edit the replacement string.

In multi-buffer replacements type ‘Y’ to replace all remaining

matches in all remaining buffers with no more questions,

‘N’ to skip to the next buffer without replacing remaining matches

in the current buffer.

1赞

r表示进入替换,按 y 或者 n 来表示是否替换当前行,按!替换所有。 这个和Emacs的行为一致,不是bug.

1赞

视频没了?已经找不到了。

我现在使用 rg.el 和deadgrep 来 替换 color-rg 插件,很好用

我使用color-rg搜索关键字结束后,搜索结果自动闪退。这个怎么回事。还是说默认就是这样的。我的环境是spacemacs, Manjaro系统, emacs 28.

请用 emacs -Q 先排查 请用 emacs -Q 先排查 请用 emacs -Q 先排查 请用 emacs -Q 先排查 请用 emacs -Q 先排查

已经解决了。我对compile添加了如下的配置导致compile闪退。

;; {{{ compile command
(defun notify-compilation-result(buffer msg)
  "Notify that the compilation is finished,
close the *compilation* buffer if the compilation is successful,
and set the focus back to Emacs frame"
  (if (string-match "^finished" msg)
      (progn
        (delete-windows-on buffer)
        (tooltip-show "\n Compilation Successful :-) \n "))
    (tooltip-show "\n Compilation Failed :-( \n "))
  (setq current-frame (car (car (cdr (current-frame-configuration)))))
  (select-frame-set-input-focus current-frame)
  )

(add-to-list 'compilation-finish-functions
               'notify-compilation-result)

(require 'compile)
(add-hook 'sh-mode-hook
          (lambda ()
            (set (make-local-variable 'compile-command)
                 (format "bash %s" (file-name-nondirectory buffer-file-name)))))
(add-hook 'python-mode-hook
          (lambda ()
            (set (make-local-variable 'compile-command)
                 (format "python %s" (file-name-nondirectory buffer-file-name)))))

(global-set-key (kbd "<f6>") 'compile)
      (lambda ()
        (set (make-local-variable 'compile-command)
             (format "python %s" (file-name-nondirectory buffer-file-name)))))

(global-set-key (kbd “”) 'compile)

```

大神抱歉啊。

这两功能似乎是重复的呀,你一起使用?

最常使用的是 deadgrep,rg.el 也没删。感觉两个都很好用,都非常优秀,舍不得删

我最常用的是 counsel-rg,对大量搜索结果的用 rg.el。感觉 rg.el 的菜单选项更好用,方便切换各种选项。

能问一下,color-rg是不是不支持widows下的中文搜索啊。因为我发现在linux下正常使用,在windows上面好像中文无法检索

我不用windows,欢迎补丁

再搜索文本的时候,color-rg buffer里面出现部分内容貌似乱码,请看下面图片。

emacs提示“error in process filter: compilation-get-file-structure: Wrong type argument: hash-table-p, nil error in process filter: Wrong type argument: hash-table-p, nil ”

麻烦给一下详细的重现步骤,这个步骤不是很清晰,谢谢。