unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: 66332@debbugs.gnu.org
Subject: bug#66332: Xref mode-line
Date: Fri, 06 Oct 2023 09:59:51 +0300	[thread overview]
Message-ID: <86bkdcw6mo.fsf@mail.linkov.net> (raw)
In-Reply-To: <29cc81a6-0629-38d9-e69e-c7934432cf47@gutov.dev> (Dmitry Gutov's message of "Wed, 4 Oct 2023 20:18:00 +0300")

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

>>>> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xref-num-matches-found.patch --]
[-- Type: text/x-diff, Size: 1320 bytes --]

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))

  reply	other threads:[~2023-10-06  6:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04  6:20 bug#66332: Xref mode-line Juri Linkov
2023-10-04 11:35 ` Dmitry Gutov
2023-10-04 16:59   ` Juri Linkov
2023-10-04 17:18     ` Dmitry Gutov
2023-10-06  6:59       ` Juri Linkov [this message]
2023-10-06 10:10         ` Dmitry Gutov
2023-10-09 18:03           ` Juri Linkov

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=86bkdcw6mo.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=66332@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    /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).