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: Thu, 05 Dec 2024 19:52:08 +0200 Organization: LINKOV.NET Message-ID: <87o71qghzf.fsf@mail.linkov.net> References: <1d08c589-2d0e-4f10-8c2e-e21c206ac118@gmx.at> <78a96965-31c1-4688-b808-2de09d1832c4@gmx.at> <878qt9pz4w.fsf@mail.linkov.net> <05452bef-dd2e-4e93-abdd-6eb391027197@gmx.at> <87y118cyyk.fsf@mail.linkov.net> <871pyzp6br.fsf@mail.linkov.net> <25443bb1-788a-4f06-9350-5d2c666f6795@gmx.at> <32b8cc56-afa1-40f6-933f-6de0df2b9f63@gutov.dev> <688d5119-0900-46a4-86c7-32a9b06cc349@gmx.at> <87ed2v1aec.fsf@mail.linkov.net> <19124901-e749-4daa-bf47-27e12ea619aa@gutov.dev> <87mshbj4lk.fsf@mail.linkov.net> <4a81429a-ef9e-473c-989f-cff1314f5633@gmx.at> <8734j3l69p.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19314"; 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: Dmitry Gutov , 74361@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 05 19:02:37 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 1tJGBP-0004kf-B8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Dec 2024 19:02:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJGAu-00078o-69; Thu, 05 Dec 2024 13:02:04 -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 1tJGAs-00078A-VF for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 13:02:03 -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 1tJGAs-0005Xv-JE for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 13:02: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=EE1KZKUBR6a7z6vXbHAtPzWWTz+eodtEwaCGBpgT4kc=; b=tNiwTfkLz+VBHxrIGR2u0DftpWV8J4JiubvtRrIefzI0uOxBB6JtEsjtFEtN6aynR1DRw3OwCCftaLsyKbpFZRuLOy4uMqmul3GqBgXwAyX+0xJcprCYGTuS0EJI9HdgJ8xxHauwVugmbFlwWcIdqg3chrCDWeoI8e4nphEnAV0bANEkMAINK/g+er8CUVKvYFh3p1Z+ITcm6PgY+RV+XSkqlkJFHvVAXM5x2stNX/eQmMopZvdlo/fLbmZ5fyvjHxYhOxma+eUhCm+XYUXtJGk10OwN3HuNJ2T2G4TpyBzXyFSsN6zHXQeDi5PnaXCpSp6fXMthkoqZd4Ze/oAefA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tJGAs-0002OA-DZ for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 13:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Dec 2024 18:02:02 +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.17334216729050 (code B ref 74361); Thu, 05 Dec 2024 18:02:02 +0000 Original-Received: (at 74361) by debbugs.gnu.org; 5 Dec 2024 18:01:12 +0000 Original-Received: from localhost ([127.0.0.1]:40642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJGA3-0002Lu-UG for submit@debbugs.gnu.org; Thu, 05 Dec 2024 13:01:12 -0500 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:39399) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJGA1-0002Lc-5x for 74361@debbugs.gnu.org; Thu, 05 Dec 2024 13:01:10 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 5EDEC60002; Thu, 5 Dec 2024 18:01:02 +0000 (UTC) In-Reply-To: (martin rudalics's message of "Thu, 5 Dec 2024 10:23:15 +0100") 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:296478 Archived-At: >> Ok. This reminds me adding '(previous-window . WINDOW)' >> to 'display-buffer-in-previous-window' with: >> >> (when (and previous-window (symbolp previous-window) >> (boundp previous-window)) >> (setq previous-window (symbol-value previous-window))) > > Where and how is or would this be used? In the sources all I see is > > `((previous-window . ,debugger-previous-window)))))) > > so I suppose the symbol value would be used in customizations only. I just tried to understand the differences between display-buffer-in-previous-window and display-buffer-use-some-window. >> (when (and (setq window previous-window) >> (window-live-p window) >> >> Probably we should support both a symbol and a value for 'some-window' >> as well. > > Where and how would this be used? Mostly in customizations to support both ways: `((previous-window . display-buffer-previous-window)) `((previous-window . ,display-buffer-previous-window)) `((some-window . display-buffer-some-window)) `((some-window . ,display-buffer-some-window)) >> BTW, here is an example of using 'previous-window' with an advice on >> 'window--display-buffer' that could be combined with 'some-window': >> >> (defvar-local display-buffer-previous-window nil) >> >> (add-to-list 'display-buffer-alist >> '((category . xref-jump) >> display-buffer-in-previous-window >> (previous-window . display-buffer-previous-window) > > So here 'display-buffer' would retrieve the symbol-value of whatever is > in the buffer-local value of 'display-buffer-previous-window'. Right? Right. >> (inhibit-same-window . nil)) >> ;; Append to not override display-buffer-same-window >> 'append) >> >> (define-advice xref-goto-xref (:around (ofun &rest args) previous-window) >> (let ((buffer (current-buffer))) >> (apply ofun args) >> (with-current-buffer buffer >> (setq-local display-buffer-previous-window (selected-window))))) > > This relies on 'ofun' selecting a window and would not work for plain > 'display-buffer'. Right? It should work for plain 'display-buffer' because of using 'with-current-buffer'. >> (define-advice window--display-buffer (:around (ofun &rest args) previous-window) >> (let ((buffer (current-buffer)) >> (window (apply ofun args))) >> (with-current-buffer buffer >> (setq-local display-buffer-previous-window window)) >> window)) > > And this assumes that the current buffer is the one where to set the > variable. Would this work with a function calling 'xref-goto-xref', > bound to a key and called interactively with an arbitrary window > selected? This is how it's designed to work: to associate the displayed window with the buffer that was current.