emacs-diffs
[Top][All Lists]
Advanced

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

master 2cdf80bb8f5 1/2: * lisp/progmodes/xref.el: Show the number of mat


From: Juri Linkov
Subject: master 2cdf80bb8f5 1/2: * lisp/progmodes/xref.el: Show the number of matches on mode-line (bug#66332)
Date: Mon, 9 Oct 2023 14:11:31 -0400 (EDT)

branch: master
commit 2cdf80bb8f56110b45dbde3e22dfa69d6f1fdc9c
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/progmodes/xref.el: Show the number of matches on mode-line 
(bug#66332)
    
    (xref-num-matches-found, xref-num-matches-face, xref-mode-line-matches):
    New variables.
    (xref--show-xref-buffer): Set xref-num-matches-found to the length of xrefs,
    and buffer-local mode-line-process to xref-mode-line-matches.
---
 lisp/progmodes/xref.el | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index b7bfb192d87..fd788ec8f32 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -638,6 +638,18 @@ If SELECT is non-nil, select the target window."
   "Face used to highlight matches in the xref buffer."
   :version "28.1")
 
+(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)
+
 (defmacro xref--with-dedicated-window (&rest body)
   `(let* ((xref-w (get-buffer-window xref-buffer-name))
           (xref-w-dedicated (window-dedicated-p xref-w)))
@@ -1235,6 +1247,8 @@ Return an alist of the form ((GROUP . (XREF ...)) ...)."
       (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))



reply via email to

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