[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

image-rotate: Accept angle as an argument

From: Tino Calancha
Subject: image-rotate: Accept angle as an argument
Date: Mon, 5 Sep 2016 14:52:42 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

lisp/image.el defines 'image-increase-size' and 'image-decrease-size',
with an argument N.  We might allow for an argument in 'image-rotate'
as well.

commit 27fb0aeb3b12256853c86d8494ff258c8926073e
Author: Tino Calancha <address@hidden>
Date:   Mon Sep 5 14:44:18 2016 +0900

    image-rotate: Accept angle as an argument

    * lisp/image.el (image-rotate):
    Add argument ANGLE, the angle in degrees for the rotation.
    Add optional argument _ARG; in interactive calls, a non-nil
    value prompt for ANGLE.

diff --git a/lisp/image.el b/lisp/image.el
index e1f52de..cad8332 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -1008,12 +1008,21 @@ image--current-scaling
         (display-width (car (image-size image t))))
     (/ (float display-width) image-width)))

-(defun image-rotate ()
-  "Rotate the image under point by 90 degrees clockwise."
-  (interactive)
+(defun image-rotate (angle &optional _arg)
+  "Rotate the image under point by ANGLE degrees clockwise.
+If ANGLE is a negative number, then rotate counterclockwise.
+When called interactively with a prefix argument, prompt for ANGLE."
+  (interactive
+   (let* ((ask current-prefix-arg)
+          (default 90)
+          (prompt "Rotate image by ANGLE degrees: ")
+          (rotation (if ask
+                        (read-number prompt default)
+                      default)))
+     (list rotation ask)))
   (let ((image (image--get-imagemagick-and-warn)))
     (plist-put (cdr image) :rotation
- (float (mod (+ (or (plist-get (cdr image) :rotation) 0) 90) + (float (mod (+ (or (plist-get (cdr image) :rotation) 0) angle)
                            ;; We don't want to exceed 360 degrees
                            ;; rotation, because it's not seen as valid
                            ;; in exif data.

In GNU Emacs (x86_64-pc-linux-gnu, GTK+ Version 3.20.9)
 of 2016-09-05 built on calancha-pc
Repository revision: 62e4dc4660cb3b29cfffcad0639e51c7f382ced8

reply via email to

[Prev in Thread] Current Thread [Next in Thread]