From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Morgan Smith Newsgroups: gmane.emacs.bugs Subject: bug#74246: [PATCH] Reuse display windows in image-dired Date: Wed, 27 Nov 2024 19:32:43 -0500 Message-ID: References: <868qtsmydz.fsf@gnu.org> <86a5dqm9gl.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5170"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: martin rudalics , 74246@debbugs.gnu.org, stefankangas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 28 01:33:29 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 1tGSTI-00019D-L1 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 28 Nov 2024 01:33:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGSSy-0006wx-LD; Wed, 27 Nov 2024 19:33:08 -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 1tGSSt-0006wR-Ib for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2024 19:33:05 -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 1tGSSs-0004n2-AF for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2024 19:33: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=A5TwwU1ihytvYezQyWkMJsCyDObNMyKksNmFsYUuLiM=; b=b8QkvZCbITe27gfP5DOOe0b5H1oLudt198mwYjLfmy6SloExvIcXmq4XwM7xStn2ouKcI4GrcI04oyXLxxtNJjDyOI5Gu/wrSe4yYsBan5vJepb/EmgmJ5HL7SxscTCVoTg9J9ekYn0eUl3INyy+FetmcfwIIhb3hFtTv0Y6wlaFC/nFgApLuNUOhA1yF15ZY/PyqBA5E0w05nt9oylEzjFOpe+r/E3EmdNbciwJBsCmd9CgVoAp9L0F7m3yOCFB+rqY1PUMv+bpLZogsxbgQCktkiHbEi6XGBAMLkX8EJrCtSs+frhY5NzDJH9SM1OrwX6UdyFnL/9+damWFU2Wiw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tGSSr-0004cn-Sn for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2024 19:33:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Morgan Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Nov 2024 00:33: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.173275397317759 (code B ref 74246); Thu, 28 Nov 2024 00:33:01 +0000 Original-Received: (at 74246) by debbugs.gnu.org; 28 Nov 2024 00:32:53 +0000 Original-Received: from localhost ([127.0.0.1]:35549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGSSi-0004cH-PK for submit@debbugs.gnu.org; Wed, 27 Nov 2024 19:32:53 -0500 Original-Received: from mail-dm6nam04olkn2098.outbound.protection.outlook.com ([40.92.45.98]:40935 helo=NAM04-DM6-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGSSg-0004by-ML for 74246@debbugs.gnu.org; Wed, 27 Nov 2024 19:32:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z+Au6wq68o9mGDhFfwYD813hzhMkn2XC7CL+a+LYqPhsd3F/CoHgd4WULwWxV3LQ6oM4Rnny19+Pf87JCR1N0h63WFHdw78V4lNUURkz9tKRS8xQI85XHCVpvI3AFGvlRpL1U/AvMjL/HVHxNqyEu8+WECbdwflxSunc7Npb3Sk7dt831Ov7Z7gOBvcCBaLW9hIcZROj5tdvq8Et4QIZh37VrmFnovjOugxq2RYVAVemxfwYsJOQYk/FHmPHl4Crq9bbOIspECdFRzSmyGtG2CdrVRyJ2jLKK+LSG/if8NGVS1qLsuEIkWJfqrek6SB069k9izi6et+19V5BB7flWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A5TwwU1ihytvYezQyWkMJsCyDObNMyKksNmFsYUuLiM=; b=JbRYCy3g1ILrC06hWWAI0wGxo6Q08jHc6DWncs2pqUIzg05vieggvNdkCQ0RPftTojzENmPnKYqO+5hiaqpemp9VgTsq8L4w8E91uzjW3XEiP8LxrSA/+J9PXF3bEXdyKMfevfoUqGb7paCqXImxIU8svntaI/o6Qg7HrRS6OTGA9I5cXqr7pjBIBV2E6wV9KN75bgUo/DStFRZBsCY0IBXCbugiuTljFzIGXpwoh7ciTXEqwSMBUlx2JeNP3H23HhD1wVwhrznjPImX6iqTyx4D8qNpcRJQxd5uYiuV+eZYKFg4Igi/pZav7AcFKNCeV4PmJfOf/tnQTLaLRqZgQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A5TwwU1ihytvYezQyWkMJsCyDObNMyKksNmFsYUuLiM=; b=VoKyoOJDCv1lmflHdrhLgl8kxfEVoHPZZ3SjXKqjQRnwlLSx9T9IxgfN83a74uwnCGfjHBzywRnXEoQDm9odmJepbzsIY5Oust1Pa07yLxodqNaPI6bdbxNRg3HATSSGjzBQS6bnh5cysE+Lxr86z5kRQ7qnZ0OnEhJTxzOhBaoyiMEpvsT7Qy1thT6ubSGZ28vidcjnBHRBIiqUgKCPOXJrIOrI3k8cVRkhOE+MKn/tLZkXvJyVHePHrKQSeYh3OJA+sApIkeK6cvqk2oc0dTMAIH3QTXQy1Ojq7d04U5b+VewacOfJ36HP9pgT0nzlkH7KD56BSku2E5YFYYr/tg== Original-Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) by MW4PR84MB3145.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:303:1e1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.21; Thu, 28 Nov 2024 00:32:43 +0000 Original-Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::5c77:7a58:48ed:9aef]) by CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::5c77:7a58:48ed:9aef%4]) with mapi id 15.20.8207.010; Thu, 28 Nov 2024 00:32:42 +0000 In-Reply-To: <86a5dqm9gl.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Nov 2024 14:16:26 +0200") X-Hashcash: 1:20:241128:rudalics@gmx.at::Jdn0MMq9K6thQd9W:2gHR X-Hashcash: 1:20:241128:eliz@gnu.org::Lem42GKmX50BTH4e:3JUO X-Hashcash: 1:20:241128:74246@debbugs.gnu.org::gWmGdseeFuzL5Ol6:1uPQ X-Hashcash: 1:20:241128:stefankangas@gmail.com::KFb9FVhUCpZy+G1M:4bGE X-ClientProxiedBy: YQBPR0101CA0209.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:67::9) To CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) X-Microsoft-Original-Message-ID: <878qt4nqok.fsf@outlook.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR84MB3424:EE_|MW4PR84MB3145:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cb0642a-3052-4165-0e4e-08dd0f442aef X-Microsoft-Antispam: BCL:0; ARA:14566002|15080799006|19110799003|8060799006|6092099012|461199028|7092599003|5072599009|440099028|13095399003|3412199025; X-Microsoft-Antispam-Message-Info: s5sLHTyfA/oxPHQGMrq7sAr1typKjP9hg1bpgVocMXrw5EJnAHnP0OGkO0kQlFbDoFyzg9iA4X3+PtJDbed7wJRhrFFhD0Ol17+8fNVCMIlxMP+oSt0NiDzUXwNaFWfeCLzD89WPQbOqUw3mT9iwFOnxt9CBObH8Ql1MBoj2ok2Xz2pPCKzjApj1wwkv/FiD432YbMC3zd9z89XGvonvVL1wBHw1M4Lyv6D4H986h45BoBB+UCy7Pqccxuhaoguo2HrL5KSgo5WzBA6vEBqQz3oilPPzHAi1VMC2UBxZoUYW9JZdiaG/bCsuP8bBUAWz/1GZ2okhF5Lh0mvv/vh7M1ck1K+8+DzwsWOs8Z0MPVryq8ssY8frUMFVj6A4yRcyYCnpo0L1+vzspL75p9QyE+FRUfa8CTy81xK1KPBf4a8dQfIcQMEpLea01Nno/tduvGb+8PGjTkYNB8QN7P2uE8KNMZ6tGmqfew42TyxvjaB/BtrWpgcTy46+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wcsiQ5nX3xZzMmVpy/s+3bFgtrfoA6Q2ECOHpJnqCfkEaEyAIeTaTEJcjYoXxIRlbpr80EcItoESlZW9YQ7upH0c1M6PUK8oBiL/k 3zvAN+tFfXlj5Au08tlykYW88NElx0bY9MSs732lXzJ/I874S0LiGR59SDLSxca1ILU6MOVEoAmqbcnqSJf2V9JbkEskdt0nRv X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cb0642a-3052-4165-0e4e-08dd0f442aef X-MS-Exchange-CrossTenant-AuthSource: CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2024 00:32:42.7866 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR84MB3145 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:296042 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Ping! Morgan, could you please try Martin's suggestions and report > back? > >> >> FWIW, I would rewrite 'image-dired-display-image' as the (largely >> untested) >> >> (defun image-dired-display-image (file &optional _ignored) >> "Display image FILE in the image buffer window. >> If FILE is an image, the window will use `image-dired-image-mode' >> which is based on `image-mode'." >> (declare (advertised-calling-convention (file) "29.1")) >> (setq file (expand-file-name file)) >> (when (not (file-exists-p file)) >> (error "No such file: %s" file)) >> (let* ((buffer (get-buffer-create image-dired-display-image-buffer)) >> (window (get-buffer-window buffer))) >> (find-file-noselect-1 buffer file nil t nil nil) >> (with-current-buffer buffer >> (if (string-match (image-file-name-regexp) file) >> (image-dired-image-mode) >> ;; Support visiting PDF files. >> (normal-mode))) >> >> (unless window >> (display-buffer buffer)))) >> >> instead of doing all that 'kill-buffer' (which could delete the selected >> window as a side-effect so the final 'select-window' will throw an >> error) 'rename-buffer' rigmarole. >> >> martin I initially explored this option but was weary to use 'find-file-noselect-1` as it looks like it should be an internal function and is used only in the file it's defined in. However, I do like this solution the most. Attached is a patch almost identical to the proposed function. The proposed function would be perfect if it contained the line '(display-buffer buffer t)'. Morgan --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Reuse-display-windows-in-image-dired-bug-74246.patch >From 7d0d9133b5276565589aadea9c0804522ed3cc64 Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Wed, 27 Nov 2024 19:22:27 -0500 Subject: [PATCH] Reuse display windows in image-dired (bug#74246) * lisp/image/image-dired.el(image-dired-display-image): Reuse the buffer if it exists. --- lisp/image/image-dired.el | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el index 83745e88f09..29863acea8e 100644 --- a/lisp/image/image-dired.el +++ b/lisp/image/image-dired.el @@ -1268,18 +1268,15 @@ image-dired-display-image (setq file (expand-file-name file)) (when (not (file-exists-p file)) (error "No such file: %s" file)) - (let ((buf (get-buffer image-dired-display-image-buffer)) - (cur-win (selected-window))) - (when buf - (kill-buffer buf)) - (when-let* ((buf (find-file-noselect file nil t))) - (pop-to-buffer buf) - (rename-buffer image-dired-display-image-buffer) + (let ((buf (find-file-noselect-1 + (get-buffer-create image-dired-display-image-buffer) + file nil t nil nil))) + (display-buffer buf t) + (with-current-buffer buf (if (string-match (image-file-name-regexp) file) (image-dired-image-mode) ;; Support visiting PDF files. - (normal-mode)) - (select-window cur-win)))) + (normal-mode))))) (defun image-dired-display-this (&optional arg) "Display current thumbnail's original image in display buffer. -- 2.46.0 --=-=-=--