This is going to be a small correction to my previous post about Ugrep and project navigation.

If you remember, I was using xref-show-definitions-completing-read to make project-find-regexp offer its results in the minibuffer. The problem with that command is that the results are grouped by file, which is good, but within the groups they do not appear to be sorted by line number, which is not so good.

However, since I am already using consult the solution is right behind the corner.

(defun mu-project-find-regexp ()
  "Use `project-find-regexp' with completion."
  (defvar xref-show-xrefs-function)
  (let ((xref-show-xrefs-function #'consult-xref))
    (if-let ((tap (thing-at-point 'symbol)))
        (project-find-regexp tap)
      (call-interactively #'project-find-regexp))))

The documentation of consult-xref itself is pretty clear.

Show xrefs with preview in the minibuffer.

This function can be used for ‘xref-show-xrefs-function’.

Now the only thing left is saying “Thank you, Daniel Mendler!” one more time for all his beautiful work.