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: Sun, 8 Dec 2024 17:55:17 +0100 Message-ID: <7a548d2f-144b-45e3-9558-8908a2a4a86b@gmx.at> 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> <87cyi6f2gb.fsf@mail.linkov.net> <6689d418-d028-40b8-b3d2-4ff12fe4283a@gmx.at> <87ed2jwhm5.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="31061"; 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 Sun Dec 08 17:56:27 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 1tKKa3-0007uo-Ey for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 Dec 2024 17:56:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKKZh-0002CT-2I; Sun, 08 Dec 2024 11:56:05 -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 1tKKZe-0002Bn-PN for bug-gnu-emacs@gnu.org; Sun, 08 Dec 2024 11:56: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 1tKKZe-0003ez-E2 for bug-gnu-emacs@gnu.org; Sun, 08 Dec 2024 11:56: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=UHU7wt6StGa7mnkn8+jcZ9DBsBi6jX3jPdh71ERBRr0=; b=Q4gcCApBBO+06nBWNvkE5NsOPRvAxccHJllHgXyEyQ6CLWAW0wjI7lAkA+bqGz9IfdK552+IUQ1MKsZkPkHRM60puy4467SSNLrDWPpqJJho0D+A9iWsRJe3wXPlHnnwrHZgdN/0DVdaAxs0/3ULRO83QLD8ZhSv8ii7FmXiVNTyYA1X7KJBQ02zWbinhmbjNo8/lTbcIVnz9wgBnSs2372/hulGqVv38crtYnzi+/u3iH/PnoKiWyzEAzjXwfiw4VM9QjanlOWKOWEJUxYE1B3MqTbv5qxqGWTN9GZExN3U4rWcBqSsJBYWrrkeFeBdHa0aizCXlr07xLccSpXkig==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tKKZd-0003IF-VB for bug-gnu-emacs@gnu.org; Sun, 08 Dec 2024 11:56:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Dec 2024 16:56:01 +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.173367693412599 (code B ref 74246); Sun, 08 Dec 2024 16:56:01 +0000 Original-Received: (at 74246) by debbugs.gnu.org; 8 Dec 2024 16:55:34 +0000 Original-Received: from localhost ([127.0.0.1]:51521 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKKZB-0003H9-Hb for submit@debbugs.gnu.org; Sun, 08 Dec 2024 11:55:33 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:37209) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKKZ8-0003Gq-8h for 74246@debbugs.gnu.org; Sun, 08 Dec 2024 11:55:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.at; s=s31663417; t=1733676921; x=1734281721; i=rudalics@gmx.at; bh=UHU7wt6StGa7mnkn8+jcZ9DBsBi6jX3jPdh71ERBRr0=; 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=jty5N1Py+pSoB0vCHypJzi3qPVurGDwERjL3IGep73HJDAHZHhF0Owd4XPrTjhgo 5JfLXbIdZ2mnOf4hMdUe037YWyucerDDvsk71M1Lf6Ml66cytAvYsbr5J8bLvWxnS 8wBg5VP+v+DxyIT4pM4WW/o8ilFOQA2Qmd22HbNbZL41iL+a0lDrWXaIggmj7YrVP JbhyFV3R3Rs91F2ife3cgyQcbT6A0pz5X80i1ES+O/NLQEej73TTJMvoTrcMtkMqR xqU4dkGFSW18AsmDnl/aYYtLj13WeqDsXgQof7qnawvapSRT1uAwXtuzvXqyyb9Ov 0wtRxRTG7jdrTU2CrQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from [192.168.31.113] ([212.95.5.71]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MgesG-1tq60T13hk-00gG8c; Sun, 08 Dec 2024 17:55:21 +0100 Content-Language: en-US In-Reply-To: <87ed2jwhm5.fsf@mail.linkov.net> X-Provags-ID: V03:K1:fd32Q15BumBmsKhORLhy4qX/I8rSoBgxVBhzTmL9fWh9dJMMHhX AOV+Jhqlg8dbqJITK8u6pqlaaM5NBapGuy7A/Wvs7YlV+Ov/QHlqwOK1iG5ttNm3DuAwFqz sbb6aOXVM2jEBQHyrxpRp2cJ8SugRJhO1ac5ST3JsSOR0uLWPTvtIDU/OkbHt+g8zMXeMEG RRQ4Z/tAMX2fht9rEHfWQ== UI-OutboundReport: notjunk:1;M01:P0:kOYlwa6L5DY=;qTslUaBbdIMplksJ5aS263NYUpq ZuvW6a68yUOtciO94ErtcbcBVVClFlrra53tEDxjJCrhSlSNJPf8YgnpVFzSL0Hx2mBvcCQzo owEYuOCVq8NB7CAy9FEXG33zH2qBDhn7zMVAeyDQUjgTVbHhGKKHY8X9X1G634fFiubV+IgW7 38yPgsUchL/I8H1VGPFa25zwN/D8oZ2uGAzywGBs2mi5ulYyc+FQ9haGe5NCy9FSHW8uJBui5 hyLOZroIXnBgcSyVWyn29NMq3oH3t7+BMiaoTf6JHjlFldrlEYooRMmrRqX2k1XktpPAnkaxw 45wVCzcDcFOl/IQ9jjYRt0e+xQSdC+257a3B/xOw79DHW2ASE9Whyt2ql4vNFPF1F18u5EusI HbvYz/hbZ524FW+lZRCVOF1E5YMuexi6lg7VMTGFslNomNdPR237IPkhcUr9YTVY2lvUroUx3 0jgdhJ11vcNj/1jMmS0YkkQxyv3RarRMC3826B0PP+XzhoBVdDDClWEeDxzce4alNSy91WlqH p7Mv/q6LeerWjngrR+8OJB83cNNYFmas515z8DI5yFEqlYSgQj0IPVY7XM+ZfSEfgS4yOQ3Ct 4AyJQeuvq5J7GgZB4twhYo3njMWxlspj1xGMBCn0KvdkHTQP9snFm1xiGqu3OeKgJx4GbxxKb O3NwXyFB2BqeDyBLETZM5c1mnI8IQVvnX4RpfX5K/PlDt7rWw5oi1cESy7AaxE01DDyts3FKf F8tA9D5zzVxuWouWYu88NbUOQl00XMiEd2M++HQpbvvWtod08LwLaqSki+fPTskO4iq55qNy 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:296650 Archived-At: > I meant that only the same command (and therefore the same > display-buffer call) should reuse the same window. > This is why I checked for 'this-command' in the posted snippet. > But instead of associating with a command name an alternative approach > would be to use a category. One and the same command may issue an arbitrary number of 'display-buffer' calls. Checking for 'this-command' may work for you in a specific context but is certainly not a safe approach for general use. > The *backtrace* buffer is not a problem because it uses own > display-buffer alist that overrides display-buffer-use-some-window. Unless a user has customized it or 'display-buffer-below-selected' fails for some reason. > display-buffer-use-some-window could recheck if the window is still suitable > for every use of the same command and display-buffer call. As I said above this is not reliable. The only reliable thing is to pass the symbol of the function calling 'display-buffer' with some unique number identifying the nth call of 'display-buffer' within that function. Everything else is guesswork. >>> It's fine to set a buffer-local variable in the buffer where the user >>> types a key that displays the target buffer from another source buffer. >>> As long as the same buffer is used to get the value of this variable. >> >> I have no idea of a secure way to retrieve that buffer. > > It's always the current buffer, even if another buffer is used > as the source buffer. But the current buffer may vary continuously, it might even be the minibuffer if I issue the call from there. > What if the user wants to display an image buffer in another window? > Then 'display-buffer-reuse-window' can't be used. If a user issues the command to display an image in a window that already shows an image and insists on using another window, an arbitrary other window can be chosen. Users who want that just get the usual chaotic behavior lru provides. They asked for it. > A buffer-local variable should be set in the source buffer only, > not in the image buffer. With 'image-dired' it can be set in the image buffer because that buffer is always the same. > I have absolutely no problems with existing code > in 'image-dired-display-image' because of using: > > (setq display-buffer-base-action > '(nil . ((some-window > . (lambda (_buffer alist) > (let ((last-window (buffer-local-value > 'display-buffer-last-window > (window-buffer)))) > (or (and (eq this-command (car last-window)) > (window-live-p (cdr last-window)) > (cdr last-window)) > (get-mru-window nil nil t)))))))) Imagine users who once they displayed an image want it to fill their frame entirely and want to use a key combination to display the next or previous image there. Web pages usually display a < on the left and a > on the right to achieve that behavior. Image viewers put similar icons in a toolbar for that. There is no visible source buffer or current buffer around for that in Emacs. All you have is the target buffer. martin