diff options
author | Joakim Verona <joakim@verona.se> | 2010-08-17 23:19:11 +0200 |
---|---|---|
committer | Joakim Verona <joakim@verona.se> | 2010-08-17 23:19:11 +0200 |
commit | a8101f663e6cbff953b67b8bef33bc0171818477 (patch) | |
tree | 8f71a16188f75e91670e05379fb4de2d0136cbf4 /lisp/image-mode.el | |
parent | fe72c5b4651334677326104ec138e7cdd50f2ffe (diff) | |
parent | 489cd5bd5a0128d6c3bee49fa2c451f2927ddea9 (diff) | |
download | emacs-a8101f663e6cbff953b67b8bef33bc0171818477.tar.gz |
merge from trunk
Diffstat (limited to 'lisp/image-mode.el')
-rw-r--r-- | lisp/image-mode.el | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 9bd5a76d5da..5bda540fdfe 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -128,6 +128,28 @@ A winprops object has the shape (WINDOW . ALIST)." (declare-function image-size "image.c" (spec &optional pixels frame)) +(defun image-display-size (spec &optional pixels frame) + "Wrapper around `image-size', to handle slice display properties. +If SPEC is an image display property, call `image-size' with the +given arguments. +If SPEC is a list of properties containing `image' and `slice' +properties, calculate the display size from the slice property. +If SPEC contains `image' but not `slice', call `image-size' with +the specified image." + (if (eq (car spec) 'image) + (image-size spec pixels frame) + (let ((image (assoc 'image spec)) + (slice (assoc 'slice spec))) + (cond ((and image slice) + (if pixels + (cons (nth 3 slice) (nth 4 slice)) + (cons (/ (float (nth 3 slice)) (frame-char-width frame)) + (/ (float (nth 4 slice)) (frame-char-height frame))))) + (image + (image-size image pixels frame)) + (t + (error "Invalid image specification: %s" spec)))))) + (defun image-forward-hscroll (&optional n) "Scroll image in current window to the left by N character widths. Stop if the right edge of the image is reached." @@ -139,7 +161,7 @@ Stop if the right edge of the image is reached." (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (win-width (- (nth 2 edges) (nth 0 edges))) - (img-width (ceiling (car (image-size image))))) + (img-width (ceiling (car (image-display-size image))))) (image-set-window-hscroll (min (max 0 (- img-width win-width)) (+ n (window-hscroll)))))))) @@ -160,7 +182,7 @@ Stop if the bottom edge of the image is reached." (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (win-height (- (nth 3 edges) (nth 1 edges))) - (img-height (ceiling (cdr (image-size image))))) + (img-height (ceiling (cdr (image-display-size image))))) (image-set-window-vscroll (min (max 0 (- img-height win-height)) (+ n (window-vscroll)))))))) @@ -233,7 +255,7 @@ stopping if the top or bottom edge of the image is reached." (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (win-width (- (nth 2 edges) (nth 0 edges))) - (img-width (ceiling (car (image-size image))))) + (img-width (ceiling (car (image-display-size image))))) (image-set-window-hscroll (max 0 (- img-width win-width))))) (defun image-bob () @@ -248,9 +270,9 @@ stopping if the top or bottom edge of the image is reached." (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (win-width (- (nth 2 edges) (nth 0 edges))) - (img-width (ceiling (car (image-size image)))) + (img-width (ceiling (car (image-display-size image)))) (win-height (- (nth 3 edges) (nth 1 edges))) - (img-height (ceiling (cdr (image-size image))))) + (img-height (ceiling (cdr (image-display-size image))))) (image-set-window-hscroll (max 0 (- img-width win-width))) (image-set-window-vscroll (max 0 (- img-height win-height))))) @@ -264,7 +286,7 @@ This function assumes the current frame has only one window." (interactive) (let* ((saved (frame-parameter nil 'image-mode-saved-size)) (display (image-get-display-property)) - (size (image-size display))) + (size (image-display-size display))) (if (and saved (eq (caar saved) (frame-width)) (eq (cdar saved) (frame-height))) @@ -519,15 +541,15 @@ the image file and `image-mode' showing the image as an image." ;;; Support for bookmark.el -(declare-function bookmark-make-record-default "bookmark" - (&optional point-only)) +(declare-function bookmark-make-record-default + "bookmark" (&optional no-file no-context posn)) (declare-function bookmark-prop-get "bookmark" (bookmark prop)) (declare-function bookmark-default-handler "bookmark" (bmk)) (defun image-bookmark-make-record () - (nconc (bookmark-make-record-default) - `((image-type . ,image-type) - (handler . image-bookmark-jump)))) + `(,@(bookmark-make-record-default nil 'no-context 0) + (image-type . ,image-type) + (handler . image-bookmark-jump))) ;;;###autoload (defun image-bookmark-jump (bmk) |