diff options
| author | Stefan Kangas | 2021-10-28 03:36:28 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2022-08-18 19:31:28 +0200 |
| commit | 0dc9c9a68f5a137fd71d7aca356d08fd52b16d52 (patch) | |
| tree | d0a41ae9ea3e6ebeedb6d72008e151c5a0175c4f | |
| parent | 9f8e16d828bab7db3bdf67fabd5b3abfe3974e8e (diff) | |
| download | emacs-0dc9c9a68f5a137fd71d7aca356d08fd52b16d52.tar.gz 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.
| -rw-r--r-- | doc/emacs/files.texi | 14 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/image-mode.el | 11 |
3 files changed, 24 insertions, 6 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 404978b315d..5b3b15cd38f 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -2273,12 +2273,14 @@ behavior by using the options @code{image-auto-resize} and | |||
| 2273 | @findex image-transform-set-scale | 2273 | @findex image-transform-set-scale |
| 2274 | @findex image-transform-reset | 2274 | @findex image-transform-reset |
| 2275 | To resize the image manually you can use the command | 2275 | To resize the image manually you can use the command |
| 2276 | @code{image-transform-fit-to-window} bound to @kbd{s w} | 2276 | @code{image-transform-fit-to-window} bound to @kbd{s w} that fits the |
| 2277 | that fits the image to both the window height and width. | 2277 | image to both the window height and width. To scale the image to a |
| 2278 | To scale the image specifying a scale factor, use the command | 2278 | percentage of its original size, use the command |
| 2279 | @code{image-transform-set-scale} bound to @kbd{s s}. | 2279 | @code{image-transform-set-percent} bound to @kbd{s p}. To scale |
| 2280 | To reset all transformations to the initial state, use | 2280 | the image specifying a scale factor, use the command |
| 2281 | @code{image-transform-reset} bound to @kbd{s 0}. | 2281 | @code{image-transform-set-scale} bound to @kbd{s s}. To reset all |
| 2282 | transformations to the initial state, use @code{image-transform-reset} | ||
| 2283 | bound to @kbd{s 0}. | ||
| 2282 | 2284 | ||
| 2283 | @findex image-next-file | 2285 | @findex image-next-file |
| 2284 | @findex image-previous-file | 2286 | @findex image-previous-file |
| @@ -1863,6 +1863,11 @@ this message for SVG and XPM. | |||
| 1863 | *** New commands: 'image-flip-horizontally' and 'image-flip-vertically'. | 1863 | *** New commands: 'image-flip-horizontally' and 'image-flip-vertically'. |
| 1864 | These commands horizontally and vertically flip the image under point. | 1864 | These commands horizontally and vertically flip the image under point. |
| 1865 | 1865 | ||
| 1866 | +++ | ||
| 1867 | *** New command 'image-transform-set-percent'. | ||
| 1868 | It allows setting the image size to a percentage of its original size, | ||
| 1869 | and is bound to "s p" in Image mode. | ||
| 1870 | |||
| 1866 | ** Images | 1871 | ** Images |
| 1867 | 1872 | ||
| 1868 | +++ | 1873 | +++ |
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'." | |||
| 494 | "s h" #'image-transform-fit-to-height | 494 | "s h" #'image-transform-fit-to-height |
| 495 | "s i" #'image-transform-fit-to-width | 495 | "s i" #'image-transform-fit-to-width |
| 496 | "s b" #'image-transform-fit-both | 496 | "s b" #'image-transform-fit-both |
| 497 | "s p" #'image-transform-set-percent | ||
| 497 | "s s" #'image-transform-set-scale | 498 | "s s" #'image-transform-set-scale |
| 498 | "s r" #'image-transform-set-rotation | 499 | "s r" #'image-transform-set-rotation |
| 499 | "s m" #'image-transform-set-smoothing | 500 | "s m" #'image-transform-set-smoothing |
| @@ -1530,6 +1531,16 @@ return value is suitable for appending to an image spec." | |||
| 1530 | (list :transform-smoothing | 1531 | (list :transform-smoothing |
| 1531 | (string= image--transform-smoothing "smooth"))))))) | 1532 | (string= image--transform-smoothing "smooth"))))))) |
| 1532 | 1533 | ||
| 1534 | (defun image-transform-set-percent (scale) | ||
| 1535 | "Prompt for a percentage, and resize the current image to that size. | ||
| 1536 | The percentage is in relation to the original size of the image." | ||
| 1537 | (interactive (list (read-number "Scale (% of original): " 100 | ||
| 1538 | 'read-number-history))) | ||
| 1539 | (unless (cl-plusp scale) | ||
| 1540 | (error "Not a positive number: %s" scale)) | ||
| 1541 | (setq image-transform-resize (/ scale 100.0)) | ||
| 1542 | (image-toggle-display-image)) | ||
| 1543 | |||
| 1533 | (defun image-transform-set-scale (scale) | 1544 | (defun image-transform-set-scale (scale) |
| 1534 | "Prompt for a number, and resize the current image by that amount." | 1545 | "Prompt for a number, and resize the current image by that amount." |
| 1535 | (interactive "nScale: ") | 1546 | (interactive "nScale: ") |