Idea征集:改进lsp-ui-doc

你的命令行是啥样子?

请教一下,插入(debug) ,然后想要显示command-line或者(delete-dups command-line)的信息该如何debug?

(message command-line)会显示输入类型错误。

直接 toggle-debug-on-error 以后, 报错的时候自动会把堆栈弄出来.

不好意哈,没怎么调过elisp,打扰您了。在这种情况下,我该怎么样尝试去debug,进而达到你的显示的效果,打开toggle-debug-on-error后,运行M-x color-rg-search-input是没有error的,当尝试M-x color-rg-open-file出现error

你其实没有看我上面那么多回复.

我的意思是, color-rg 搜索的时候会在顶部打印命令, 你能否把这些命令拷贝到终端模拟器中执行?

我先看一下你的 ripgrep 在终端模拟器中是否是按照分组模式来渲染的?

这样我才好判断是否是 color-rg.el 的问题还是 ripgrep 的问题

以为首先是你在 windows 的显示模式不对才导致你遇到的错误, 只有 ripgrep 的显示正确了才能去排除 color-rg.el 的问题, 看着你的截图, 你的 ripgrep 输出就不对, 你再怎么调试 color-rg.el 都没用, 因为根本就不是 color-rg.el 的代码出了问题.

其实你的回复我都看了,也知道从哪里开始,结束是有什么效果(相同文件,只显示一个文件名,按照行号和列号标明每一个出现的字段, 这步工作需要把ripgrep返回的结果reduce到一个结果中), 我不能像您一样知道每一个字节都怎样流动而已。

我的ripgrep有问题? 您那边显示的riggrep是什么样式(分组模式如何开启)?也许我改一下ripgrep的配置就可以更正过来。

image

我第一帖就发了我这边的样子, 如果分组正确, 每一条匹配只显示行号和列号, 不会在行号左边显示文件路径, 如果不显示路劲, 你说的问题就不存在.

Mac/Linux 下默认就是长这个样子的, 我不知道分组模式怎么打开和在windows下要怎么玩.

所以, 我的建议:

  1. 你先把 windows 下 ripgrep 行号左边不显示路径的命令参数研究出来, 把这个参数加到 color-rg-build-command 里面再运行 color-rg.el 直接就好了
  2. 如果参数正确还有错误, 就执行 toggle-debug-on-error , 把堆栈分享出来

你按照这两个步骤, 我才好帮助你分析问题, 我已经十几年没有用 windows 了, 很难直接帮到你.

默认情况下,rg是分组显示。您看到的上面我的截图不是分组,因为存在–vimgrep选项。

而color-rg.el执行的命令是: rg -i --column --color=always --smart-case -e “color-rg” c:/Users/yzl/AppData/Roaming/.emacs.d/customizations/color-rg/

在windows下的cmd没问题(linux和macs据作者说也没问题),但是emacs调用的是eshell,在eshell输入上面命令行依然不是分组模式显示(每行都有文件路径名:行号:列号)

结论是: 在windows emacs中,需要在color-rg-build-command强制添加*–heading**选项,表示的意思是Print matches grouped by each file。

然后显示就正常,常用函数也可以使用。:grinning:

谢谢manateelazycat!

3 个赞

这才是解决问题的正确方法嘛, 好在你终于明白了.

