bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49731: 28.0.50; Filter xref results by filename


From: Juri Linkov
Subject: bug#49731: 28.0.50; Filter xref results by filename
Date: Sun, 25 Jul 2021 23:43:55 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> I plan to implement a new feature for xref, but I'd like to get some
> opinions first:
>
> Sometimes an xref backend returns a lot of results spread over several
> files.  This usually happens in huge projects and for certain operations
> like "search references".  To make them more manageable, I propose a new
> command that can filter xref result groups (typically filenames) by a
> regular expression.  A user could filter by "tests/", or something like
> that, to only get results from unit tests.

I have exactly the same problem while using xref on the Emacs source tree:
most of the time I'm not interested in the results found in ChangeLog files,
so I want to ignore all ChangeLog files, and only ChangeLog files.

This problem was solved by enabling outline-minor-mode on the xref output,
then collapsing all ChangeLog entries automatically:

#+begin_src emacs-lisp
(add-hook 'xref-after-update-hook
          (lambda ()
            (setq-local outline-regexp
              (if (eq xref-file-name-display 'abs) "/" "[^ 0-9]"))
            (outline-minor-mode +1)
            (save-excursion
              (goto-char (point-min))
              (while (search-forward "ChangeLog" nil t)
                (outline-cycle)))))
#+end_src

> Right now the only approach I know for this use case is to use Isearch,
> but Isearch searches the entire xref buffer, including xref matches.

You can use isearch-filter-predicate to match only on file names.
There is an example of this feature in dired-isearch-filenames-mode.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]