diff options
| author | Lars Ingebrigtsen | 2020-08-03 09:00:53 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-08-03 09:00:53 +0200 |
| commit | 79527cd56e9e3f8b5b1630fe18b92f7ea95e87fd (patch) | |
| tree | cfb1242d8ab309be5fa7d0fc04073dd35f728282 | |
| parent | 26b9a1da63bab8c8ee00a484df46db6ed57e2317 (diff) | |
| download | emacs-79527cd56e9e3f8b5b1630fe18b92f7ea95e87fd.tar.gz emacs-79527cd56e9e3f8b5b1630fe18b92f7ea95e87fd.zip | |
Fix problem with viewing .webp files from .zip buffers
* lisp/image-mode.el (image-toggle-display-image): Make it
possible to view images (via external formatters, like webp) from
zip files (and other archive modes) (bug#39994).
| -rw-r--r-- | lisp/image-mode.el | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 129529542ae..c417be43da5 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el | |||
| @@ -818,13 +818,21 @@ was inserted." | |||
| 818 | (- (nth 2 edges) (nth 0 edges)))) | 818 | (- (nth 2 edges) (nth 0 edges)))) |
| 819 | (max-height (when edges | 819 | (max-height (when edges |
| 820 | (- (nth 3 edges) (nth 1 edges)))) | 820 | (- (nth 3 edges) (nth 1 edges)))) |
| 821 | (type (if (image--imagemagick-wanted-p filename) | ||
| 822 | 'imagemagick | ||
| 823 | (image-type file-or-data nil data-p))) | ||
| 824 | (inhibit-read-only t) | 821 | (inhibit-read-only t) |
| 825 | (buffer-undo-list t) | 822 | (buffer-undo-list t) |
| 826 | (modified (buffer-modified-p)) | 823 | (modified (buffer-modified-p)) |
| 827 | props image) | 824 | props image type) |
| 825 | |||
| 826 | ;; If the data in the current buffer isn't from an existing file, | ||
| 827 | ;; but we have a file name (this happens when visiting images from | ||
| 828 | ;; a zip file, for instance), provide a type hint based on the | ||
| 829 | ;; suffix. | ||
| 830 | (when (and data-p filename) | ||
| 831 | (setq data-p (intern (format "image/%s" | ||
| 832 | (file-name-extension filename))))) | ||
| 833 | (setq type (if (image--imagemagick-wanted-p filename) | ||
| 834 | 'imagemagick | ||
| 835 | (image-type file-or-data nil data-p))) | ||
| 828 | 836 | ||
| 829 | ;; Get the rotation data from the file, if any. | 837 | ;; Get the rotation data from the file, if any. |
| 830 | (when (zerop image-transform-rotation) ; don't reset modified value | 838 | (when (zerop image-transform-rotation) ; don't reset modified value |
| @@ -841,10 +849,13 @@ was inserted." | |||
| 841 | ;; :scale 1: If we do not set this, create-image will apply | 849 | ;; :scale 1: If we do not set this, create-image will apply |
| 842 | ;; default scaling based on font size. | 850 | ;; default scaling based on font size. |
| 843 | (setq image (if (not edges) | 851 | (setq image (if (not edges) |
| 844 | (create-image file-or-data type data-p :scale 1) | 852 | (create-image file-or-data type data-p :scale 1 |
| 853 | :format (and filename data-p)) | ||
| 845 | (create-image file-or-data type data-p :scale 1 | 854 | (create-image file-or-data type data-p :scale 1 |
| 846 | :max-width max-width | 855 | :max-width max-width |
| 847 | :max-height max-height))) | 856 | :max-height max-height |
| 857 | ;; Type hint. | ||
| 858 | :format (and filename data-p)))) | ||
| 848 | 859 | ||
| 849 | ;; Discard any stale image data before looking it up again. | 860 | ;; Discard any stale image data before looking it up again. |
| 850 | (image-flush image) | 861 | (image-flush image) |