unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41222: 27.1; Auto-resizing of images in image-mode
@ 2020-05-12 22:57 Juri Linkov
  2020-05-14 20:46 ` Alan Third
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2020-05-12 22:57 UTC (permalink / raw)
  To: 41222

This is a followup to the emacs-devel thread
https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00777.html

I noticed that image-mode still lacks one needed command:
some image viewers have a menu item titled “Normal Size C-0” or
“Original Size C-0”.  Here's is the patch that implements it:

diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 480b2e6b26..45007289c8 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -456,6 +456,7 @@ image-mode-map
     (define-key map "sb" 'image-transform-fit-both)
     (define-key map "ss" 'image-transform-set-scale)
     (define-key map "sr" 'image-transform-set-rotation)
+    (define-key map "so" 'image-transform-original)
     (define-key map "s0" 'image-transform-reset)
 
     ;; Multi-frame keys
@@ -521,6 +522,8 @@ image-mode-map
 	 :help "Rotate the image"]
 	["Set Rotation..." image-transform-set-rotation
 	 :help "Set rotation angle of the image"]
+	["Original Size" image-transform-original
+	 :help "Reset image to original size"]
 	["Reset Transformations" image-transform-reset
 	 :help "Reset all image transformations"]
 	"--"
@@ -1382,6 +1385,13 @@ image-transform-set-rotation
   (setq image-transform-rotation (float (mod rotation 360)))
   (image-toggle-display-image))
 
+(defun image-transform-original ()
+  "Display the current image with the original size and rotation."
+  (interactive)
+  (setq image-transform-resize nil
+	image-transform-scale 1)
+  (image-toggle-display-image))
+
 (defun image-transform-reset ()
   "Display the current image with the default size and rotation."
   (interactive)


BTW, like ‘image-auto-resize-on-window-resize’ was added recently to
image-mode.el, is there a need to add a similar option to man.el
to allow customization of auto-resizing of Man buffers as well?
Maybe something like:

diff --git a/lisp/man.el b/lisp/man.el
index 5278a1a84d..a614cac536 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1579,7 +1579,8 @@ Man-mode
   (set (make-local-variable 'outline-level) (lambda () 1))
   (set (make-local-variable 'bookmark-make-record-function)
        'Man-bookmark-make-record)
-  (add-hook 'window-state-change-functions #'Man--window-state-change nil t))
+  (when Man-fit-to-window-on-window-resize
+    (add-hook 'window-state-change-functions #'Man--window-state-change nil t)))
 
 (defun Man-build-section-list ()
   "Build the list of manpage sections."





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#41222: 27.1; Auto-resizing of images in image-mode
  2020-05-12 22:57 bug#41222: 27.1; Auto-resizing of images in image-mode Juri Linkov
@ 2020-05-14 20:46 ` Alan Third
  2020-05-14 22:39   ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Third @ 2020-05-14 20:46 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 41222

On Wed, May 13, 2020 at 01:57:38AM +0300, Juri Linkov wrote:
> This is a followup to the emacs-devel thread
> https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00777.html
> 
> I noticed that image-mode still lacks one needed command:
> some image viewers have a menu item titled “Normal Size C-0” or
> “Original Size C-0”.  Here's is the patch that implements it:
<snip>
> +	["Original Size" image-transform-original
> +	 :help "Reset image to original size"]

Hi Juri, this looks good to me, but I’m not sure about saying
"original size", as that may be mistaken for meaning the size it was
when it was loaded the first time.

Perhaps "actual size"? It’s not great, but I think less open to
interpretation than "original".
-- 
Alan Third





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#41222: 27.1; Auto-resizing of images in image-mode
  2020-05-14 20:46 ` Alan Third
@ 2020-05-14 22:39   ` Juri Linkov
  2020-05-15  6:28     ` Alan Third
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2020-05-14 22:39 UTC (permalink / raw)
  To: Alan Third; +Cc: 41222

[-- Attachment #1: Type: text/plain, Size: 879 bytes --]

>> I noticed that image-mode still lacks one needed command:
>> some image viewers have a menu item titled “Normal Size C-0” or
>> “Original Size C-0”.  Here's is the patch that implements it:
> <snip>
>> +	["Original Size" image-transform-original
>> +	 :help "Reset image to original size"]
>
> Hi Juri, this looks good to me, but I’m not sure about saying
> "original size", as that may be mistaken for meaning the size it was
> when it was loaded the first time.

It seems the correct term for the size of the image loaded the first
time would be "initial size"?  Hmm, actually, the docstring of
'image-transform-reset' says the correct term for the initial size is
"default size".

> Perhaps "actual size"? It’s not great, but I think less open to
> interpretation than "original".

I don't know, some programs use "original size", some "normal size":

Xreader:

[-- Attachment #2: xreader.png --]
[-- Type: image/png, Size: 8182 bytes --]

[-- Attachment #3: Type: text/plain, Size: 10 bytes --]


Xviewer:

[-- Attachment #4: xviewer.png --]
[-- Type: image/png, Size: 4806 bytes --]

[-- Attachment #5: Type: text/plain, Size: 63 bytes --]


And I found one program, namely Pix, that uses "actual size".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#41222: 27.1; Auto-resizing of images in image-mode
  2020-05-14 22:39   ` Juri Linkov