我推送了一个补丁, 强制使用分组了: Add `--heading' option force to make group matches work always to sup… · manateelazycat/color-rg@cd1ed39 · GitHub

1 个赞

不是唯一方式,但用 package 方式对于用户来讲还是最方便快捷的,维护升级也更方便。分享的话个人认为还是更好的方式。

我不关心,为什么我一定要用package?

color-rg-jump-next-file(h) 报Reach to last file提示(但其实下面哎呦很多file)

color-rg-jump-next-file(l) 报Reach to first file提示 (当前光标前面还有其他文件)

Ret 无法跳转到光标下的文件位置,这也导致r命令无法修改到对应位置(windows下使用各种问题—我事先把evil-mode关掉了。:joy:)。

j,k使用时正常的

next-file只到文件分组,移动到最后一行要 j 和 k

感谢回复,基本了解了差异。 今天试用了一下,功能除了第4点外其实大同小异。理念上有所差异,使用效果上差别不大。 恕我直言,细节上还是差一些。比如和主题的契合度,重新搜索的方便程度等等。其他都还是不错的,全凭喜好了。

每个人都有自己选择的自由

@seagle0128 你的wgrep在进行修改后有没有出现 change cannot applied 的情况?(尝试了重装helm,helm,restart emacs, reinstall wgrep,restart emacs,没用)

Changes are not applied when using (wgrep-finish-edit) function. · Issue #36 · mhayashi1120/Emacs-wgrep · GitHub

你的ivy的配置不错,抄了一下:blush:

第3个问题, 就搜索完之后, 在搜索结果窗口里某一行上按x,

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("" nil)
  (and (or non-prefix-dot (and (> (length name) 0) (if (= (aref ido-text 0) 46) (= (aref name 0) 46) (/= (aref name 0) 46)))) (string-match re name))
  (if (and (or non-prefix-dot (and (> (length name) 0) (if (= (aref ido-text 0) 46) (= (aref name 0) 46) (/= (aref name 0) 46)))) (string-match re name)) (cond ((and (eq ido-cur-item (quote buffer)) (> (length re) 0) (string-match ".*/" name) (not (string-match re name (match-end 0)))) (setq bad-matches (cons item bad-matches))) ((and (eq ido-cur-item (quote buffer)) (or (not (stringp ido-default-item)) (not (string= name ido-default-item))) (string= name (buffer-name ido-entry-buffer))) (setq matches (cons item matches))) ((and full-re (string-match full-re name)) (setq full-matches (cons item full-matches))) ((and suffix-re (string-match suffix-re name)) (setq suffix-matches (cons item suffix-matches))) ((and prefix-re (string-match prefix-re name)) (setq prefix-matches (cons item prefix-matches))) (t (setq matches (cons item matches)))))
  (let ((name (ido-name item))) (if (and (or non-prefix-dot (and (> (length name) 0) (if (= (aref ido-text 0) 46) (= (aref name 0) 46) (/= (aref name 0) 46)))) (string-match re name)) (cond ((and (eq ido-cur-item (quote buffer)) (> (length re) 0) (string-match ".*/" name) (not (string-match re name (match-end 0)))) (setq bad-matches (cons item bad-matches))) ((and (eq ido-cur-item (quote buffer)) (or (not (stringp ido-default-item)) (not (string= name ido-default-item))) (string= name (buffer-name ido-entry-buffer))) (setq matches (cons item matches))) ((and full-re (string-match full-re name)) (setq full-matches (cons item full-matches))) ((and suffix-re (string-match suffix-re name)) (setq suffix-matches (cons item suffix-matches))) ((and prefix-re (string-match prefix-re name)) (setq prefix-matches (cons item prefix-matches))) (t (setq matches (cons item matches))))))
  (lambda (item) (let ((name (ido-name item))) (if (and (or non-prefix-dot (and (> (length name) 0) (if (= ... 46) (= ... 46) (/= ... 46)))) (string-match re name)) (cond ((and (eq ido-cur-item (quote buffer)) (> (length re) 0) (string-match ".*/" name) (not (string-match re name ...))) (setq bad-matches (cons item bad-matches))) ((and (eq ido-cur-item (quote buffer)) (or (not ...) (not ...)) (string= name (buffer-name ido-entry-buffer))) (setq matches (cons item matches))) ((and full-re (string-match full-re name)) (setq full-matches (cons item full-matches))) ((and suffix-re (string-match suffix-re name)) (setq suffix-matches (cons item suffix-matches))) ((and prefix-re (string-match prefix-re name)) (setq prefix-matches (cons item prefix-matches))) (t (setq matches (cons item matches)))))) t)(nil)
  mapc((lambda (item) (let ((name (ido-name item))) (if (and (or non-prefix-dot (and (> ... 0) (if ... ... ...))) (string-match re name)) (cond ((and (eq ido-cur-item ...) (> ... 0) (string-match ".*/" name) (not ...)) (setq bad-matches (cons item bad-matches))) ((and (eq ido-cur-item ...) (or ... ...) (string= name ...)) (setq matches (cons item matches))) ((and full-re (string-match full-re name)) (setq full-matches (cons item full-matches))) ((and suffix-re (string-match suffix-re name)) (setq suffix-matches (cons item suffix-matches))) ((and prefix-re (string-match prefix-re name)) (setq prefix-matches (cons item prefix-matches))) (t (setq matches (cons item matches)))))) t) ("txt" "el" "md" "status" nil "sh" "man" "4" "m4" "c" "h"))
  (condition-case error (mapc (function (lambda (item) (let ((name (ido-name item))) (if (and (or non-prefix-dot ...) (string-match re name)) (cond (... ...) (... ...) (... ...) (... ...) (... ...) (t ...)))) t)) items) (invalid-regexp (setq ido-incomplete-regexp t matches (cdr error))))
  (let* ((case-fold-search ido-case-fold) (slash (and (not ido-enable-prefix) (ido-final-slash ido-text))) (text (if slash (substring ido-text 0 -1) ido-text)) (rex0 (if ido-enable-regexp text (replace-regexp-in-string " +" ".*" (regexp-quote text) t t))) (rexq (concat rex0 (if slash ".*/" ""))) (re (if ido-enable-prefix (concat "\\`" rexq) rexq)) (full-re (and do-full (not (and (eq ido-cur-item (quote buffer)) ido-buffer-disable-smart-matches)) (not ido-enable-regexp) (not (string-match "$\\'" rex0)) (concat "\\`" rex0 (if slash "/" "") "\\'"))) (suffix-re (and do-full slash (not (and (eq ido-cur-item (quote buffer)) ido-buffer-disable-smart-matches)) (not ido-enable-regexp) (not (string-match "$\\'" rex0)) (concat rex0 "/\\'"))) (prefix-re (and full-re (not ido-enable-prefix) (concat "\\`" rexq))) (non-prefix-dot (or (not ido-enable-dot-prefix) (not ido-process-ignore-lists) ido-enable-prefix (= (length ido-text) 0))) full-matches suffix-matches prefix-matches matches bad-matches) (setq ido-incomplete-regexp nil) (condition-case error (mapc (function (lambda (item) (let ((name ...)) (if (and ... ...) (cond ... ... ... ... ... ...))) t)) items) (invalid-regexp (setq ido-incomplete-regexp t matches (cdr error)))) (if bad-matches (progn (ido-trace "bad match" (list text re bad-matches)) (setq matches (nconc matches bad-matches)))) (if prefix-matches (progn (ido-trace "prefix match" prefix-matches) (setq matches (nconc prefix-matches matches)))) (if suffix-matches (progn (ido-trace "suffix match" (list text suffix-re suffix-matches)) (setq matches (nconc suffix-matches matches)))) (if full-matches (progn (ido-trace "full match" (list text full-re full-matches)) (setq matches (nconc full-matches matches)))) (if (and (null matches) ido-enable-flex-matching (> (length ido-text) 1) (not ido-enable-regexp)) (progn (setq re (concat (regexp-quote (string (aref ido-text 0))) (mapconcat (function (lambda ... ...)) (substring ido-text 1) ""))) (if ido-enable-prefix (setq re (concat "\\`" re))) (mapc (function (lambda (item) (let (...) (if ... ...)))) items))) (delete-consecutive-dups matches t))
  ido-set-matches-1(("txt" "el" "md" "status" nil "sh" "man" "4" "m4" "c" "h") t)
  ido-set-matches()
  ido-read-internal(list "Only display file suffix with: " nil nil nil nil)
  ido-completing-read("Only display file suffix with: " ("h" "c" "m4" "4" "man" "sh" nil "status" "md" "el" "txt"))
  (setq filter-extension (ido-completing-read (if match-files "Only display file suffix with: " "Remove file suffix with: ") file-extensions))
  (if (< (length file-extensions) 2) (message (format "Has one type files now.")) (setq filter-extension (ido-completing-read (if match-files "Only display file suffix with: " "Remove file suffix with: ") file-extensions)) (save-excursion (save-current-buffer (set-buffer color-rg-buffer) (setq remove-counter 0) (goto-char (point-min)) (while (setq end (search-forward-regexp color-rg-regexp-file nil t)) (beginning-of-line) (setq start (point)) (setq file-extension (file-name-extension (buffer-substring-no-properties start end))) (if match-files (if (string-equal file-extension filter-extension) (end-of-line) (color-rg-remove-lines-under-file)) (if (string-equal file-extension filter-extension) (color-rg-remove-lines-under-file) (end-of-line)))))))
  (let (file-extensions start end) (save-excursion (goto-char (point-min)) (while (setq end (search-forward-regexp color-rg-regexp-file nil t)) (beginning-of-line) (setq start (point)) (setq filename (buffer-substring-no-properties start end)) (end-of-line) (let* ((x (file-name-extension filename))) (if (member x file-extensions) file-extensions (setq file-extensions (cons x file-extensions)))))) (if (< (length file-extensions) 2) (message (format "Has one type files now.")) (setq filter-extension (ido-completing-read (if match-files "Only display file suffix with: " "Remove file suffix with: ") file-extensions)) (save-excursion (save-current-buffer (set-buffer color-rg-buffer) (setq remove-counter 0) (goto-char (point-min)) (while (setq end (search-forward-regexp color-rg-regexp-file nil t)) (beginning-of-line) (setq start (point)) (setq file-extension (file-name-extension (buffer-substring-no-properties start end))) (if match-files (if (string-equal file-extension filter-extension) (end-of-line) (color-rg-remove-lines-under-file)) (if (string-equal file-extension filter-extension) (color-rg-remove-lines-under-file) (end-of-line))))))))
  color-rg-filter-files(t)
  color-rg-filter-match-files()
  funcall-interactively(color-rg-filter-match-files)
  call-interactively(color-rg-filter-match-files nil nil)
  command-execute(color-rg-filter-match-files)

我这里没有出现这个错误,wgrep 很正常。估计什么包有冲突吧

BTW,欢迎来抄 :grinning:

优秀 :+1: