aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJoakim Verona2010-07-10 22:35:42 +0200
committerJoakim Verona2010-07-10 22:35:42 +0200
commitfe72c5b4651334677326104ec138e7cdd50f2ffe (patch)
treead0ce60cec882f6d25b0edf5d3249e3fa508757c /lisp
parent788489aa741e8cefdccf881459eac789c7041e92 (diff)
downloademacs-fe72c5b4651334677326104ec138e7cdd50f2ffe.tar.gz
emacs-fe72c5b4651334677326104ec138e7cdd50f2ffe.zip
some more docs and polish
Diffstat (limited to 'lisp')
-rw-r--r--lisp/image-mode.el34
1 files changed, 19 insertions, 15 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 78ec4772d16..9bd5a76d5da 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -543,8 +543,8 @@ the image file and `image-mode' showing the image as an image."
543; (define-key map [(control ?+)] 'image-scale-in) 543; (define-key map [(control ?+)] 'image-scale-in)
544; (define-key map [(control ?-)] 'image-scale-out) 544; (define-key map [(control ?-)] 'image-scale-out)
545; (define-key map [(control ?=)] 'image-scale-none) 545; (define-key map [(control ?=)] 'image-scale-none)
546;; (define-key map "c f h" 'image-scale-fit-height) 546;; (define-key map "c f h" 'image-scale-fit-height)
547;; (define-key map "c ]" 'image-rotate-right) 547;; (define-key map "c ]" 'image-rotate-right)
548 map) 548 map)
549 "Minor mode keymap for transforming the view of images Image mode.") 549 "Minor mode keymap for transforming the view of images Image mode.")
550 550
@@ -553,23 +553,16 @@ the image file and `image-mode' showing the image as an image."
553 nil "image-transform" 553 nil "image-transform"
554 image-transform-minor-mode-map) 554 image-transform-minor-mode-map)
555 555
556;;these are supposed to be buffer local 556(defvar image-transform-resize nil
557;(defvar image-transform-height 100);;nil should mean 100% 557 "The image resize operation. See the command
558;;the interface could rather be: 558 `image-transform-set-scale' for more information." )
559(defvar image-transform-resize
560 nil
561 "values: fit-height number=scale nil=scale100% TODO fit-width fit-page"
562 )
563 559
564;;TODO 0 90 180 270 degrees are the only reasonable angles here
565;;otherwise combining with rescaling will get very awkward
566(defvar image-transform-rotation 0.0) 560(defvar image-transform-rotation 0.0)
567 561
568;;then it would be nice with a bunch of globals like:
569;; image-transform-always-resize values: 'fit-height nil=100% number=scale TODO 'fit-width 'fit-page
570;; image-transform-always-rotate value: angle
571 562
572(defun image-transform-properties (display) 563(defun image-transform-properties (display)
564 "Calculate the display properties for transformations; scaling
565and rotation. "
573 (let* 566 (let*
574 ((size (image-size display t)) 567 ((size (image-size display t))
575 (height 568 (height
@@ -588,28 +581,39 @@ the image file and `image-mode' showing the image as an image."
588 ,@(if width (list :width width)) 581 ,@(if width (list :width width))
589 ,@(if (not (equal 0.0 image-transform-rotation)) 582 ,@(if (not (equal 0.0 image-transform-rotation))
590 (list :rotation image-transform-rotation)) 583 (list :rotation image-transform-rotation))
584 ;;TODO fit-to-* should consider the rotation angle
591 ))) 585 )))
592 586
593(defun image-transform-set-scale (scale) 587(defun image-transform-set-scale (scale)
588 "SCALE sets the scaling for images. "
594 (interactive "nscale:") 589 (interactive "nscale:")
595 (image-transform-set-resize (float scale))) 590 (image-transform-set-resize (float scale)))
596 591
597(defun image-transform-fit-to-height () 592(defun image-transform-fit-to-height ()
593 "Fit image height to window height. "
598 (interactive) 594 (interactive)
599 (image-transform-set-resize 'fit-height)) 595 (image-transform-set-resize 'fit-height))
600 596
601(defun image-transform-fit-to-width () 597(defun image-transform-fit-to-width ()
598 "Fit image width to window width. "
602 (interactive) 599 (interactive)
603 (image-transform-set-resize 'fit-width)) 600 (image-transform-set-resize 'fit-width))
604 601
605(defun image-transform-set-resize (resize) 602(defun image-transform-set-resize (resize)
603 "Set the resize mode for images. The RESIZE value can be the
604symbol fit-height which fits the image to the window height. The
605symbol fit-width fits the image to the window width. A number
606indicates a scaling factor. nil indicates scale to 100%. "
606 (setq image-transform-resize resize) 607 (setq image-transform-resize resize)
607 (if (eq 'image-mode major-mode) (image-toggle-display-image))) 608 (if (eq 'image-mode major-mode) (image-toggle-display-image)))
608 609
609(defun image-transform-set-rotation (rotation) 610(defun image-transform-set-rotation (rotation)
611 "Set the image ROTATION angle. "
610 (interactive "nrotation:") 612 (interactive "nrotation:")
613 ;;TODO 0 90 180 270 degrees are the only reasonable angles here
614 ;;otherwise combining with rescaling will get very awkward
611 (setq image-transform-rotation (float rotation)) 615 (setq image-transform-rotation (float rotation))
612 (image-toggle-display-image)) 616 (if (eq major-mode 'image-mode) (image-toggle-display-image)))
613 617
614(provide 'image-mode) 618(provide 'image-mode)
615 619