diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-03-21 18:05:18 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-03-21 18:05:18 +0100 |
commit | d74cd0cf1f96e256c479599939efacd11600c0c8 (patch) | |
tree | 97d47945bff9757af2ffa38a40c776b92ab7fc43 /lisp/image | |
parent | 61d34c6a500d487c8952d4ad7751e1deb80f5bfc (diff) | |
download | emacs-d74cd0cf1f96e256c479599939efacd11600c0c8.tar.gz |
Make `n' in image-mode work more reliably with external formats
* lisp/image-mode.el (image-mode): Init the external machinery so
that commands like `n' work for those files.
* lisp/image/image-converter.el (image-converter-initialize):
Factored out into own function.
(image-convert-p): Use it.
(image-convert): Ditto.
Diffstat (limited to 'lisp/image')
-rw-r--r-- | lisp/image/image-converter.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/image/image-converter.el b/lisp/image/image-converter.el index b8c9a620024..a339e95ab4a 100644 --- a/lisp/image/image-converter.el +++ b/lisp/image/image-converter.el @@ -68,15 +68,19 @@ not, conversion will fail." (imagemagick :command "convert" :probe ("-list" "format"))) "List of supported image converters to try.") +(defun image-converter-initialize () + "Determine the external image converter to be used. +This also determines which external formats we can parse." + (unless image-converter + (image-converter--find-converter))) + (defun image-convert-p (source &optional data-p) "Return `image-convert' if SOURCE is an image that can be converted. SOURCE can either be a file name or a string containing image data. In the latter case, DATA-P should be non-nil. If DATA-P is a string, it should be a MIME format string like \"image/gif\"." - ;; Find an installed image converter. - (unless image-converter - (image-converter--find-converter)) + (image-converter-initialize) ;; When image-converter was customized (when (and image-converter (not image-converter-regexp)) (when-let ((formats (image-converter--probe image-converter))) @@ -111,9 +115,7 @@ IMAGE can also be an image object as returned by `create-image'. This function converts the image the preferred format, and the converted image data is returned as a string." - ;; Find an installed image converter. - (unless image-converter - (image-converter--find-converter)) + (image-converter-initialize) (unless image-converter (error "No external image converters available")) (when (and image-format |