diff options
| author | Tassilo Horn | 2013-03-14 16:24:04 +0100 |
|---|---|---|
| committer | Tassilo Horn | 2013-03-14 16:24:04 +0100 |
| commit | d35f586402bb8545871f488b07032805310b8de2 (patch) | |
| tree | 5155bdf5e67d378ef80b8a47a27badaf40c06e25 | |
| parent | 2407788fbbb919458ade69651d4de402f2096367 (diff) | |
| download | emacs-d35f586402bb8545871f488b07032805310b8de2.tar.gz emacs-d35f586402bb8545871f488b07032805310b8de2.zip | |
* doc-view.el (doc-view-insert-image): Don't modify overlay
associated with pseudo winprops entry, and implement horizontal
centering of image in case it's smaller than the window
(bug#13887).
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/doc-view.el | 92 |
2 files changed, 61 insertions, 38 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 30f4739a8a9..a5dbac3a5a0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-03-14 Tassilo Horn <tsdh@gnu.org> | ||
| 2 | |||
| 3 | * doc-view.el (doc-view-insert-image): Don't modify overlay | ||
| 4 | associated with pseudo winprops entry, and implement horizontal | ||
| 5 | centering of image in case it's smaller than the window | ||
| 6 | (bug#13887). | ||
| 7 | |||
| 1 | 2013-03-13 Karl Fogel <kfogel@red-bean.com> | 8 | 2013-03-13 Karl Fogel <kfogel@red-bean.com> |
| 2 | 9 | ||
| 3 | * saveplace.el (save-place-alist-to-file): Don't sort | 10 | * saveplace.el (save-place-alist-to-file): Don't sort |
diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 0cfdc9a22d1..7290040d168 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el | |||
| @@ -1250,44 +1250,60 @@ ARGS is a list of image descriptors." | |||
| 1250 | (when doc-view-pending-cache-flush | 1250 | (when doc-view-pending-cache-flush |
| 1251 | (clear-image-cache) | 1251 | (clear-image-cache) |
| 1252 | (setq doc-view-pending-cache-flush nil)) | 1252 | (setq doc-view-pending-cache-flush nil)) |
| 1253 | (let ((ol (doc-view-current-overlay)) | 1253 | (let ((ol (doc-view-current-overlay))) |
| 1254 | (image (if (and file (file-readable-p file)) | 1254 | ;; ol might be deleted (see `doc-view-new-window-function'), in |
| 1255 | (if (not (and doc-view-scale-internally | 1255 | ;; which case we don't want to modify it. |
| 1256 | (fboundp 'imagemagick-types))) | 1256 | (when (overlay-buffer ol) |
| 1257 | (apply 'create-image file doc-view--image-type nil args) | 1257 | (let* ((image (if (and file (file-readable-p file)) |
| 1258 | (unless (member :width args) | 1258 | (if (not (and doc-view-scale-internally |
| 1259 | (setq args `(,@args :width ,doc-view-image-width))) | 1259 | (fboundp 'imagemagick-types))) |
| 1260 | (apply 'create-image file 'imagemagick nil args)))) | 1260 | (apply 'create-image file doc-view--image-type nil args) |
| 1261 | (slice (doc-view-current-slice))) | 1261 | (unless (member :width args) |
| 1262 | (setf (doc-view-current-image) image) | 1262 | (setq args `(,@args :width ,doc-view-image-width))) |
| 1263 | (move-overlay ol (point-min) (point-max)) | 1263 | (apply 'create-image file 'imagemagick nil args)))) |
| 1264 | (overlay-put ol 'display | 1264 | (slice (doc-view-current-slice)) |
| 1265 | (cond | 1265 | (img-width (and image (car (image-size image)))) |
| 1266 | (image | 1266 | (displayed-img-width (if (and image slice) |
| 1267 | (if slice | 1267 | (* (/ (float (nth 2 slice)) |
| 1268 | (list (cons 'slice slice) image) | 1268 | (car (image-size image 'pixels))) |
| 1269 | image)) | 1269 | img-width) |
| 1270 | ;; We're trying to display a page that doesn't exist. | 1270 | img-width)) |
| 1271 | (doc-view-current-converter-processes | 1271 | (window-width (window-width (selected-window)))) |
| 1272 | ;; Maybe the page doesn't exist *yet*. | 1272 | (setf (doc-view-current-image) image) |
| 1273 | "Cannot display this page (yet)!") | 1273 | (move-overlay ol (point-min) (point-max)) |
| 1274 | (t | 1274 | ;; In case the window is wider than the image, center the image |
| 1275 | ;; Typically happens if the conversion process somehow | 1275 | ;; horizontally. |
| 1276 | ;; failed. Better not signal an error here because it | 1276 | (overlay-put ol 'before-string |
| 1277 | ;; could prevent a subsequent reconversion from fixing | 1277 | (when (and image (> window-width displayed-img-width)) |
| 1278 | ;; the problem. | 1278 | (propertize " " 'display |
| 1279 | (concat "Cannot display this page!\n" | 1279 | `(space :align-to (+ center (-0.5 . ,displayed-img-width)))))) |
| 1280 | "Maybe because of a conversion failure!")))) | 1280 | (overlay-put ol 'display |
| 1281 | (let ((win (overlay-get ol 'window))) | 1281 | (cond |
| 1282 | (if (stringp (overlay-get ol 'display)) | 1282 | (image |
| 1283 | (progn ;Make sure the text is not scrolled out of view. | 1283 | (if slice |
| 1284 | (set-window-hscroll win 0) | 1284 | (list (cons 'slice slice) image) |
| 1285 | (set-window-vscroll win 0)) | 1285 | image)) |
| 1286 | (let ((hscroll (image-mode-window-get 'hscroll win)) | 1286 | ;; We're trying to display a page that doesn't exist. |
| 1287 | (vscroll (image-mode-window-get 'vscroll win))) | 1287 | (doc-view-current-converter-processes |
| 1288 | ;; Reset scroll settings, in case they were changed. | 1288 | ;; Maybe the page doesn't exist *yet*. |
| 1289 | (if hscroll (set-window-hscroll win hscroll)) | 1289 | "Cannot display this page (yet)!") |
| 1290 | (if vscroll (set-window-vscroll win vscroll))))))) | 1290 | (t |
| 1291 | ;; Typically happens if the conversion process somehow | ||
| 1292 | ;; failed. Better not signal an error here because it | ||
| 1293 | ;; could prevent a subsequent reconversion from fixing | ||
| 1294 | ;; the problem. | ||
| 1295 | (concat "Cannot display this page!\n" | ||
| 1296 | "Maybe because of a conversion failure!")))) | ||
| 1297 | (let ((win (overlay-get ol 'window))) | ||
| 1298 | (if (stringp (overlay-get ol 'display)) | ||
| 1299 | (progn ;Make sure the text is not scrolled out of view. | ||
| 1300 | (set-window-hscroll win 0) | ||
| 1301 | (set-window-vscroll win 0)) | ||
| 1302 | (let ((hscroll (image-mode-window-get 'hscroll win)) | ||
| 1303 | (vscroll (image-mode-window-get 'vscroll win))) | ||
| 1304 | ;; Reset scroll settings, in case they were changed. | ||
| 1305 | (if hscroll (set-window-hscroll win hscroll)) | ||
| 1306 | (if vscroll (set-window-vscroll win vscroll))))))))) | ||
| 1291 | 1307 | ||
| 1292 | (defun doc-view-sort (a b) | 1308 | (defun doc-view-sort (a b) |
| 1293 | "Return non-nil if A should be sorted before B. | 1309 | "Return non-nil if A should be sorted before B. |