aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2022-08-18 19:58:39 +0200
committerStefan Kangas2022-08-18 19:58:39 +0200
commit7858ec980bf968b15703db520e18903e51bfb63f (patch)
treef90367d5acd68ef25775488702ca5b21684324e9
parent104cb5cbf5da4c07d5e4b3d26431eaa42e8ce33d (diff)
downloademacs-7858ec980bf968b15703db520e18903e51bfb63f.tar.gz
emacs-7858ec980bf968b15703db520e18903e51bfb63f.zip
Do interactive mode tagging in image-mode.el
* lisp/image-mode.el (image-forward-hscroll) (image-backward-hscroll, image-next-line, image-previous-line) (image-scroll-up, image-scroll-down, image-scroll-left) (image-scroll-right, image-bol, image-eol, image-bob, image-eob) (image-mode-fit-frame, image-kill-buffer, image-next-file) (image-previous-file, image-mode-copy-file-name-as-kill) (image-mode-mark-file, image-mode-unmark-file) (image-transform-set-percent, image-transform-set-scale) (image-transform-fit-to-height, image-transform-fit-to-width) (image-transform-fit-both, image-transform-fit-to-window) (image-transform-set-rotation, image-transform-set-smoothing) (image-transform-original, image-transform-reset): Add interactive tag for image-mode.
-rw-r--r--lisp/image-mode.el60
1 files changed, 31 insertions, 29 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 20aa9588b38..9646d8e4c3d 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -242,7 +242,7 @@ image."
242(defun image-forward-hscroll (&optional n) 242(defun image-forward-hscroll (&optional n)
243 "Scroll image in current window to the left by N character widths. 243 "Scroll image in current window to the left by N character widths.
244Stop if the right edge of the image is reached." 244Stop if the right edge of the image is reached."
245 (interactive "p") 245 (interactive "p" image-mode)
246 (cond ((= n 0) nil) 246 (cond ((= n 0) nil)
247 ((< n 0) 247 ((< n 0)
248 (image-set-window-hscroll (max 0 (+ (window-hscroll) n)))) 248 (image-set-window-hscroll (max 0 (+ (window-hscroll) n))))
@@ -257,13 +257,13 @@ Stop if the right edge of the image is reached."
257(defun image-backward-hscroll (&optional n) 257(defun image-backward-hscroll (&optional n)
258 "Scroll image in current window to the right by N character widths. 258 "Scroll image in current window to the right by N character widths.
259Stop if the left edge of the image is reached." 259Stop if the left edge of the image is reached."
260 (interactive "p") 260 (interactive "p" image-mode)
261 (image-forward-hscroll (- n))) 261 (image-forward-hscroll (- n)))
262 262
263(defun image-next-line (n) 263(defun image-next-line (n)
264 "Scroll image in current window upward by N lines. 264 "Scroll image in current window upward by N lines.
265Stop if the bottom edge of the image is reached." 265Stop if the bottom edge of the image is reached."
266 (interactive "p") 266 (interactive "p" image-mode)
267 ;; Convert N to pixels. 267 ;; Convert N to pixels.
268 (setq n (* n (frame-char-height))) 268 (setq n (* n (frame-char-height)))
269 (cond ((= n 0) nil) 269 (cond ((= n 0) nil)
@@ -280,7 +280,7 @@ Stop if the bottom edge of the image is reached."
280(defun image-previous-line (&optional n) 280(defun image-previous-line (&optional n)
281 "Scroll image in current window downward by N lines. 281 "Scroll image in current window downward by N lines.
282Stop if the top edge of the image is reached." 282Stop if the top edge of the image is reached."
283 (interactive "p") 283 (interactive "p" image-mode)
284 (image-next-line (- n))) 284 (image-next-line (- n)))
285 285
286(defun image-scroll-up (&optional n) 286(defun image-scroll-up (&optional n)
@@ -298,7 +298,7 @@ A negative N means scroll downward.
298 298
299If N is the atom `-', scroll downward by nearly full screen. 299If N is the atom `-', scroll downward by nearly full screen.
300When calling from a program, supply as argument a number, nil, or `-'." 300When calling from a program, supply as argument a number, nil, or `-'."
301 (interactive "P") 301 (interactive "P" image-mode)
302 (cond ((null n) 302 (cond ((null n)
303 (let* ((edges (window-inside-edges)) 303 (let* ((edges (window-inside-edges))
304 (win-height (- (nth 3 edges) (nth 1 edges)))) 304 (win-height (- (nth 3 edges) (nth 1 edges))))
@@ -326,7 +326,7 @@ A negative N means scroll upward.
326 326
327If N is the atom `-', scroll upward by nearly full screen. 327If N is the atom `-', scroll upward by nearly full screen.
328When calling from a program, supply as argument a number, nil, or `-'." 328When calling from a program, supply as argument a number, nil, or `-'."
329 (interactive "P") 329 (interactive "P" image-mode)
330 (cond ((null n) 330 (cond ((null n)
331 (let* ((edges (window-inside-edges)) 331 (let* ((edges (window-inside-edges))
332 (win-height (- (nth 3 edges) (nth 1 edges)))) 332 (win-height (- (nth 3 edges) (nth 1 edges))))
@@ -347,7 +347,7 @@ A near full screen is 2 columns less than a full screen.
347Negative ARG means scroll rightward. 347Negative ARG means scroll rightward.
348If ARG is the atom `-', scroll rightward by nearly full screen. 348If ARG is the atom `-', scroll rightward by nearly full screen.
349When calling from a program, supply as argument a number, nil, or `-'." 349When calling from a program, supply as argument a number, nil, or `-'."
350 (interactive "P") 350 (interactive "P" image-mode)
351 (cond ((null n) 351 (cond ((null n)
352 (let* ((edges (window-inside-edges)) 352 (let* ((edges (window-inside-edges))
353 (win-width (- (nth 2 edges) (nth 0 edges)))) 353 (win-width (- (nth 2 edges) (nth 0 edges))))
@@ -368,7 +368,7 @@ A near full screen is 2 less than a full screen.
368Negative ARG means scroll leftward. 368Negative ARG means scroll leftward.
369If ARG is the atom `-', scroll leftward by nearly full screen. 369If ARG is the atom `-', scroll leftward by nearly full screen.
370When calling from a program, supply as argument a number, nil, or `-'." 370When calling from a program, supply as argument a number, nil, or `-'."
371 (interactive "P") 371 (interactive "P" image-mode)
372 (cond ((null n) 372 (cond ((null n)
373 (let* ((edges (window-inside-edges)) 373 (let* ((edges (window-inside-edges))
374 (win-width (- (nth 2 edges) (nth 0 edges)))) 374 (win-width (- (nth 2 edges) (nth 0 edges))))
@@ -385,7 +385,7 @@ When calling from a program, supply as argument a number, nil, or `-'."
385 "Scroll horizontally to the left edge of the image in the current window. 385 "Scroll horizontally to the left edge of the image in the current window.
386With argument ARG not nil or 1, move forward ARG - 1 lines first, 386With argument ARG not nil or 1, move forward ARG - 1 lines first,
387stopping if the top or bottom edge of the image is reached." 387stopping if the top or bottom edge of the image is reached."
388 (interactive "p") 388 (interactive "p" image-mode)
389 (and arg 389 (and arg
390 (/= (setq arg (prefix-numeric-value arg)) 1) 390 (/= (setq arg (prefix-numeric-value arg)) 1)
391 (image-next-line (- arg 1))) 391 (image-next-line (- arg 1)))
@@ -395,7 +395,7 @@ stopping if the top or bottom edge of the image is reached."
395 "Scroll horizontally to the right edge of the image in the current window. 395 "Scroll horizontally to the right edge of the image in the current window.
396With argument ARG not nil or 1, move forward ARG - 1 lines first, 396With argument ARG not nil or 1, move forward ARG - 1 lines first,
397stopping if the top or bottom edge of the image is reached." 397stopping if the top or bottom edge of the image is reached."
398 (interactive "p") 398 (interactive "p" image-mode)
399 (and arg 399 (and arg
400 (/= (setq arg (prefix-numeric-value arg)) 1) 400 (/= (setq arg (prefix-numeric-value arg)) 1)
401 (image-next-line (- arg 1))) 401 (image-next-line (- arg 1)))
@@ -407,13 +407,13 @@ stopping if the top or bottom edge of the image is reached."
407 407
408(defun image-bob () 408(defun image-bob ()
409 "Scroll to the top-left corner of the image in the current window." 409 "Scroll to the top-left corner of the image in the current window."
410 (interactive) 410 (interactive nil image-mode)
411 (image-set-window-hscroll 0) 411 (image-set-window-hscroll 0)
412 (image-set-window-vscroll 0)) 412 (image-set-window-vscroll 0))
413 413
414(defun image-eob () 414(defun image-eob ()
415 "Scroll to the bottom-right corner of the image in the current window." 415 "Scroll to the bottom-right corner of the image in the current window."
416 (interactive) 416 (interactive nil image-mode)
417 (let* ((image (image-get-display-property)) 417 (let* ((image (image-get-display-property))
418 (edges (window-inside-edges)) 418 (edges (window-inside-edges))
419 (pixel-edges (window-edges nil t t)) 419 (pixel-edges (window-edges nil t t))
@@ -435,7 +435,7 @@ If called interactively, or if TOGGLE is non-nil, toggle between
435fitting FRAME to the current image and restoring the size and 435fitting FRAME to the current image and restoring the size and
436window configuration prior to the last `image-mode-fit-frame' 436window configuration prior to the last `image-mode-fit-frame'
437call." 437call."
438 (interactive (list nil t)) 438 (interactive (list nil t) image-mode)
439 (let* ((buffer (current-buffer)) 439 (let* ((buffer (current-buffer))
440 (saved (frame-parameter frame 'image-mode-saved-params)) 440 (saved (frame-parameter frame 'image-mode-saved-params))
441 (window-configuration (current-window-configuration frame)) 441 (window-configuration (current-window-configuration frame))
@@ -1014,7 +1014,7 @@ Otherwise, display the image by calling `image-mode'."
1014 1014
1015(defun image-kill-buffer () 1015(defun image-kill-buffer ()
1016 "Kill the current buffer." 1016 "Kill the current buffer."
1017 (interactive) 1017 (interactive nil image-mode)
1018 (kill-buffer (current-buffer))) 1018 (kill-buffer (current-buffer)))
1019 1019
1020(defun image-after-revert-hook () 1020(defun image-after-revert-hook ()
@@ -1195,7 +1195,7 @@ current one, in cyclic alphabetical order.
1195 1195
1196This command visits the specified file via `find-alternate-file', 1196This command visits the specified file via `find-alternate-file',
1197replacing the current Image mode buffer." 1197replacing the current Image mode buffer."
1198 (interactive "p") 1198 (interactive "p" image-mode)
1199 (unless (derived-mode-p 'image-mode) 1199 (unless (derived-mode-p 'image-mode)
1200 (error "The buffer is not in Image mode")) 1200 (error "The buffer is not in Image mode"))
1201 (unless buffer-file-name 1201 (unless buffer-file-name
@@ -1292,12 +1292,12 @@ current one, in cyclic alphabetical order.
1292 1292
1293This command visits the specified file via `find-alternate-file', 1293This command visits the specified file via `find-alternate-file',
1294replacing the current Image mode buffer." 1294replacing the current Image mode buffer."
1295 (interactive "p") 1295 (interactive "p" image-mode)
1296 (image-next-file (- n))) 1296 (image-next-file (- n)))
1297 1297
1298(defun image-mode-copy-file-name-as-kill () 1298(defun image-mode-copy-file-name-as-kill ()
1299 "Push the currently visited file name onto the kill ring." 1299 "Push the currently visited file name onto the kill ring."
1300 (interactive) 1300 (interactive nil image-mode)
1301 (unless buffer-file-name 1301 (unless buffer-file-name
1302 (error "The current buffer doesn't visit a file")) 1302 (error "The current buffer doesn't visit a file"))
1303 (kill-new buffer-file-name) 1303 (kill-new buffer-file-name)
@@ -1309,7 +1309,7 @@ Any dired buffer that's opened to the current file's directory
1309will have the line where the image appears (if any) marked. 1309will have the line where the image appears (if any) marked.
1310 1310
1311If no such buffer exists, it will be opened." 1311If no such buffer exists, it will be opened."
1312 (interactive) 1312 (interactive nil image-mode)
1313 (unless buffer-file-name 1313 (unless buffer-file-name
1314 (error "Current buffer is not visiting a file")) 1314 (error "Current buffer is not visiting a file"))
1315 (image-mode--mark-file buffer-file-name #'dired-mark "marked")) 1315 (image-mode--mark-file buffer-file-name #'dired-mark "marked"))
@@ -1321,7 +1321,7 @@ will remove the mark from the line where the image appears (if
1321any). 1321any).
1322 1322
1323If no such buffer exists, it will be opened." 1323If no such buffer exists, it will be opened."
1324 (interactive) 1324 (interactive nil image-mode)
1325 (unless buffer-file-name 1325 (unless buffer-file-name
1326 (error "Current buffer is not visiting a file")) 1326 (error "Current buffer is not visiting a file"))
1327 (image-mode--mark-file buffer-file-name #'dired-unmark "unmarked")) 1327 (image-mode--mark-file buffer-file-name #'dired-unmark "unmarked"))
@@ -1539,7 +1539,8 @@ return value is suitable for appending to an image spec."
1539 "Prompt for a percentage, and resize the current image to that size. 1539 "Prompt for a percentage, and resize the current image to that size.
1540The percentage is in relation to the original size of the image." 1540The percentage is in relation to the original size of the image."
1541 (interactive (list (read-number "Scale (% of original): " 100 1541 (interactive (list (read-number "Scale (% of original): " 100
1542 'read-number-history))) 1542 'read-number-history))
1543 image-mode)
1543 (unless (cl-plusp scale) 1544 (unless (cl-plusp scale)
1544 (error "Not a positive number: %s" scale)) 1545 (error "Not a positive number: %s" scale))
1545 (setq image-transform-resize (/ scale 100.0)) 1546 (setq image-transform-resize (/ scale 100.0))
@@ -1547,59 +1548,60 @@ The percentage is in relation to the original size of the image."
1547 1548
1548(defun image-transform-set-scale (scale) 1549(defun image-transform-set-scale (scale)
1549 "Prompt for a number, and resize the current image by that amount." 1550 "Prompt for a number, and resize the current image by that amount."
1550 (interactive "nScale: ") 1551 (interactive "nScale: " image-mode)
1551 (setq image-transform-resize scale) 1552 (setq image-transform-resize scale)
1552 (image-toggle-display-image)) 1553 (image-toggle-display-image))
1553 1554
1554(defun image-transform-fit-to-height () 1555(defun image-transform-fit-to-height ()
1555 "Fit the current image to the height of the current window." 1556 "Fit the current image to the height of the current window."
1556 (declare (obsolete nil "29.1")) 1557 (declare (obsolete nil "29.1"))
1557 (interactive) 1558 (interactive nil image-mode)
1558 (setq image-transform-resize 'fit-height) 1559 (setq image-transform-resize 'fit-height)
1559 (image-toggle-display-image)) 1560 (image-toggle-display-image))
1560 1561
1561(defun image-transform-fit-to-width () 1562(defun image-transform-fit-to-width ()
1562 "Fit the current image to the width of the current window." 1563 "Fit the current image to the width of the current window."
1563 (declare (obsolete nil "29.1")) 1564 (declare (obsolete nil "29.1"))
1564 (interactive) 1565 (interactive nil image-mode)
1565 (setq image-transform-resize 'fit-width) 1566 (setq image-transform-resize 'fit-width)
1566 (image-toggle-display-image)) 1567 (image-toggle-display-image))
1567 1568
1568(defun image-transform-fit-both () 1569(defun image-transform-fit-both ()
1569 "Scale the current image down to fit in the current window." 1570 "Scale the current image down to fit in the current window."
1570 (interactive) 1571 (interactive nil image-mode)
1571 (setq image-transform-resize t) 1572 (setq image-transform-resize t)
1572 (image-toggle-display-image)) 1573 (image-toggle-display-image))
1573 1574
1574(defun image-transform-fit-to-window () 1575(defun image-transform-fit-to-window ()
1575 "Fit the current image to the height and width of the current window." 1576 "Fit the current image to the height and width of the current window."
1576 (interactive) 1577 (interactive nil image-mode)
1577 (setq image-transform-resize 'fit-window) 1578 (setq image-transform-resize 'fit-window)
1578 (image-toggle-display-image)) 1579 (image-toggle-display-image))
1579 1580
1580(defun image-transform-set-rotation (rotation) 1581(defun image-transform-set-rotation (rotation)
1581 "Prompt for an angle ROTATION, and rotate the image by that amount. 1582 "Prompt for an angle ROTATION, and rotate the image by that amount.
1582ROTATION should be in degrees." 1583ROTATION should be in degrees."
1583 (interactive "nRotation angle (in degrees): ") 1584 (interactive "nRotation angle (in degrees): " image-mode)
1584 (setq image-transform-rotation (float (mod rotation 360))) 1585 (setq image-transform-rotation (float (mod rotation 360)))
1585 (image-toggle-display-image)) 1586 (image-toggle-display-image))
1586 1587
1587(defun image-transform-set-smoothing (smoothing) 1588(defun image-transform-set-smoothing (smoothing)
1588 (interactive (list (completing-read "Smoothing: " 1589 (interactive (list (completing-read "Smoothing: "
1589 '("none" "smooth") nil t))) 1590 '("none" "smooth") nil t))
1591 image-mode)
1590 (setq image--transform-smoothing smoothing) 1592 (setq image--transform-smoothing smoothing)
1591 (image-toggle-display-image)) 1593 (image-toggle-display-image))
1592 1594
1593(defun image-transform-original () 1595(defun image-transform-original ()
1594 "Display the current image with the original (actual) size and rotation." 1596 "Display the current image with the original (actual) size and rotation."
1595 (interactive) 1597 (interactive nil image-mode)
1596 (setq image-transform-resize nil 1598 (setq image-transform-resize nil
1597 image-transform-scale 1) 1599 image-transform-scale 1)
1598 (image-toggle-display-image)) 1600 (image-toggle-display-image))
1599 1601
1600(defun image-transform-reset () 1602(defun image-transform-reset ()
1601 "Display the current image with the default (initial) size and rotation." 1603 "Display the current image with the default (initial) size and rotation."
1602 (interactive) 1604 (interactive nil image-mode)
1603 (setq image-transform-resize image-auto-resize 1605 (setq image-transform-resize image-auto-resize
1604 image-transform-rotation 0.0 1606 image-transform-rotation 0.0
1605 image-transform-scale 1 1607 image-transform-scale 1