From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74246: [PATCH] Reuse display windows in image-dired Date: Thu, 5 Dec 2024 10:23:40 +0100 Message-ID: References: <868qtsmydz.fsf@gnu.org> <86a5dqm9gl.fsf@gnu.org> <06f264c8-b1a1-4a7f-8fe9-1ca58b2343ff@gmx.at> <87jzcn1af7.fsf@mail.linkov.net> <08f46ed1-e489-4859-8a25-ba7dc4262b95@gmx.at> <87y1108u9k.fsf@mail.linkov.net> <87ldwyil8q.fsf@mail.linkov.net> <3a5afa37-0ea1-4183-a563-ecc3067818c2@gmx.at> <871pypb43g.fsf@mail.linkov.net> <8cd0088f-1beb-4871-a06c-17f8cfb23e29@gmx.at> <87plm8addt.fsf@mail.linkov.net> <90c5f5d6-37f3-41a6-be7c-903e6d0359ac@gmx.at> <87ikrzjrj1.fsf@mail.linkov.net> Reply-To: martin rudalics Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28665"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Morgan Smith , Eli Zaretskii , 74246@debbugs.gnu.org, stefankangas@gmail.com To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 05 10:24:25 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 1tJ85u-0007EX-G7 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Dec 2024 10:24:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJ85h-0006X6-1h; Thu, 05 Dec 2024 04:24:09 -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 1tJ85b-0006WN-3w for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 04:24: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 1tJ85a-0004Ks-RP for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 04:24:02 -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=73dHnvGiiRCagqFndfwll0toguDGtAMZSUrN/LNvFvI=; b=qAKYEVVbgp+hQKd2VG1selhBGQF2pB2Ard7BcSsMT+2be1rossGtfBvr29r4yrcHsUOBkWdvX0FL0YjgIzcNI7uAd2+2pk5hdFHQpv7s6VYbEP09n2EwedQPZ4ezs9s8pq9GqH4sKq6MC/4OPr1nXuIwyR60PND47TzU+QAD+rYUrYYF9/z4xLuzdWKxlSbTxfx//ZYXyAnJig4Gr4gw3xbiwGcxYmPPFILour9cYCaQ+q1gTQSSzjEdWa+UQ4JQ/uiWQ7QUpcihdrOEeFS1ODORRZ0T6VfcXHmA2yMmaKHhPv1CSG+WIfBFWfyOQ50v36Y4Yh61irgXJK2ie0LgSg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tJ85a-0001pz-EJ for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2024 04:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Dec 2024 09:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74246 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74246-submit@debbugs.gnu.org id=B74246.17333906327042 (code B ref 74246); Thu, 05 Dec 2024 09:24:02 +0000 Original-Received: (at 74246) by debbugs.gnu.org; 5 Dec 2024 09:23:52 +0000 Original-Received: from localhost ([127.0.0.1]:38255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJ85P-0001pW-Rw for submit@debbugs.gnu.org; Thu, 05 Dec 2024 04:23:52 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:47665) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJ85N-0001pG-H5 for 74246@debbugs.gnu.org; Thu, 05 Dec 2024 04:23:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.at; s=s31663417; t=1733390621; x=1733995421; i=rudalics@gmx.at; bh=73dHnvGiiRCagqFndfwll0toguDGtAMZSUrN/LNvFvI=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=s8SZxaJsZJk05zsKVMO74ZzXQ4n93gQ10wgziOEfeX723iUACqiBKTuUkAoQ7F+M aR8mujQ/DfJBE3YWEkMJuxpVO2LcTNDlnwVoZ/zZUPxmLolZVNfinNbIKDoD9xebD nNv5xT3Lx/vQEAWGftBnDos0ytcZPA5usuMYhFxpFt5kwyv5jMThISpCjTaFT5gkP dTBZ5os4LhLfm4NZrPAWQNFdqvv1HSHXhmCCOdNImSAkTXR8FGhy5Dtis+mlt0VGg V76Q+Q1IJ2DBHGZcFdbNgjwkZcJ78RnrErJdW10A+GYPOmfvdIQ7d1VyGXyegRULI SRBcTGTmhb3i8+yPDg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from [192.168.31.113] ([213.142.97.121]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M42nS-1tJ85F0v0S-00Dsxj; Thu, 05 Dec 2024 10:23:41 +0100 Content-Language: en-US In-Reply-To: <87ikrzjrj1.fsf@mail.linkov.net> X-Provags-ID: V03:K1:UmlUJFh6/RjPS2JqLiCZiCCYlyXHyrfbLAd4EruK4zum/x9T96C tNvbYr0xVPtnL+WVzvSS5IebCkEOWFhvg+5KMIV7r7YLR+kw4oXXmoG0CsNkapsY75JTh+r 1yzX7cPfrkqR3furQllOS42Iln1/urEWu4nbct2hM/PNu2nJiC3Nio2y2VZSLT/yMbJlVzj chFsyZOO/tfFtzeVgTjWA== UI-OutboundReport: notjunk:1;M01:P0:4rv+Q5ixPow=;+WlEXZiEiOP24rtatPvlA6O2niF ngTjWeRsbPFOuHBx0XRE5iM3eT1nXlmXwNosmhrHVHgiWTCuycsbA0c7LjQBWaHE56xPslFgY qdlZgNupz+cn2rBo5xlPGG3bbWWUU7uJkYpi3ZVORTmOFS0X8abkX9ZIiw8I/Yaaes0OupzVT Y4lsGTcRKMjGR28KZjtozUrnEpNLMLiSkbMBwpINC+NzPUx5PQSV/DBGMavuO9Q9PT7U79qPJ IGANUDxhwNZUht9UvaqZYl4V5b/j93mZRkVHFLgKnzoN7HFgXMqAFSOeSVuYbFwi1NV9ywqnA pSWg9UdyNoK0F9ktR1hlxeoMlAHmwCr1ACKJ341XHLCyezapJ3crr77PfT+y1AVB01+nL8FmS qxw4PaFkqSW6XRfJhmWFRNzQSBZDJvu8VsOut9No7qu2y0nYA1GbgPxNJ7bWlUrjEYkNObvMc KQTn+3H6TS50nBo2F8q5YYLcC+g2WHcivAAIvmJKPBiOGWayz6Cse4G2fnyVd1GvLEEyHsIzN y0zqQPISEoBhvHjdDCQw+9GVh6M2Q/hFoe/0OHmrYVEsdD4/slCQA4kZX413V/ONubba9H+TP fVVsktIXpny/a5zkmFR7R2IOillW2Mx96Q0NyNf9+aAvsbIGxXDcUAhwDbjblBaA54xgQXRRS YEU1i+zWnJ4UcE95hAYFpYUf5d0SV9PQTFj26CnjtUQ2hDadCZ2Y84oZrby0PwfSU7qgVFrER QIlo7+zwhHP07V4HZFWrqFul09AUYCbw7YdFH514rNvSwhwOXKDdwR/a3UXmxMh0FM9MAhYk 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:296460 Archived-At: > In all customizations I relied on the assumption that the source buffer > was current and its window was selected. And indeed I see the uses > of '(eq window (selected-window))' in display-buffer functions. Let's assume a "source buffer" containing a list of objects (usually links to files possibly enhanced with positions in them) a user might want to display in a buffer. These files could be source files containing definitions or compiler errors, images or simply all files in a directory. A user might want to navigate that list to display a "target buffer" showing the next or previous object with respect to the current object of that list. Do we agree on that? If the function for showing the next of previous object in the list is `display-buffer', then if 'display-buffer-use-some-window' is called to find a suitable window and there are several windows on the selected frame, it would be nice if always the same window were chosen for displaying the target buffer instead of using the lru window with the consequence that the next object in the list is always shown in another window. Hence some way to remember the last window chosen and use it again in the next call would be a nice idea. The proposed way to do that is by using a buffer-local variable. Do we agree on that as well? Then let's store the last window chosen in a buffer-local variable say 'last-window'. This can be either done in the target buffer as DEFVAR_PER_BUFFER ("last-window", &BVAR (current_buffer, last_window), Qnil, doc: /* Last window showing this buffer via `display-buffer'.. This is the last window used by `display-buffer' for showing this buffer. It is used by `display-buffer-use-some-window' for displaying this buffer in that window. */); or in the source buffer as DEFVAR_PER_BUFFER ("last-window", &BVAR (current_buffer, last_window), Qnil, doc: /* Last window showing a buffer via `display-buffer'. This is the last window used by `display-buffer' for showing a buffer invoked by a function with this buffer current. It is used by `display-buffer-use-some-window' for displaying its buffer argument in that window. */); The first specification has the following two drawbacks. The caller of 'display-buffer' would have to initialize it in a target buffer that has not been shown before to the window that has previously shown an element of the list. Also, it's somehow redundant since 'window-prev-buffers' called on all windows could find that window as well if the target buffer has already been displayed anywhere. The second specification has the drawback that _any_ 'display-buffer' call that relies on 'display-buffer-use-some-window' may use that window. Just think of an error occurring during that call: The *backtrace* buffer will pop up in the window specified by that variable although it is by no means related to it. Moreover, in the implementations proposed for setting it so far, 'window--display-buffer' would set that variable locally in the buffer of the window selected before calling 'display-buffer'. This implies that the source buffer must appear in the selected window and would preclude the use of a key binding that works even if the source buffer is currently not displayed in any window. Obviously, we could also ask for the caller to pass the window to use in a 'previous-window' or 'some-window' alist entry and set the window previously used in some non-local variable pertinent to the caller. But then why use a buffer-local variable in the first place? What am I missing? martin