From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74361: [PATCH] New option xref-navigation-display-window-action Date: Fri, 15 Nov 2024 14:13:32 +0200 Message-ID: <86ldxkitjn.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27634"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74361@debbugs.gnu.org, juri@linkov.net To: Dmitry Gutov , martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 15 13:14:24 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 1tBvDU-00070Y-D6 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Nov 2024 13:14:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBvDB-0001GY-G3; Fri, 15 Nov 2024 07:14: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 1tBvD8-0001GJ-6p for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 07:14:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBvD7-0000pl-RX for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 07:14:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=d8e6ERi8nn8qYfXzE9sHdqaEK7Vn7RK93XCKBHr9o+o=; b=Gw0G3TvVHYLmXvxEjrZXW5CdxJlIftc3rM6IBl0qYsWrzl0iJhKZhaG1onHkHRrd+aqxO39DpoIH/NbsMSBdV3QZBqoo5X+ond66Hfz3VFpav0cZxi7xjcdnPRKO2F5fG2+RjknRoAkxyCFLs/N5/syGxSNBbfMG4+5pH5PJTTu2FzC6cT5ewJDB10p8lz/r+XEGTKeXQZs30QnizbhZvz7ekAtgshC/qcG8dq4UimZiPVgGaEORNwpVU38BLR3ExUeSnMq5vvZ+Oi4C7mayeIpCQnwV7TmKU8YiZj6XYw5BZRV1L61ZHy2HE7gHna2NSEn4FdqlSyKvQuxt9Bi0uA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBvD7-0001et-MJ for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 07:14:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Nov 2024 12:14: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.17316728246344 (code B ref 74361); Fri, 15 Nov 2024 12:14:01 +0000 Original-Received: (at 74361) by debbugs.gnu.org; 15 Nov 2024 12:13:44 +0000 Original-Received: from localhost ([127.0.0.1]:48874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBvCq-0001eF-As for submit@debbugs.gnu.org; Fri, 15 Nov 2024 07:13:44 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46240) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBvCo-0001e2-Ua for 74361@debbugs.gnu.org; Fri, 15 Nov 2024 07:13:43 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBvCh-0000m3-NZ; Fri, 15 Nov 2024 07:13:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=d8e6ERi8nn8qYfXzE9sHdqaEK7Vn7RK93XCKBHr9o+o=; b=Ha7bw/VLE7wR 1JJVNmQpp4t0d5WG8xDuc0H86dmgoYkG0fqxlP881vAZ+aupK5/YZrjwouQxFKaXGfk4t0iJ+DAUK bR+TlJWSe51mDtHUl9x8I6Jycz5cpdvO0DJvvulhAu+ITc5d5ziP9geKo74E9nc5nBnp1h3sISmin GtWEwLX80qD8vXJSieMlJRfElZwM+qUJsw/UoFn84LAlA3FRnxT/ilpPIx2BxxFbcZwNGDl27VRAQ ShSlMzADlFTG31XdlUQrGUeduQ3EPK8aU4TwDyUTvPRuQHs1NcbmwXIUggu03Ckmojnnf5/p4LFll 7fp0Yup35nCX8/4wXxvTcQ==; In-Reply-To: (message from Dmitry Gutov on Fri, 15 Nov 2024 00:29:14 +0200) 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:295390 Archived-At: > Cc: juri linkov > Date: Fri, 15 Nov 2024 00:29:14 +0200 > From: Dmitry Gutov > > This adds a capability to customize the destination window selection > logic for navigation (xref-find-definitions, xref-go-back, > xref-go-forward) by allowing a user-supplied display window function. > > Inspired by the Merlin package and its user option > merlin-locate-in-new-window > (https://github.com/ocaml/merlin/blob/a36f42a5b181d0c9cc84174e8eb241b11eeabc0f/emacs/merlin.el#L177C12-L177C39) > - where the value 'diff' uses a different window if the destination is > in an file different from the current one. > > With the attached patch the customization looks a bit noisier though: > > (setq xref-navigation-display-window-action > '(display-buffer-reuse-window)) > > ^ This makes it try to reuse an existing window and fall back to > pop-to-window, but the effect is similar to what's described above. > > Comments welcome. I added Martin to the discussion, and have a few minor comments below. > diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el > index cc06e06ef78..670e80ea40b 100644 > --- a/lisp/progmodes/xref.el > +++ b/lisp/progmodes/xref.el > @@ -431,6 +431,21 @@ xref-auto-jump-to-first-xref > :version "28.1" > :package-version '(xref . "1.2.0")) > > +(defcustom xref-navigation-display-window-action nil > + "When non-nil, the display action to use for navigation commands. This is too general, when taken alone (as in the apropos commands). I suggest something like If non-nil, the `display-buffer' action for showing results of Xref commands. (The "navigation" part seems misleading, since xref-find-definitions is not a navigation command.) > +This does not affect commands that specify the action explicitly, I guess "...that specify the window to use explicitly" is more accurate? > +such as `xref-find-definitions-other-window'." > + :type '(choice (const :tag "Use selected window" nil) > + (const :tag "Reuse window showing destination or use another" I think "If possible, reuse window already showing destination" is better? > +(defun xref--switch-to-buffer (buf) > + (if xref-navigation-display-window-action > + (pop-to-buffer buf xref-navigation-display-window-action) Should we have some sanity checks for the value of xref-navigation-display-window-action? It's a user option, so theoretically the user could use setq to set it to any value.