@ 2020-05-15  6:28     ` Alan Third
  2020-05-19 22:43       ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Third @ 2020-05-15  6:28 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 41222

On Fri, May 15, 2020 at 01:39:55AM +0300, Juri Linkov wrote:
> >> I noticed that image-mode still lacks one needed command:
> >> some image viewers have a menu item titled “Normal Size C-0” or
> >> “Original Size C-0”.  Here's is the patch that implements it:
> > <snip>
> >> +	["Original Size" image-transform-original
> >> +	 :help "Reset image to original size"]
> >
> > Hi Juri, this looks good to me, but I’m not sure about saying
> > "original size", as that may be mistaken for meaning the size it was
> > when it was loaded the first time.
> 
> It seems the correct term for the size of the image loaded the first
> time would be "initial size"?  Hmm, actually, the docstring of
> 'image-transform-reset' says the correct term for the initial size is
> "default size".
> 
> > Perhaps "actual size"? It’s not great, but I think less open to
> > interpretation than "original".
> 
> I don't know, some programs use "original size", some "normal size":

If you're happy enough it won't be a problem I won't argue. :)
-- 
Alan Third





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#41222: 27.1; Auto-resizing of images in image-mode
  2020-05-15  6:28     ` Alan Third
@ 2020-05-19 22:43       ` Juri Linkov
  2020-05-20 20:18         ` Alan Third
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2020-05-19 22:43 UTC (permalink / raw)
  To: Alan Third; +Cc: 41222

>> >> I noticed that image-mode still lacks one needed command:
>> >> some image viewers have a menu item titled “Normal Size C-0” or
>> >> “Original Size C-0”.  Here's is the patch that implements it:
>> > <snip>
>> >> +	["Original Size" image-transform-original
>> >> +	 :help "Reset image to original size"]
>> >
>> > Hi Juri, this looks good to me, but I’m not sure about saying
>> > "original size", as that may be mistaken for meaning the size it was
>> > when it was loaded the first time.
>> 
>> It seems the correct term for the size of the image loaded the first
>> time would be "initial size"?  Hmm, actually, the docstring of
>> 'image-transform-reset' says the correct term for the initial size is
>> "default size".
>> 
>> > Perhaps "actual size"? It’s not great, but I think less open to
>> > interpretation than "original".
>> 
>> I don't know, some programs use "original size", some "normal size":
>
> If you're happy enough it won't be a problem I won't argue. :)

Actually the problem is in consistency of these two menu items:

	["Original Size" image-transform-original
	 :help "Reset image to original size"]
	["Reset Transformations" image-transform-reset
	 :help "Reset all image transformations"]

image-transform-original resets to the actual/original/normal size.
image-transform-reset resets to the default size defined by image-auto-resize.

So they both should be fixed to be mutually consistent.

One possible change is:

  "Original Size"
  "Reset to Default Size"

But when using "Actual Size" instead of "Original Size",
what would be a good title for the second menu item?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#41222: 27.1; Auto-resizing of images in image-mode
  2020-05-19 22:43       ` Juri Linkov
@ 2020-05-20 20:18         ` Alan Third
  2020-05-20 22:23           ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Third @ 2020-05-20 20:18 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 41222

On Wed, May 20, 2020 at 01:43:00AM +0300, Juri Linkov wrote:
> Actually the problem is in consistency of these two menu items:
> 
> 	["Original Size" image-transform-original
> 	 :help "Reset image to original size"]
> 	["Reset Transformations" image-transform-reset
> 	 :help "Reset all image transformations"]
> 
> image-transform-original resets to the actual/original/normal size.
> image-transform-reset resets to the default size defined by image-auto-resize.
> 
> So they both should be fixed to be mutually consistent.

