* bug#74313: [PATCH] Update 'xref-num-matches-found' when reverting *xref* buffer
@ 2024-11-11 19:16 Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 2:28 ` Dmitry Gutov
0 siblings, 1 reply; 2+ messages in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-11 19:16 UTC (permalink / raw)
To: 74313; +Cc: Dmitry Gutov
[-- 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#74313: [PATCH] Update 'xref-num-matches-found' when reverting *xref* buffer
2024-11-11 19:16 bug#74313: [PATCH] Update 'xref-num-matches-found' when reverting *xref* buffer Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-14 2:28 ` Dmitry Gutov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Gutov @ 2024-11-14 2:28 UTC (permalink / raw)
To: Eshel Yaron, 74313-done
Version: 30.1
Hi!
On 11/11/2024 21:16, Eshel Yaron wrote:
> 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.
Thanks, this is a good idea.
It's a minor but noticeable bug, so I've pushed the patch to emacs-30.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-14 2:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11 19:16 bug#74313: [PATCH] Update 'xref-num-matches-found' when reverting *xref* buffer Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 2:28 ` Dmitry Gutov
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).