From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#49731: 28.0.50; Filter xref results by filename Date: Tue, 04 Jun 2024 09:34:24 +0300 Organization: LINKOV.NET Message-ID: <86jzj5i5mh.fsf@mail.linkov.net> References: <87lf5urv4c.fsf@mail.linkov.net> <86fspn1pjl.fsf@mail.linkov.net> <86ilj83fik.fsf@mail.linkov.net> <86ilj6rrnq.fsf@mail.linkov.net> <16f2a5d7-fb89-5e8c-71b7-c9f9ddc5d4e3@yandex.ru> <86v86s4dsi.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5369"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 49731@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 04 08:42:53 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sENsi-0001Hm-Qb for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Jun 2024 08:42:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sENri-00089L-BM; Tue, 04 Jun 2024 02:41:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sENrg-00088z-UM for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 02:41:48 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sENrg-00070z-N3 for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 02:41:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sENrt-0005FF-PU for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 02:42:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Jun 2024 06:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49731 X-GNU-PR-Package: emacs Original-Received: via spool by 49731-submit@debbugs.gnu.org id=B49731.171748326720080 (code B ref 49731); Tue, 04 Jun 2024 06:42:01 +0000 Original-Received: (at 49731) by debbugs.gnu.org; 4 Jun 2024 06:41:07 +0000 Original-Received: from localhost ([127.0.0.1]:56200 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sENr1-0005Do-6v for submit@debbugs.gnu.org; Tue, 04 Jun 2024 02:41:07 -0400 Original-Received: from relay2-d.mail.gandi.net ([217.70.183.194]:37149) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sENqw-0005D0-Mx for 49731@debbugs.gnu.org; Tue, 04 Jun 2024 02:41:06 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id F238B4000A; Tue, 4 Jun 2024 06:40:21 +0000 (UTC) In-Reply-To: <86v86s4dsi.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 13 Feb 2024 18:52:29 +0200") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286517 Archived-At: > Also there is an additional helper function that is needed > to keep hidden outlines and restore them after reverting the > xref buffer with 'g' (xref-revert-buffer). > This is an example of advice that does this. > Later when xref will use revert-buffer-function, > this advice could be replaced by a simple hook call: > > #+begin_src emacs-lisp > (define-advice xref-revert-buffer (:around (ofun &rest args) keep-outlines) > "Keep hidden outlines after xref revert." > (let ((regexp (outline-hidden-headings-regexp)) > (value (apply ofun args))) > (outline-hide-by-heading-regexp regexp) > value)) > #+end_src So here is the patch for xref: diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 0025f1f9479..0a5c9243027 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1277,13 +1277,18 @@ xref-revert-buffer "Refresh the search results in the current buffer." (interactive) (let ((inhibit-read-only t) - (buffer-undo-list t)) + (buffer-undo-list t) + restore-functions) + (when (boundp 'revert-buffer-restore-functions) + (run-hook-wrapped 'revert-buffer-restore-functions + (lambda (f) (push (funcall f) restore-functions) nil))) (save-excursion (condition-case err (let ((alist (xref--analyze (funcall xref--fetcher))) (inhibit-modification-hooks t)) (erase-buffer) - (xref--insert-xrefs alist)) + (prog1 (xref--insert-xrefs alist) + (mapc #'funcall (delq nil restore-functions)))) (user-error (erase-buffer) (insert