Closed slayer152 closed 2 years ago
Oh, boy, I think I must have only tested with project-find-regexp
! There indeed seem to be problems with dired-do-find-regexp
.
I figured out that some small part of the problem is not my fault 😛. Refresh doesn't seem to work correctly for the xref buffer produced by dired-do-find-regexp
! Try this experiment:
Go back to the default settings:
(setq xref-show-xrefs-function #'xref--show-xref-buffer
xref-show-definitions-function #'xref-show-definitions-buffer)
Run dired
, mark more than one file, and use dired-do-find-regexp
. Then refresh the resulting xref buffer. What happens on my machine is that, after refreshing, only the results from the first file remain, the other files aren't taken into account it seems.
Great! Time for report-emacs-bug
! Fortunately xref is available via ELPA so people can profit soon from potential fixes.
I reported it.
And I've figured out the part that was my fault!
@slayer152 said that reverting the xref buffer would open the first marked file and erase it's contents. It took me a few tries to reproduce that and it only happened by a combination of circumstances:
consult-xref
doesn't even open the minibuffer (which I was counting on), but instead jumps right to it.xref-revert-buffer
takes over, not suspecting that consult-xref
changed the current buffer from the xref buffer to the first marked file, deletes the entire buffer's contents!I've implemented a fix: in case rerunning the fetcher produces 0 or 1 items, I don't call consult-xref
but return the items directly. This way we won't delete any unsuspecting buffer's contents, but the revert won't feel fully correct since it will only use the regexp and not the minibuffer input you gave to consult-xref prior to exporting. But that's definitely better than deleting a buffer's contents!
Fixed in oantolin/embark@70f720f914b78bd11f84b0790df5f125945dd50f
...What happens on my machine is that after refreshing only the results from the first file remain, the other files aren't taken into account it seems...I reported it.
Indeed, I see the same behavior with default settings. Thanks for reporting it and it looks like Lars Ingebrigtsen has already addressed it.
I've implemented a fix....But that's definitely better than deleting a buffer's contents!
Definitely. Thank you very much for the quick fix.
Hi Daniel,
I'm not sure if this is a consult issue or an embark issue or something else; please let me know if it should be moved or I need to customize something.
Repro with
emacs -Q
:With the above config, if I:
M-x dired
and select a directoryM-x dired-do-find-regexp
and provide a regexp, I get a minibuffer prompt Go to xref: with a list of the results.embark-export
on the list of results, I get a normal Embark Collect buffer with major-mode asembark-collect-mode
(and notxref--xref-buffer-mode
which would allow me to useM-g M-n
andM-g M-p
compilation-mode-like bindings to navigate the results).However, If I don't use the above 2
setq xref-show...
bindings and I runM-x dired-do-find-regexp
and provide a regexp in step-3, I directly get a buffer with major-mode asxref--xref-buffer-mode
which allows me to useM-g M-n
andM-g M-p
bindings to navigate the results. Would it be possible to useconsult-xref
and alsoembark-export
to axref--xref-buffer-mode
buffer if needed.Thanks.