From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#66332: Xref mode-line Date: Fri, 06 Oct 2023 09:59:51 +0300 Organization: LINKOV.NET Message-ID: <86bkdcw6mo.fsf@mail.linkov.net> References: <867co2c3p4.fsf@mail.linkov.net> <86y1gi9vdx.fsf@mail.linkov.net> <29cc81a6-0629-38d9-e69e-c7934432cf47@gutov.dev> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29421"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 66332@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 06 09:33:01 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qofKX-0007WE-6c for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 06 Oct 2023 09:33:01 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qofKI-0007rO-QL; Fri, 06 Oct 2023 03:32:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qofKG-0007mU-CQ for bug-gnu-emacs@gnu.org; Fri, 06 Oct 2023 03:32:44 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qofKG-0003AW-3g for bug-gnu-emacs@gnu.org; Fri, 06 Oct 2023 03:32:44 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qofKY-0005U3-K9 for bug-gnu-emacs@gnu.org; Fri, 06 Oct 2023 03:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Oct 2023 07:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66332 X-GNU-PR-Package: emacs Original-Received: via spool by 66332-submit@debbugs.gnu.org id=B66332.169657754021021 (code B ref 66332); Fri, 06 Oct 2023 07:33:02 +0000 Original-Received: (at 66332) by debbugs.gnu.org; 6 Oct 2023 07:32:20 +0000 Original-Received: from localhost ([127.0.0.1]:49068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qofJr-0005Sy-LG for submit@debbugs.gnu.org; Fri, 06 Oct 2023 03:32:19 -0400 Original-Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]:45727) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qofJm-0005Sh-0i for 66332@debbugs.gnu.org; Fri, 06 Oct 2023 03:32:18 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id D00341BF208; Fri, 6 Oct 2023 07:31:47 +0000 (UTC) In-Reply-To: <29cc81a6-0629-38d9-e69e-c7934432cf47@gutov.dev> (Dmitry Gutov's message of "Wed, 4 Oct 2023 20:18:00 +0300") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271932 Archived-At: --=-=-= Content-Type: text/plain >>>> 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=xref-num-matches-found.patch 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)) --=-=-=--