[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#66332: Xref mode-line
From: |
Juri Linkov |
Subject: |
bug#66332: Xref mode-line |
Date: |
Fri, 06 Oct 2023 09:59:51 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
>>>> grep-mode shows the number of matches on the mode-line.
>>>> Could xref do the same?
>>> Certainly.
>>>
>>> This should be especially useful later, when we make it update
>>> asynchronously.
>> Should I look into the implementation, or you already know how it could work?
>
> I might not get around to this until after the next few weeks, so you're
> welcome to take initiative.
Ok, here is the initial version based on grep/compilation variables:
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index b7bfb192d87..dbf013bdba2 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -626,6 +626,18 @@ xref-pop-to-location
(defconst xref-buffer-name "*xref*"
"The name of the buffer to show xrefs.")
+(defvar-local xref-num-matches-found 0)
+
+(defvar xref-num-matches-face 'compilation-info
+ "Face name to show the number of matches on the mode line.")
+
+(defconst xref-mode-line-matches
+ `(" [" (:propertize (:eval (int-to-string xref-num-matches-found))
+ face ,xref-num-matches-face
+ help-echo "Number of matches so far")
+ "]"))
+(put 'xref-mode-line-matches 'risky-local-variable t)
+
(defface xref-file-header '((t :inherit compilation-info))
"Face used to highlight file header in the xref buffer."
:version "27.1")
@@ -1235,6 +1229,8 @@ 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)))
(xref--auto-jump-first buf (assoc-default 'auto-jump alist))