diff options
Diffstat (limited to 'lisp/image-mode.el')
| -rw-r--r-- | lisp/image-mode.el | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index e677dd0d0e7..e549b49001e 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el | |||
| @@ -153,6 +153,8 @@ otherwise it defaults to t, used for times when the buffer is not displayed." | |||
| 153 | (selected-window)))) | 153 | (selected-window)))) |
| 154 | 154 | ||
| 155 | (declare-function image-size "image.c" (spec &optional pixels frame)) | 155 | (declare-function image-size "image.c" (spec &optional pixels frame)) |
| 156 | (declare-function xwidget-info "xwidget.c" (xwidget)) | ||
| 157 | (declare-function xwidget-at "xwidget.el" (pos)) | ||
| 156 | 158 | ||
| 157 | (defun image-display-size (spec &optional pixels frame) | 159 | (defun image-display-size (spec &optional pixels frame) |
| 158 | "Wrapper around `image-size', handling slice display properties. | 160 | "Wrapper around `image-size', handling slice display properties. |
| @@ -160,24 +162,29 @@ Like `image-size', the return value is (WIDTH . HEIGHT). | |||
| 160 | WIDTH and HEIGHT are in canonical character units if PIXELS is | 162 | WIDTH and HEIGHT are in canonical character units if PIXELS is |
| 161 | nil, and in pixel units if PIXELS is non-nil. | 163 | nil, and in pixel units if PIXELS is non-nil. |
| 162 | 164 | ||
| 163 | If SPEC is an image display property, this function is equivalent | 165 | If SPEC is an image display property, this function is equivalent to |
| 164 | to `image-size'. If SPEC is a list of properties containing | 166 | `image-size'. If SPEC represents an xwidget object, defer to `xwidget-info'. |
| 165 | `image' and `slice' properties, return the display size taking | 167 | If SPEC is a list of properties containing `image' and `slice' properties, |
| 166 | the slice property into account. If the list contains `image' | 168 | return the display size taking the slice property into account. If the list |
| 167 | but not `slice', return the `image-size' of the specified image." | 169 | contains `image' but not `slice', return the `image-size' of the specified |
| 168 | (if (eq (car spec) 'image) | 170 | image." |
| 169 | (image-size spec pixels frame) | 171 | (cond ((eq (car spec) 'xwidget) |
| 170 | (let ((image (assoc 'image spec)) | 172 | (let ((xwi (xwidget-info (xwidget-at (point-min))))) |
| 171 | (slice (assoc 'slice spec))) | 173 | (cons (aref xwi 2) (aref xwi 3)))) |
| 172 | (cond ((and image slice) | 174 | ((eq (car spec) 'image) |
| 173 | (if pixels | 175 | (image-size spec pixels frame)) |
| 174 | (cons (nth 3 slice) (nth 4 slice)) | 176 | (t (let ((image (assoc 'image spec)) |
| 175 | (cons (/ (float (nth 3 slice)) (frame-char-width frame)) | 177 | (slice (assoc 'slice spec))) |
| 176 | (/ (float (nth 4 slice)) (frame-char-height frame))))) | 178 | (cond ((and image slice) |
| 177 | (image | 179 | (if pixels |
| 178 | (image-size image pixels frame)) | 180 | (cons (nth 3 slice) (nth 4 slice)) |
| 179 | (t | 181 | (cons (/ (float (nth 3 slice)) (frame-char-width frame)) |
| 180 | (error "Invalid image specification: %s" spec)))))) | 182 | (/ (float (nth 4 slice)) |
| 183 | (frame-char-height frame))))) | ||
| 184 | (image | ||
| 185 | (image-size image pixels frame)) | ||
| 186 | (t | ||
| 187 | (error "Invalid image specification: %s" spec))))))) | ||
| 181 | 188 | ||
| 182 | (defun image-forward-hscroll (&optional n) | 189 | (defun image-forward-hscroll (&optional n) |
| 183 | "Scroll image in current window to the left by N character widths. | 190 | "Scroll image in current window to the left by N character widths. |