unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 74313@debbugs.gnu.org
Cc: Dmitry Gutov <dmitry@gutov.dev>
Subject: bug#74313: [PATCH] Update 'xref-num-matches-found' when reverting *xref* buffer
Date: Mon, 11 Nov 2024 20:16:22 +0100	[thread overview]
Message-ID: <m18qtpd1ix.fsf@macbookpro.home> (raw)

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

Tags: patch

Hi,

The *xref* buffer displays the number of found matches in the mode line.
With this patch, it also updates that number, stored in variable
xref-num-matches-found, when you revert the buffer.  That way the mode
line shows the updated number of matches when you add or delete some
references and revert the *xref* buffer.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Update-xref-num-matches-found-when-reverting-xref-bu.patch --]
[-- Type: text/patch, Size: 1786 bytes --]

From 47fb809c858ee4fb18283350a4af6d9c7c33a8fb Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@eshelyaron.com>
Date: Mon, 11 Nov 2024 19:45:10 +0100
Subject: [PATCH] Update 'xref-num-matches-found' when reverting *xref* buffer

* lisp/progmodes/xref.el (xref--insert-xrefs): Update
'xref-num-matches-found' here...
(xref--show-xref-buffer): ...instead of here.
---
 lisp/progmodes/xref.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index cc06e06ef78..cf061a18ee0 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1139,6 +1139,7 @@ xref--insert-xrefs
 GROUP is a string for decoration purposes and XREF is an
 `xref-item' object."
   (require 'compile) ; For the compilation faces.
+  (setq xref-num-matches-found 0)
   (cl-loop for (group . xrefs) in xref-alist
            for max-line = (cl-loop for xref in xrefs
                                    maximize (xref-location-line
@@ -1158,6 +1159,7 @@ xref--insert-xrefs
            (xref--insert-propertized '(face xref-file-header xref-group t)
                                      group "\n")
            (dolist (xref xrefs)
+             (cl-incf xref-num-matches-found)
              (pcase-let (((cl-struct xref-item summary location) xref))
                (let* ((line (xref-location-line location))
                       (prefix
@@ -1247,7 +1249,6 @@ xref--show-xref-buffer
       (xref--ensure-default-directory dd (current-buffer))
       (xref--xref-buffer-mode)
       (xref--show-common-initialize xref-alist fetcher alist)
-      (setq xref-num-matches-found (length xrefs))
       (setq mode-line-process (list xref-mode-line-matches))
       (pop-to-buffer (current-buffer))
       (setq buf (current-buffer)))
-- 
2.46.2


             reply	other threads:[~2024-11-11 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 19:16 Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-11-14  2:28 ` bug#74313: [PATCH] Update 'xref-num-matches-found' when reverting *xref* buffer Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m18qtpd1ix.fsf@macbookpro.home \
    --to=bug-gnu-emacs@gnu.org \
    --cc=74313@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=me@eshelyaron.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).