From unknown Fri Aug 15 03:56:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7730: 24.0.50; `image-mode-fit-frame': add optional FRAME arg Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Dec 2010 23:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7730 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 7730@debbugs.gnu.org X-Debbugs-Original-To: Received: via spool by submit@debbugs.gnu.org id=B.129323398312779 (code B ref -1); Fri, 24 Dec 2010 23:40:02 +0000 Received: (at submit) by debbugs.gnu.org; 24 Dec 2010 23:39:43 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PWHEc-0003K4-MI for submit@debbugs.gnu.org; Fri, 24 Dec 2010 18:39:42 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PWHEa-0003Jr-BJ for submit@debbugs.gnu.org; Fri, 24 Dec 2010 18:39:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWHL2-0006FE-He for submit@debbugs.gnu.org; Fri, 24 Dec 2010 18:46:21 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:46099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWHL2-0006F8-DK for submit@debbugs.gnu.org; Fri, 24 Dec 2010 18:46:20 -0500 Received: from [140.186.70.92] (port=48503 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PWHL1-00028Q-K5 for bug-gnu-emacs@gnu.org; Fri, 24 Dec 2010 18:46:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWHL0-0006Eq-A9 for bug-gnu-emacs@gnu.org; Fri, 24 Dec 2010 18:46:19 -0500 Received: from rcsinet10.oracle.com ([148.87.113.121]:46408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWHL0-0006Eb-3p for bug-gnu-emacs@gnu.org; Fri, 24 Dec 2010 18:46:18 -0500 Received: from rcsinet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id oBONkFXW000624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 24 Dec 2010 23:46:17 GMT Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by rcsinet13.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id oBONkFMT011300 for ; Fri, 24 Dec 2010 23:46:15 GMT Received: from abhmt015.oracle.com by acsmt355.oracle.com with ESMTP id 904846601293234306; Fri, 24 Dec 2010 15:45:06 -0800 Received: from dradamslap1 (/10.159.220.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Dec 2010 15:45:06 -0800 From: "Drew Adams" Date: Fri, 24 Dec 2010 15:45:05 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcujxJb7VYCS5a0BSCGKNoogW2YNcg== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.4 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) Here's a possible enhancement to `image-mode-fit-frame'. These are the differences: 1. Added an optional FRAME arg. 2. The command only toggles if called interactively (actually, if the first arg is non-nil). #1 means you can use it for another frame. #2 means that only interactive calls save the previous frame size and alternate between fitting and restoring the old size. Also, at the end of the function I changed the separate calls to `set-frame-width' and `set-frame-height' to a single call to `set-frame-size'. I did that because I was seeing that the frame was not getting resized to fit in some cases. Dunno if there is a bug associated with that. FWIW, in my own use of this, my general command `fit-frame' calls it for Emacs 23+ if the FRAME is in `image-mode' or `image-minor-mode': (if (and (fboundp 'image-mode-fit-frame) ; Emacs 23+ (if (or (null frame) (eq frame (selected-frame))) (or (eq major-mode 'image-mode) image-minor-mode) (save-window-excursion (select-frame frame) (or (eq major-mode 'image-mode) image-minor-mode)))) (fit-frame-to-image (interactive-p) frame) ...) (I also use a different name for the command.) (defun fit-frame-to-image (interactivep &optional frame) "Fit FRAME to the current image. If FRAME is not the selected frame, fit it to its first image. Interactively, if frame has already been fit to the image, then restore the size from before it was fit. This function assumes that FRAME has only one window." ;; FIXME: This does not take into account decorations ;; like mode-line, minibuffer, header-line, ... (interactive "p") (let* ((saved (frame-parameter frame 'image-mode-saved-size)) (display (if (or (null frame) (equal frame (selected-frame))) (image-get-display-property) (save-selected-window (select-frame frame) (image-get-display-property)))) (size (image-display-size display nil frame))) (setq frame (or frame (selected-frame))) (if (and interactivep saved (eq (caar saved) (frame-width frame)) (eq (cdar saved) (frame-height frame))) (progn ; Restore previous size, before it was fit. (set-frame-parameter frame 'image-mode-saved-size nil) (setq size (cdr saved))) ;; Round up size, and save current size so we can toggle back to it. (setcar size (ceiling (car size))) (setcdr size (ceiling (cdr size))) (set-frame-parameter frame 'image-mode-saved-size (cons size (cons (frame-width frame) (frame-height frame))))) (set-frame-size frame (car size) (cdr size)))) In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600) of 2010-12-20 on 3249CTO Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (4.4) --no-opt --cflags -Ic:/imagesupport/include' From unknown Fri Aug 15 03:56:35 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: "Drew Adams" Subject: bug#7730: closed (Re: bug#7730: 24.0.50; `image-mode-fit-frame': add optional FRAME arg) Message-ID: References: <87pq11qx2g.fsf@gnu.org> X-Gnu-PR-Message: they-closed 7730 X-Gnu-PR-Package: emacs Reply-To: 7730@debbugs.gnu.org Date: Sat, 19 Jan 2013 10:38:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1358591882-2842-1" This is a multi-part message in MIME format... ------------=_1358591882-2842-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #7730: 24.0.50; `image-mode-fit-frame': add optional FRAME arg which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 7730@debbugs.gnu.org. --=20 7730: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D7730 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1358591882-2842-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 7730-done) by debbugs.gnu.org; 19 Jan 2013 10:37:08 +0000 Received: from localhost ([127.0.0.1]:39575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TwVnP-0000ih-Rn for submit@debbugs.gnu.org; Sat, 19 Jan 2013 05:37:08 -0500 Received: from mail-da0-f50.google.com ([209.85.210.50]:53672) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TwVnN-0000ia-Ab for 7730-done@debbugs.gnu.org; Sat, 19 Jan 2013 05:37:06 -0500 Received: by mail-da0-f50.google.com with SMTP id h15so2005036dan.9 for <7730-done@debbugs.gnu.org>; Sat, 19 Jan 2013 02:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=jQXJCVlHEPxTMAhoCBK7APRhDxDNDPuKdtp5Pb7+guo=; b=sUjOroHk67xrL/lvDSh6CfzUHy+SZL6HPLFmxGei7HwoZQD25tmAuSngZ0s+O7ewnq p1h6ciZL2DnnDYxlJ1m1MrQ6cxVTOLQLar5f2Re1ScWHBMxiWPpu0hiDd0BnDfK0vLSc hQxXyDBrRFrBDodWVA01u1LrvMTOLkGnBEktNUNkUvx3mk/BxSckjBM5z0T3znvMZn2r 8b0ekZNmqkAJ7b+NAhqT4A8SklxWsghjlDUJjVWtTxbaLbqvOg/IOcVPco1Fxw10tM8H VzQUSU162OdA8Uehq7vIGhtPiIjJbIZQO/qvGXYtsD1YLUP1nWpd4aOGxPLo34ENfpkb nmwg== X-Received: by 10.68.252.100 with SMTP id zr4mr13299940pbc.103.1358591771907; Sat, 19 Jan 2013 02:36:11 -0800 (PST) Received: from tsparkle (cm107.delta179.maxonline.com.sg. [59.189.179.107]) by mx.google.com with ESMTPS id ux4sm4810058pbc.25.2013.01.19.02.36.08 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 19 Jan 2013 02:36:10 -0800 (PST) From: Chong Yidong To: "Drew Adams" Subject: Re: bug#7730: 24.0.50; `image-mode-fit-frame': add optional FRAME arg References: Date: Sat, 19 Jan 2013 18:36:07 +0800 In-Reply-To: (Drew Adams's message of "Fri, 24 Dec 2010 15:45:05 -0800") Message-ID: <87pq11qx2g.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 7730-done Cc: 7730-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) "Drew Adams" writes: > Here's a possible enhancement to `image-mode-fit-frame'. > > 1. Added an optional FRAME arg. > > 2. The command only toggles if called interactively (actually, if the > first arg is non-nil). Thanks. I've committed something similar. ------------=_1358591882-2842-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 24 Dec 2010 23:39:43 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PWHEc-0003K4-MI for submit@debbugs.gnu.org; Fri, 24 Dec 2010 18:39:42 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PWHEa-0003Jr-BJ for submit@debbugs.gnu.org; Fri, 24 Dec 2010 18:39:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWHL2-0006FE-He for submit@debbugs.gnu.org; Fri, 24 Dec 2010 18:46:21 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:46099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWHL2-0006F8-DK for submit@debbugs.gnu.org; Fri, 24 Dec 2010 18:46:20 -0500 Received: from [140.186.70.92] (port=48503 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PWHL1-00028Q-K5 for bug-gnu-emacs@gnu.org; Fri, 24 Dec 2010 18:46:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWHL0-0006Eq-A9 for bug-gnu-emacs@gnu.org; Fri, 24 Dec 2010 18:46:19 -0500 Received: from rcsinet10.oracle.com ([148.87.113.121]:46408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWHL0-0006Eb-3p for bug-gnu-emacs@gnu.org; Fri, 24 Dec 2010 18:46:18 -0500 Received: from rcsinet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id oBONkFXW000624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 24 Dec 2010 23:46:17 GMT Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by rcsinet13.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id oBONkFMT011300 for ; Fri, 24 Dec 2010 23:46:15 GMT Received: from abhmt015.oracle.com by acsmt355.oracle.com with ESMTP id 904846601293234306; Fri, 24 Dec 2010 15:45:06 -0800 Received: from dradamslap1 (/10.159.220.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Dec 2010 15:45:06 -0800 From: "Drew Adams" To: Subject: 24.0.50; `image-mode-fit-frame': add optional FRAME arg Date: Fri, 24 Dec 2010 15:45:05 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcujxJb7VYCS5a0BSCGKNoogW2YNcg== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) Here's a possible enhancement to `image-mode-fit-frame'. These are the differences: 1. Added an optional FRAME arg. 2. The command only toggles if called interactively (actually, if the first arg is non-nil). #1 means you can use it for another frame. #2 means that only interactive calls save the previous frame size and alternate between fitting and restoring the old size. Also, at the end of the function I changed the separate calls to `set-frame-width' and `set-frame-height' to a single call to `set-frame-size'. I did that because I was seeing that the frame was not getting resized to fit in some cases. Dunno if there is a bug associated with that. FWIW, in my own use of this, my general command `fit-frame' calls it for Emacs 23+ if the FRAME is in `image-mode' or `image-minor-mode': (if (and (fboundp 'image-mode-fit-frame) ; Emacs 23+ (if (or (null frame) (eq frame (selected-frame))) (or (eq major-mode 'image-mode) image-minor-mode) (save-window-excursion (select-frame frame) (or (eq major-mode 'image-mode) image-minor-mode)))) (fit-frame-to-image (interactive-p) frame) ...) (I also use a different name for the command.) (defun fit-frame-to-image (interactivep &optional frame) "Fit FRAME to the current image. If FRAME is not the selected frame, fit it to its first image. Interactively, if frame has already been fit to the image, then restore the size from before it was fit. This function assumes that FRAME has only one window." ;; FIXME: This does not take into account decorations ;; like mode-line, minibuffer, header-line, ... (interactive "p") (let* ((saved (frame-parameter frame 'image-mode-saved-size)) (display (if (or (null frame) (equal frame (selected-frame))) (image-get-display-property) (save-selected-window (select-frame frame) (image-get-display-property)))) (size (image-display-size display nil frame))) (setq frame (or frame (selected-frame))) (if (and interactivep saved (eq (caar saved) (frame-width frame)) (eq (cdar saved) (frame-height frame))) (progn ; Restore previous size, before it was fit. (set-frame-parameter frame 'image-mode-saved-size nil) (setq size (cdr saved))) ;; Round up size, and save current size so we can toggle back to it. (setcar size (ceiling (car size))) (setcdr size (ceiling (cdr size))) (set-frame-parameter frame 'image-mode-saved-size (cons size (cons (frame-width frame) (frame-height frame))))) (set-frame-size frame (car size) (cdr size)))) In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600) of 2010-12-20 on 3249CTO Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (4.4) --no-opt --cflags -Ic:/imagesupport/include' ------------=_1358591882-2842-1--