From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#74361: [PATCH] New option xref-navigation-display-window-action Date: Mon, 18 Nov 2024 03:28:49 +0200 Message-ID: References: <87msi1ueb0.fsf@mail.linkov.net> <4256f446-e11b-450c-b455-131cb75acab0@gutov.dev> <871pzbj8mq.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------6aYs9h52ha8YAxIPmXVdVKBG" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11912"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 74361@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 18 02:30:21 2024 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 1tCqaq-0002v3-PW for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Nov 2024 02:30:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCqac-00019Y-Ur; Sun, 17 Nov 2024 20:30:06 -0500 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 1tCqaa-00018A-OV for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 20:30:05 -0500 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 1tCqaa-0000rb-FU for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 20:30:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:From:References:MIME-Version:Date:To:Subject; bh=Gc+Sfr7KwFuYXu6ECZ9gAhxr70fHHQxWSOkUsS4g/ms=; b=IY9wep7XuDCPlx23tqS1mq4LkKUVNc0jryl1SICDBRNCgIgnbcQTgEsF0kFlZSHgpaj0Z58BJ1MzZq2uzH1+UyV1dySgLylswA9Z3xh1eG92Rp1eiYdYM0PfQjQamAkCeUrYRTWLJ8r2dzrvpMYTZjNujltS59npanZsN1XiL+DYu7skZi7KekQ0g/LF+zK/m7hG8vqUr1GoHq0TCSyQMaeC9HkG1FwpZ3Z+rNsXjHMitYdPGzeMfrtiO1GI3nbV9MuBAXsE+MErjdc2PqVAmNRoFTx4RNyhQrY2LyM7G+IE+2waRoh7doMGfckonYrYQ4oYKeQMXf/IHvP3nLAlRw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tCqaZ-0002BB-80 for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 20:30:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Nov 2024 01:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74361 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74361-submit@debbugs.gnu.org id=B74361.17318933438237 (code B ref 74361); Mon, 18 Nov 2024 01:30:03 +0000 Original-Received: (at 74361) by debbugs.gnu.org; 18 Nov 2024 01:29:03 +0000 Original-Received: from localhost ([127.0.0.1]:59232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tCqZa-00028Z-5r for submit@debbugs.gnu.org; Sun, 17 Nov 2024 20:29:02 -0500 Original-Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]:39959) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tCqZW-00028C-Rn for 74361@debbugs.gnu.org; Sun, 17 Nov 2024 20:29:00 -0500 Original-Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 7D95C11401B3; Sun, 17 Nov 2024 20:28:53 -0500 (EST) Original-Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sun, 17 Nov 2024 20:28:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1731893333; x=1731979733; bh=Gc+Sfr7KwF uYXu6ECZ9gAhxr70fHHQxWSOkUsS4g/ms=; b=cUuDwHGLdTjP1RqB82x5NyevEx OTkw1X8XMZ3gQamWzIoMu1tCr6LDntxkuWVNsC6fK/yue6LDOK97gM+dy7nfJ4d3 WYgS0ipWNbFTB3cXaG2asT18BkDyQZJV+aVo5s+3ctQcdFXHarypJSlGDFR/jNA1 9uCbjopOMhNvsu3IqPdm7FkVgkAMEWOuHEtaOi82WkJF+NYajMt17Ib7azzGJYyE +EMAlGnlCRn5zW6gT0btgMgo8POr1vhnz8cUQy7cLjFCUtf0CkjkLi8T5mjr6/gK kz3c6XPneGEgGhev0uGDIuUiMxhvqr8GzFvZG+Gs00s1WMTo20G0024VP9+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1731893333; x=1731979733; bh=Gc+Sfr7KwFuYXu6ECZ9gAhxr70fHHQxWSOk UsS4g/ms=; b=XPLB/48jLFxxjkvo//UGHC9Cse8CT1Il0UfnDqLGIAzHSykxnDV JNdm/6I+XZVmLMDAjNLYUDXnasNEqsN+YCiOtzRp7fMs6CjphVuQ5uzOHAIJkcCX Kt4Kx8VlVt/kj7f3OTcAMWW9MWU4quhydGPotztxRcrz27wmFcSUtCMlDPdhk/+p 7trsdnvSmixLPqgwB8YK5MLetiSsyW/r0ORBO5gNI/VO7qZznc+GnKphnaUO4eGb LU/oBlyttqIzHI+2b3yYFaGLV0DNrc/fs22fwBtBYx7lPfEfp9vuD9vqW6BzifTL qHQRGbnlHOeIsEfmeHiO726y+CEB+Opkhfw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrvdelgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpegtkfffgggfuffvvehfhfgjsehmtderredtvdejnecu hfhrohhmpeffmhhithhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvh eqnecuggftrfgrthhtvghrnhepheelfedukeduudevkeeilefgieffvdekhfekleejueej geeukeevffekjeejveehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthhopedv pdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehjuhhriheslhhinhhkohhvrdhnvg htpdhrtghpthhtohepjeegfeeiudesuggvsggsuhhgshdrghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Nov 2024 20:28:51 -0500 (EST) Content-Language: en-US In-Reply-To: <871pzbj8mq.fsf@mail.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:295573 Archived-At: This is a multi-part message in MIME format. --------------6aYs9h52ha8YAxIPmXVdVKBG Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 16/11/2024 21:12, Juri Linkov wrote: > Instead of a new option and 'switch-to-buffer', > a simpler way would be allow the users just to > customize the category with 'display-buffer-same-window': > > (setq display-buffer-alist '(((category . xref) > (display-buffer-same-window)))) > > It works nicely when (category . xref) is added to the same place > like in your patch in 'xref--show-pos-in-buf': > > ``` > diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el > index cf061a18ee0..0193c2e35e0 100644 > --- a/lisp/progmodes/xref.el > +++ b/lisp/progmodes/xref.el > @@ -689,7 +689,7 @@ xref--show-pos-in-buf > (eq (window-buffer xref--original-window) buf))) > `((xref--display-buffer-in-window) > (window . ,xref--original-window)))))) > - (with-selected-window (display-buffer buf action) > + (with-selected-window (display-buffer buf (append action '((category . xref)))) > (xref--goto-char pos) > (run-hooks 'xref-after-jump-hook) > (selected-window)))) > ``` Thanks! That covers the code path which uses 'display-buffer', and we also need to handle xref-pop-to-location, which calls switch-to-buffer now. Does (pop-to-buffer buf '((display-buffer-same-window) (category . xref))) look compatible enough? Also, when using the suggested change in xref--show-pos-in-buf, if we simply annotate it with 'category' in the display-buffer call, this also extends to the scenarios where xref--original-window-intent is non-nil. See the attached patch where we make sure to exclude those cases. I suppose that loses the semantic consistency, though: xref-find-definitions-other-window and xref-find-definitions-other-frame are "xref" commands but they will call 'display-buffer' without 'category'. The corresponding customization (described in the first message) can be: (setq display-buffer-alist '(((category . xref) (display-buffer-reuse-window display-buffer-use-some-window)))) --------------6aYs9h52ha8YAxIPmXVdVKBG Content-Type: text/x-patch; charset=UTF-8; name="xref-display-buffer-with-category.diff" Content-Disposition: attachment; filename="xref-display-buffer-with-category.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvcHJvZ21vZGVzL3hyZWYuZWwgYi9saXNwL3Byb2dtb2Rlcy94 cmVmLmVsCmluZGV4IGNjMDZlMDZlZjc4Li41NmU0YjBjNzUxOCAxMDA2NDQKLS0tIGEvbGlz cC9wcm9nbW9kZXMveHJlZi5lbAorKysgYi9saXNwL3Byb2dtb2Rlcy94cmVmLmVsCkBAIC01 MTMsNiArNTEzLDkgQEAgeHJlZi1wdXNoLW1hcmtlci1zdGFjawogOzs7IyMjYXV0b2xvYWQK IChkZWZpbmUtb2Jzb2xldGUtZnVuY3Rpb24tYWxpYXMgJ3hyZWYtcG9wLW1hcmtlci1zdGFj ayAjJ3hyZWYtZ28tYmFjayAiMjkuMSIpCiAKKyhkZWZ1biB4cmVmLS1zd2l0Y2gtdG8tYnVm ZmVyIChidWYpCisgIChwb3AtdG8tYnVmZmVyIGJ1ZiAnKChkaXNwbGF5LWJ1ZmZlci1zYW1l LXdpbmRvdykgKGNhdGVnb3J5IC4geHJlZikpKSkKKwogOzs7IyMjYXV0b2xvYWQKIChkZWZ1 biB4cmVmLWdvLWJhY2sgKCkKICAgIkdvIGJhY2sgdG8gdGhlIHByZXZpb3VzIHBvc2l0aW9u IGluIHhyZWYgaGlzdG9yeS4KQEAgLTUyMyw4ICs1MjYsOCBAQCB4cmVmLWdvLWJhY2sKICAg ICAgICAgKHVzZXItZXJyb3IgIkF0IHN0YXJ0IG9mIHhyZWYgaGlzdG9yeSIpCiAgICAgICAo bGV0ICgobWFya2VyIChwb3AgKGNhciBoaXN0b3J5KSkpKQogICAgICAgICAoeHJlZi0tcHVz aC1mb3J3YXJkIChwb2ludC1tYXJrZXIpKQotICAgICAgICAoc3dpdGNoLXRvLWJ1ZmZlciAo b3IgKG1hcmtlci1idWZmZXIgbWFya2VyKQotICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgKHVzZXItZXJyb3IgIlRoZSBtYXJrZWQgYnVmZmVyIGhhcyBiZWVuIGRlbGV0ZWQiKSkp CisgICAgICAgICh4cmVmLS1zd2l0Y2gtdG8tYnVmZmVyIChvciAobWFya2VyLWJ1ZmZlciBt YXJrZXIpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAodXNlci1lcnJv ciAiVGhlIG1hcmtlZCBidWZmZXIgaGFzIGJlZW4gZGVsZXRlZCIpKSkKICAgICAgICAgKGdv dG8tY2hhciAobWFya2VyLXBvc2l0aW9uIG1hcmtlcikpCiAgICAgICAgIChzZXQtbWFya2Vy IG1hcmtlciBuaWwgbmlsKQogICAgICAgICAocnVuLWhvb2tzICd4cmVmLWFmdGVyLXJldHVy bi1ob29rKSkpKSkKQEAgLTUzOCw4ICs1NDEsOCBAQCB4cmVmLWdvLWZvcndhcmQKICAgICAg ICAgKHVzZXItZXJyb3IgIkF0IGVuZCBvZiB4cmVmIGhpc3RvcnkiKQogICAgICAgKGxldCAo KG1hcmtlciAocG9wIChjZHIgaGlzdG9yeSkpKSkKICAgICAgICAgKHhyZWYtLXB1c2gtYmFj a3dhcmQgKHBvaW50LW1hcmtlcikpCi0gICAgICAgIChzd2l0Y2gtdG8tYnVmZmVyIChvciAo bWFya2VyLWJ1ZmZlciBtYXJrZXIpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAo dXNlci1lcnJvciAiVGhlIG1hcmtlZCBidWZmZXIgaGFzIGJlZW4gZGVsZXRlZCIpKSkKKyAg ICAgICAgKHhyZWYtLXN3aXRjaC10by1idWZmZXIgKG9yIChtYXJrZXItYnVmZmVyIG1hcmtl cikKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICh1c2VyLWVycm9yICJU aGUgbWFya2VkIGJ1ZmZlciBoYXMgYmVlbiBkZWxldGVkIikpKQogICAgICAgICAoZ290by1j aGFyIChtYXJrZXItcG9zaXRpb24gbWFya2VyKSkKICAgICAgICAgKHNldC1tYXJrZXIgbWFy a2VyIG5pbCBuaWwpCiAgICAgICAgIChydW4taG9va3MgJ3hyZWYtYWZ0ZXItcmV0dXJuLWhv b2spKSkpKQpAQCAtNjEyLDcgKzYxNSw3IEBAIHhyZWYtcG9wLXRvLWxvY2F0aW9uCiAgICAg ICAgICAgICAgICAgICAgKHhyZWYtbG9jYXRpb24tbWFya2VyICh4cmVmLWl0ZW0tbG9jYXRp b24gaXRlbSkpKSkKICAgICAgICAgIChidWYgKG1hcmtlci1idWZmZXIgbWFya2VyKSkpCiAg ICAgKGNsLWVjYXNlIGFjdGlvbgotICAgICAgKChuaWwpICAoc3dpdGNoLXRvLWJ1ZmZlciBi dWYpKQorICAgICAgKChuaWwpICAoeHJlZi0tc3dpdGNoLXRvLWJ1ZmZlciBidWYpKQogICAg ICAgKHdpbmRvdyAocG9wLXRvLWJ1ZmZlciBidWYgdCkpCiAgICAgICAoZnJhbWUgIChsZXQg KChwb3AtdXAtZnJhbWVzIHQpKSAocG9wLXRvLWJ1ZmZlciBidWYgdCkpKSkKICAgICAoeHJl Zi0tZ290by1jaGFyIG1hcmtlcikpCkBAIC02ODgsNyArNjkxLDEwIEBAIHhyZWYtLXNob3ct cG9zLWluLWJ1ZgogICAgICAgICAgICAgICAgICAgKG9yIChub3QgKHdpbmRvdy1kZWRpY2F0 ZWQtcCB4cmVmLS1vcmlnaW5hbC13aW5kb3cpKQogICAgICAgICAgICAgICAgICAgICAgIChl cSAod2luZG93LWJ1ZmZlciB4cmVmLS1vcmlnaW5hbC13aW5kb3cpIGJ1ZikpKQogICAgICAg ICAgICAgICAgICBgKCh4cmVmLS1kaXNwbGF5LWJ1ZmZlci1pbi13aW5kb3cpCi0gICAgICAg ICAgICAgICAgICAgKHdpbmRvdyAuICx4cmVmLS1vcmlnaW5hbC13aW5kb3cpKSkpKSkKKyAg ICAgICAgICAgICAgICAgICAoY2F0ZWdvcnkgLiB4cmVmKQorICAgICAgICAgICAgICAgICAg ICh3aW5kb3cgLiAseHJlZi0tb3JpZ2luYWwtd2luZG93KSkpCisgICAgICAgICAgICAgICAg KHQKKyAgICAgICAgICAgICAgICAgJygoY2F0ZWdvcnkgLiB4cmVmKSkpKSkpCiAgICAgKHdp dGgtc2VsZWN0ZWQtd2luZG93IChkaXNwbGF5LWJ1ZmZlciBidWYgYWN0aW9uKQogICAgICAg KHhyZWYtLWdvdG8tY2hhciBwb3MpCiAgICAgICAocnVuLWhvb2tzICd4cmVmLWFmdGVyLWp1 bXAtaG9vaykK --------------6aYs9h52ha8YAxIPmXVdVKBG--