From 3a50be5108590c360a5cf90f7010c36d870f9cd1 Mon Sep 17 00:00:00 2001 From: Joakim Verona Date: Sun, 27 Jun 2010 02:18:55 +0200 Subject: [PATCH] support for fit-width --- lisp/image-mode.el | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lisp/image-mode.el b/lisp/image-mode.el index a278c47a555..78ec4772d16 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -579,12 +579,16 @@ the image file and `image-mode' showing the image as an image." ((numberp image-transform-resize) (* image-transform-resize (cdr size))) ((eq image-transform-resize 'fit-height) - (nth 3 (window-inside-pixel-edges))) - ))) - `(,@(if height (list :height height)) - ,@(if (not (equal 0.0 image-transform-rotation)) - (list :rotation image-transform-rotation)) - ))) + (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) + (t nil))) + (width (if (eq image-transform-resize 'fit-width) + (- (nth 2 (window-inside-pixel-edges)) (nth 0 (window-inside-pixel-edges)))))) + + `(,@(if height (list :height height)) + ,@(if width (list :width width)) + ,@(if (not (equal 0.0 image-transform-rotation)) + (list :rotation image-transform-rotation)) + ))) (defun image-transform-set-scale (scale) (interactive "nscale:") @@ -594,9 +598,13 @@ the image file and `image-mode' showing the image as an image." (interactive) (image-transform-set-resize 'fit-height)) +(defun image-transform-fit-to-width () + (interactive) + (image-transform-set-resize 'fit-width)) + (defun image-transform-set-resize (resize) (setq image-transform-resize resize) - (image-toggle-display-image)) + (if (eq 'image-mode major-mode) (image-toggle-display-image))) (defun image-transform-set-rotation (rotation) (interactive "nrotation:") -- 2.39.2