From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Unknown Newsgroups: gmane.emacs.bugs Subject: bug#45089: 28.0.50; [PATCH] New xref commands xref-prev-group and xref-next-group Date: Mon, 07 Dec 2020 00:31:44 +0100 Message-ID: References: Reply-To: =?UTF-8?Q?Reply-to=3A_Daniel_Mart=C3=83=C2=ADn_=3Cmardani29=40yahoo=2Ees?= =?UTF-8?Q?=3E=0A?= 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="18147"; mail-complaints-to="usenet@ciao.gmane.io" To: 45089@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 07 00:33:31 2020 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 1km3X0-0004ZV-J7 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 07 Dec 2020 00:33:30 +0100 Original-Received: from localhost ([::1]:36672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1km3Wz-0003MA-4L for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Dec 2020 18:33:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1km3WY-0003Le-QD for bug-gnu-emacs@gnu.org; Sun, 06 Dec 2020 18:33:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1km3WY-0005DY-4U for bug-gnu-emacs@gnu.org; Sun, 06 Dec 2020 18:33:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1km3WY-0002Qf-16 for bug-gnu-emacs@gnu.org; Sun, 06 Dec 2020 18:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Dec 2020 23:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45089 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16072975258210 (code B ref -1); Sun, 06 Dec 2020 23:33:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Dec 2020 23:32:05 +0000 Original-Received: from localhost ([127.0.0.1]:51713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1km3Vc-000281-Bj for submit@debbugs.gnu.org; Sun, 06 Dec 2020 18:32:04 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:58978) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1km3Va-00026a-ME for submit@debbugs.gnu.org; Sun, 06 Dec 2020 18:32:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1km3Va-0003Ef-E4 for bug-gnu-emacs@gnu.org; Sun, 06 Dec 2020 18:32:02 -0500 Original-Received: from sonic302-21.consmr.mail.ir2.yahoo.com ([87.248.110.84]:39995) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1km3VT-0004sY-33 for bug-gnu-emacs@gnu.org; Sun, 06 Dec 2020 18:32:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1607297510; bh=UK1nhE8zx3/vxPfL7qZw6Ec0REElGn5dnqk+WUG3dUk=; h=From:To:Subject:Date:References:From:Subject; b=K4PokHVej1vt+C3iwYlpXDqa4ga6ew6OGxCtI/VMQkWwe6r1GpLeFa83+NtUQnWRvD/XHHEpDOM0B+XgbfKWhWizcz4wU9Mt09XlZP7Z9M7VovD3sKc7E2THXTUdGW93TdhXOPvgkKkgFSdxBHxMdwyLK582CGeWNRg0iWm7YeRbEO8gM+DBjqx14Fbze/dwhr3LMsBJhPBEiwC/M9QvmoZun6saNO36naoeYB0cMM3bxcC/+Q6XxmqMITOatxwAQlVWbuPyiL++0AfGCRJUhMgocfTATWvs/ePiMRJcBvgp1vMm4cTX2ZCC1qYVST79HvZAXn5/vwER189Js/EfKQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1607297510; bh=wimuf7m+e38B8g6lYygwlYagonXyogWashtwfsYZmdS=; h=From:To:Subject:Date:From:Subject; b=MdbdogF/p8FJlbTPkt7xVEcaT0gyHmzKIByI4ekDMEZqsILMhdrEhisrZ3xe1eqvcZTlTLlyPSnrv9OyHE/ge0HW1gPypPlQnZPqBpupgnGfD+92RbYWJu0KRrCf1ysJIelyczXyZ/i3z787CQEW9SUDAPl6qITKMC4piyGOkE6R87dwpB9qmkduFABj0ThBLxAacnJrxOQN6TMbX9rU6wMWy57hs6a0hThraV/VmWWY7W7FbgbC9YGsryY4s6t3sjlakZDLuIRnLtmljMco0RQLiId5x8oKua1Z4KwbcImKC94rDqZ8SHKJFG3HELn6haTgXGomP5NiBVmPVU782A== X-YMail-OSG: 06RPv5cVM1kgY2K2KW1KDPvGjXzs_82GAux4m1rqanZmVrwWkDezrrroYmCj9B. orWKpjhuFPlpQdDjK.uigLVWjYeHzBzxOQsltVMyfWv3Bo5H0mgIn7FOsgIMaTtGFByGcmyy83jR 1BsLxq.8A6QRWLjhJ7yQi9h8v0Ww52COCfB2pj8HyZlIKJKPUjgwToNWZ_0VCzQAIU2kTiYrco1N vRGxKuGEeEmFr8hcuossau9ZtIcD88oNYCmspz9lLm8ry_77r4yyeMjSthFBOaPeUVkZ2PxLgbKv 68LcwLF3MGQjUT1wS_lObNo9Dihld92hIC5wmLJWSGC5azMqzBuIy5if6HWu8z1byMbmyIFv4Bxu jOJmSUNTk28Vspfn5SIFsydUafJCercsJOS8Je1BbPBJRM6VrvrMewSG9rzgD057IPG7.0eS0sib xcOV8jD91rW4yO6Va_BNbBUgBtCCJqol0FR.FF6Pone1ABt4hqQP6zJzGon2kb8DDQcXTvwyD4WW Ij.cv.Sb4b._GsE3EOFDUiqnV3SVy26ppaSrnQ0wHYk0Uf9q_dzit_KnGfwqhny_AaNu4nBL.jFL w1PNQ1rikLk2edt1pz_wFWXdHXJmhvEn8L45xE_k9CCbHTKUkQzKlMkQ_n1WU6vGjnAUsQIhlE9z s_w6.P5s8LOQz0UhEhrNdXHmrDFFRWRZWOTZqZO20jW0Q.vHZgX8UPDAuGo1dMIDKr7_43_k3rdP q8baNq_K8uhsmujSSj3ENSHHzOuwjIQOpyqSalFRRuUjRM0VciOnagDbiCH3bgYTBK1UkypDsH6l L3.zw5ZxHWHrv1KruvJLaaqVsZz2VQ12B7YPvL_Yo1 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ir2.yahoo.com with HTTP; Sun, 6 Dec 2020 23:31:50 +0000 Original-Received: by smtp413.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 53490244f16c25391453f96e548e2849; Sun, 06 Dec 2020 23:31:45 +0000 (UTC) X-Mailer: WebService/1.1.17111 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.8) Received-SPF: pass client-ip=87.248.110.84; envelope-from=mardani29@yahoo.es; helo=sonic302-21.consmr.mail.ir2.yahoo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Original-From: Xref: news.gmane.io gmane.emacs.bugs:195191 Archived-At: --=-=-= Content-Type: text/plain In an *xref* buffer one can navigate quickly through the results with 'p' and 'n'. However, when there is a lot of results grouped in a bunch of files, in some cases it's more interesting to skip results and go to the first item of the previous or next group (typically, it will be the first result that is in a different file). The attached patch adds two commands for that, and binds them to 'P' and 'N', respectively. Do you think this is a generally useful feature? Do you think the keybindings I chose are appropriate? If so, feel free to install the attached patch. It already includes a NEWS entry and the corresponding updates to the Emacs manual. Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-commands-xref-next-group-and-xref-prev-group.patch >From 7217cf0aee1a27ee0adc9576f510a6696a8b6759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Sun, 6 Dec 2020 23:59:51 +0100 Subject: [PATCH] Add commands xref-next-group and xref-prev-group * lisp/progmodes/xref.el (xref-next-group): New command that navigates to the first item of the next xref group (typically a file). (xref-prev-group): New command that navigates to the first item of the next xref group (typically a file). (xref--xref-buffer-mode-map): Bound the new commands to 'N' and 'P', respectively. * doc/emacs/maintaining.texi (Xref Commands): Document the new commands in the Emacs manual. * etc/NEWS: Announce them. --- doc/emacs/maintaining.texi | 10 ++++++++++ etc/NEWS | 5 +++++ lisp/progmodes/xref.el | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 1f10b68b8a..4bc8fdb593 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -2199,12 +2199,22 @@ Xref Commands Move to the next reference and display it in the other window (@code{xref-next-line}). +@item N +@findex xref-next-group +Move to the first reference of the next reference group and display it in the other window +(@code{xref-next-group}). + @item p @itemx , @findex xref-prev-line Move to the previous reference and display it in the other window (@code{xref-prev-line}). +@item P +@findex xref-prev-group +Move to the first reference of the previous reference group and display it in the other window +(@code{xref-prev-group}). + @item C-o @findex xref-show-location-at-point Display the reference on the current line in the other window diff --git a/etc/NEWS b/etc/NEWS index 525ed8b36e..83bde4b377 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1192,6 +1192,11 @@ So far Grep and ripgrep are supported. ripgrep seems to offer better performance in certain cases, in particular for case-insensitive searches. +--- +*** New commands xref-prev-group and xref-next-group. +These commands are bound respectively to 'P' and 'N', and navigate to +the first item of the previous or next group in the "*xref*" buffer. + ** json.el --- diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 9f5fc57142..28c6a0b5b0 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -593,6 +593,25 @@ xref-prev-line (xref--search-property 'xref-item t) (xref-show-location-at-point)) +(defun xref-next-group () + "Move to the first item of the next xref group and display its source in the appropriate window." + (interactive) + (xref--search-property 'xref-group) + (xref--search-property 'xref-item) + (xref-show-location-at-point)) + +(defun xref-prev-group () + "Move to the first item of the previous xref group and display its source in the appropriate window." + (interactive) + ;; Search for the xref group of the current item, provided that the + ;; point is not already in an xref group. + (unless (plist-member (text-properties-at (point)) 'xref-group) + (xref--search-property 'xref-group t)) + ;; Search for the previous xref group. + (xref--search-property 'xref-group t) + (xref--search-property 'xref-item) + (xref-show-location-at-point)) + (defun xref--item-at-point () (save-excursion (back-to-indentation) @@ -738,6 +757,8 @@ xref--xref-buffer-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "n") #'xref-next-line) (define-key map (kbd "p") #'xref-prev-line) + (define-key map (kbd "N") #'xref-next-group) + (define-key map (kbd "P") #'xref-prev-group) (define-key map (kbd "r") #'xref-query-replace-in-results) (define-key map (kbd "RET") #'xref-goto-xref) (define-key map (kbd "TAB") #'xref-quit-and-goto-xref) -- 2.28.0 --=-=-=--