Hmm, yes, I can't tell which is which just from the menu name or even
the description.

> One possible change is:
> 
>   "Original Size"
>   "Reset to Default Size"
> 
> But when using "Actual Size" instead of "Original Size",
> what would be a good title for the second menu item?

I think "Default Size" size works in either case. I feel that Default
strongly implies it will return to whatever size it would be when I
first load the image, and that also clarifies what the other option
will do.
-- 
Alan Third





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#41222: 27.1; Auto-resizing of images in image-mode
  2020-05-20 20:18         ` Alan Third
@ 2020-05-20 22:23           ` Juri Linkov
  2020-06-08  0:30             ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2020-05-20 22:23 UTC (permalink / raw)
  To: Alan Third; +Cc: 41222

>> One possible change is:
>> 
>>   "Original Size"
>>   "Reset to Default Size"
>> 
>> But when using "Actual Size" instead of "Original Size",
>> what would be a good title for the second menu item?
>
> I think "Default Size" size works in either case. I feel that Default
> strongly implies it will return to whatever size it would be when I
> first load the image, and that also clarifies what the other option
> will do.

I added both variants “Original/Actual” and “Default/Initial”
to menu title/help, and docstrings.  More tweaking is possible,
but it seems this is quite good now.

Eli, is it ok to install this finishing patch to emacs-27?

diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 480b2e6b26..b82c066918 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -456,6 +456,7 @@ image-mode-map
     (define-key map "sb" 'image-transform-fit-both)
     (define-key map "ss" 'image-transform-set-scale)
     (define-key map "sr" 'image-transform-set-rotation)
+    (define-key map "so" 'image-transform-original)
     (define-key map "s0" 'image-transform-reset)
 
     ;; Multi-frame keys
@@ -521,8 +522,10 @@ image-mode-map
 	 :help "Rotate the image"]
 	["Set Rotation..." image-transform-set-rotation
 	 :help "Set rotation angle of the image"]
-	["Reset Transformations" image-transform-reset
-	 :help "Reset all image transformations"]
+	["Original Size" image-transform-original
+	 :help "Reset image to actual size"]
+	["Reset to Default Size" image-transform-reset
+	 :help "Reset all image transformations to initial size"]
 	"--"
 	["Show Thumbnails"
 	 (lambda ()
@@ -1382,8 +1385,15 @@ image-transform-set-rotation
   (setq image-transform-rotation (float (mod rotation 360)))
   (image-toggle-display-image))
 
+(defun image-transform-original ()
+  "Display the current image with the original (actual) size and rotation."
+  (interactive)
+  (setq image-transform-resize nil
+	image-transform-scale 1)
+  (image-toggle-display-image))
+
 (defun image-transform-reset ()
-  "Display the current image with the default size and rotation."
+  "Display the current image with the default (initial) size and rotation."
   (interactive)
   (setq image-transform-resize image-auto-resize
 	image-transform-rotation 0.0





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#41222: 27.1; Auto-resizing of images in image-mode
  2020-05-20 22:23           ` Juri Linkov
@ 2020-06-08  0:30             ` Juri Linkov
  0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2020-06-08  0:30 UTC (permalink / raw)
  To: Alan Third; +Cc: 41222-done

>>> One possible change is:
>>> 
>>>   "Original Size"
>>>   "Reset to Default Size"
>>> 
>>> But when using "Actual Size" instead of "Original Size",
>>> what would be a good title for the second menu item?
>>
>> I think "Default Size" size works in either case. I feel that Default
>> strongly implies it will return to whatever size it would be when I
>> first load the image, and that also clarifies what the other option
>> will do.
>
> I added both variants “Original/Actual” and “Default/Initial”
> to menu title/help, and docstrings.  More tweaking is possible,
> but it seems this is quite good now.

Now installed and closed.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-06-08  0:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 22:57 bug#41222: 27.1; Auto-resizing of images in image-mode Juri Linkov
2020-05-14 20:46 ` Alan Third
2020-05-14 22:39   ` Juri Linkov
2020-05-15  6:28     ` Alan Third
2020-05-19 22:43       ` Juri Linkov
2020-05-20 20:18         ` Alan Third
2020-05-20 22:23           ` Juri Linkov
2020-06-08  0:30             ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).