GNU bug report logs -
#38187
27.0.50; No mouse-wheel scaling on images
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Tue, 12 Nov 2019 21:11:02 UTC
Severity: normal
Found in version 27.0.50
Fixed in version 27.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #35 received at 38187 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> In image-mode currently ‘+’ is bound to the command ‘image-increase-size’,
>> the same command could be bound to ‘<C-mouse-4>’ (C-wheel-up) as well.
>> Same for ‘-’ (image-decrease-size) and ‘<C-mouse-5>’ (C-wheel-down).
>
> Right. I think that's an obvious thing to put in `image-map' to make it
> easier to change the size of a single image.
>
> (It's not just in image-mode -- that map is on all images inserted by
> `insert-image'.)
>
> I don't have a mouse myself, so it'd be nice if somebody with one
> created a patch so that they could test it. image-map is in image.el.
I tested this patch, and it works well:
[mouse-wheel-image-size.patch (text/x-diff, inline)]
diff --git a/lisp/image.el b/lisp/image.el
index ad2ee6c607..8e8e477865 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -158,6 +158,10 @@ image-map
(let ((map (make-sparse-keymap)))
(define-key map "-" 'image-decrease-size)
(define-key map "+" 'image-increase-size)
+ (define-key map [C-wheel-down] 'image-decrease-size)
+ (define-key map [C-mouse-5] 'image-decrease-size)
+ (define-key map [C-wheel-up] 'image-increase-size)
+ (define-key map [C-mouse-4] 'image-increase-size)
(define-key map "r" 'image-rotate)
(define-key map "o" 'image-save)
map))
@@ -993,23 +997,33 @@ imagemagick-enabled-types
(imagemagick-register-types)
-(defun image-increase-size (n)
+(defun image-increase-size (&optional n event)
"Increase the image size by a factor of N.
If N is 3, then the image size will be increased by 30%. The
default is 20%."
- (interactive "P")
- (image--change-size (if n
- (1+ (/ n 10.0))
- 1.2)))
+ (interactive (list current-prefix-arg last-nonmenu-event))
+ (let ((e (and (listp event) (event-start event))))
+ (save-window-excursion
+ (when e
+ (select-window (posn-window e))
+ (goto-char (posn-point e)))
+ (image--change-size (if n
+ (1+ (/ (prefix-numeric-value n) 10.0))
+ 1.2)))))
-(defun image-decrease-size (n)
+(defun image-decrease-size (&optional n event)
"Decrease the image size by a factor of N.
If N is 3, then the image size will be decreased by 30%. The
default is 20%."
- (interactive "P")
- (image--change-size (if n
- (- 1 (/ n 10.0))
- 0.8)))
+ (interactive (list current-prefix-arg last-nonmenu-event))
+ (let ((e (and (listp event) (event-start event))))
+ (save-window-excursion
+ (when e
+ (select-window (posn-window e))
+ (goto-char (posn-point e)))
+ (image--change-size (if n
+ (- 1 (/ (prefix-numeric-value n) 10.0))
+ 0.8)))))
(defun image--get-image ()
"Return the image at point."
This bug report was last modified 5 years and 238 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.