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#74361: [PATCH] New option xref-navigation-display-window-action Date: Sat, 16 Nov 2024 21:12:13 +0200 Organization: LINKOV.NET Message-ID: <871pzbj8mq.fsf@mail.linkov.net> References: <87msi1ueb0.fsf@mail.linkov.net> <4256f446-e11b-450c-b455-131cb75acab0@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37522"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 74361@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 16 20:16:28 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 1tCOHU-0009f0-Co for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Nov 2024 20:16:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCOH8-0001qr-2B; Sat, 16 Nov 2024 14:16: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 1tCOH4-0001qR-H5 for bug-gnu-emacs@gnu.org; Sat, 16 Nov 2024 14:16:02 -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 1tCOH4-0005Lf-7a for bug-gnu-emacs@gnu.org; Sat, 16 Nov 2024 14:16:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=Q150f+R2QL7Uhk2kvFnjt/pOjQajsGrgF8+T7XpoEpI=; b=hoU8EiawAT9nbkDN5l4g3Lr+MxKSVDyOQOIq3kL/XvxL7Eq66A/btz7LJH+4LHiCi6jgwJeCr22hpw+Rv4khu7w7FQ5XLRw9JSKSqiiHjI7PZfwC0wDT+5kBYKYljBovYHYxrrpRLL3cUpfCupVlywy1Ex0qvMerxGMsSA6C+b5YqIhIvUohi4q2W9iXXYSAE8kueKq5XJRX2HSB51pJfIRahPEBQWmwOno1bQnjswha5PLU6HcYKJeDwJ36WS6EHiRwTMLcM5hHRhILU1WzpA5emOVn3tVeUzh2KphB/xW3LzC7e7e/QIgcKYKuP5JfVS3wZf+LhLTwg7GDhMRUoQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tCOH3-0002Pa-SV for bug-gnu-emacs@gnu.org; Sat, 16 Nov 2024 14:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Nov 2024 19:16:01 +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.17317845349232 (code B ref 74361); Sat, 16 Nov 2024 19:16:01 +0000 Original-Received: (at 74361) by debbugs.gnu.org; 16 Nov 2024 19:15:34 +0000 Original-Received: from localhost ([127.0.0.1]:54838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tCOGb-0002Oq-U9 for submit@debbugs.gnu.org; Sat, 16 Nov 2024 14:15:34 -0500 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:37233) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tCOGa-0002Oc-HP for 74361@debbugs.gnu.org; Sat, 16 Nov 2024 14:15:33 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 3EDC7240004; Sat, 16 Nov 2024 19:15:23 +0000 (UTC) In-Reply-To: <4256f446-e11b-450c-b455-131cb75acab0@gutov.dev> (Dmitry Gutov's message of "Fri, 15 Nov 2024 21:05:51 +0200") 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:295486 Archived-At: >> This option looks similar to 'display-comint-buffer-action' >> whose addition was deemed to be a mistake, so we needed to declare it >> obsolete and replace it with '(category . comint)'. >> So instead of adding 'xref-navigation-display-window-action', >> could you just add a category 'xref' to xref display function calls? >> Then users will be able to customize it with e.g.: >> (setq display-buffer-alist '(((category . xref) >> (display-buffer-reuse-window)))) >> Or maybe I misunderstand other requirements for this feature. > > Thanks for the comments. The other priority here (I think) seems to retain > the current behavior by default: > > You can see this decision being made in > > (defun xref--switch-to-buffer (buf) > (if xref-navigation-display-window-action > (pop-to-buffer buf xref-navigation-display-window-action) > (switch-to-buffer buf))) > > So... I suppose one way to do that would be to add an option in Xref which > make it use 'pop-to-buffer' instead of 'switch-to-buffer' (similar to > 'switch-to-buffer-obey-display-actions'). And then the user would customize > 'display-buffer-alist' like in your example. Something like: > > (setq xref-navigation-obey-display-actions t > display-buffer-alist '(((category . xref) > (display-buffer-reuse-window)))) > > Is that not too complex, what do we think? 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)))) ```