From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Auto-resizing of images in image-mode Date: Sun, 19 Apr 2020 17:06:05 +0300 Message-ID: <83r1wjin8y.fsf@gnu.org> References: <83r1wqgcl1.fsf@gnu.org> <87eesnayhf.fsf@mail.linkov.net> <83sgh2d2zo.fsf@gnu.org> <874ktg5pgt.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="17313"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Apr 19 16:06:48 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jQAat-0004SB-QW for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Apr 2020 16:06:47 +0200 Original-Received: from localhost ([::1]:42106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQAas-00032P-SE for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Apr 2020 10:06:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37674) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQAaN-0002W5-0s for emacs-devel@gnu.org; Sun, 19 Apr 2020 10:06:15 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:51811) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQAaM-0001r7-DS; Sun, 19 Apr 2020 10:06:14 -0400 Original-Received: from [176.228.60.248] (port=1180 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jQAaK-0004yk-TL; Sun, 19 Apr 2020 10:06:13 -0400 In-Reply-To: <874ktg5pgt.fsf@mail.linkov.net> (message from Juri Linkov on Sun, 19 Apr 2020 02:45:18 +0300) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:247315 Archived-At: > From: Juri Linkov > Cc: emacs-devel@gnu.org > Date: Sun, 19 Apr 2020 02:45:18 +0300 > > Please see in commit 4df8a61117 if everything is correct > according to your comments. LGTM, thanks. > > Maybe so, but Emacs 26 still shows the images in their original size, > > AFAICT. So this is new in Emacs 27, at least for me. I think that's > > because previously the automatic resizing worked only in Emacs built > > with ImageMagick, whereas in Emacs 27 we can resize natively. I build > > my Emacs without ImageMagick, and I wonder how many others do, due to > > ImageMagick's instability. > > I'm not sure how it could be new in Emacs 27 because > image-transform-resize was added in year 2014. It's new for me, because I build Emacs without ImageMagick. > Better would be to have two ways to view an image without the > automatic resizing: > > 1. an option to disable automatic resizing permanently. > There is already a defvar 'image-transform-resize' > but its 'nil' value doesn't disable automatic resizing, > so a new defcustom is needed. Please see it below. > > 2. an easy to type key in image-mode-map to toggle automatic resizing. > Some programs use 'F' key for "Best Fit" but 'F' is already used > in image-mode-map for image-goto-frame. That's fine with me, thanks. > Also there are no keys for image-transform-fit-to-width, > image-transform-fit-to-height and image-transform-reset. > I thought about using a prefix key 'f', so using 'f w' to fit width, > but 'f' is already taken too. > > But anyway their docstrings say: > > This command has no effect unless Emacs is compiled with > ImageMagick support. > > So these commands should be fixed to work without ImageMagick. Right. But that's for master, I think. > Then three new defcustoms like these could be added: > > (defcustom image-resize t > "Non-nil to resize the image upon first display. > Its value should be one of the following: > - nil, meaning no resizing. > - t, meaning to fit the image to the window height and width. > - `fit-height', meaning to fit the image to the window height. > - `fit-width', meaning to fit the image to the window width. > - A number, which is a scale factor (the default size is 1)." > :type '(choice (const :tag "No resizing" nil) > (other :tag "Fit height and width" t) > (const :tag "Fit height" fit-height) > (const :tag "Fit width" fit-width) > (number :tag "Scale factor" 1)) > :version "27.1" > :group 'image) > > (defcustom image-window-resize t > "Non-nil to resize the image whenever the window's dimensions change." > :type 'boolean > :version "27.1" > :group 'image) > > (defcustom image-window-resize-delay 1 > "Number of seconds to wait before resizing according to `image-window-resize'." > :type 'integer > :version "27.1" > :group 'image) > > If this looks good, I could send a complete patch. Please do, and thanks.