diff options
author | Stefan Kangas <stefan@marxist.se> | 2021-10-28 03:36:28 +0200 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2022-08-18 19:31:28 +0200 |
commit | 0dc9c9a68f5a137fd71d7aca356d08fd52b16d52 (patch) | |
tree | d0a41ae9ea3e6ebeedb6d72008e151c5a0175c4f /lisp | |
parent | 9f8e16d828bab7db3bdf67fabd5b3abfe3974e8e (diff) | |
download | emacs-0dc9c9a68f5a137fd71d7aca356d08fd52b16d52.tar.gz emacs-0dc9c9a68f5a137fd71d7aca356d08fd52b16d52.tar.bz2 emacs-0dc9c9a68f5a137fd71d7aca356d08fd52b16d52.zip |
New command image-transform-set-percent
* lisp/image-mode.el (image-transform-set-percent): New command.
(image-mode-map): Bind above new command to "s p".
* doc/emacs/files.texi (Image Mode): Document it.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/image-mode.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 726f2af2ad1..7892f0d5b9e 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -494,6 +494,7 @@ image as text, when opening such images in `image-mode'." "s h" #'image-transform-fit-to-height "s i" #'image-transform-fit-to-width "s b" #'image-transform-fit-both + "s p" #'image-transform-set-percent "s s" #'image-transform-set-scale "s r" #'image-transform-set-rotation "s m" #'image-transform-set-smoothing @@ -1530,6 +1531,16 @@ return value is suitable for appending to an image spec." (list :transform-smoothing (string= image--transform-smoothing "smooth"))))))) +(defun image-transform-set-percent (scale) + "Prompt for a percentage, and resize the current image to that size. +The percentage is in relation to the original size of the image." + (interactive (list (read-number "Scale (% of original): " 100 + 'read-number-history))) + (unless (cl-plusp scale) + (error "Not a positive number: %s" scale)) + (setq image-transform-resize (/ scale 100.0)) + (image-toggle-display-image)) + (defun image-transform-set-scale (scale) "Prompt for a number, and resize the current image by that amount." (interactive "nScale: ") |