mirror of
https://github.com/vale981/ement.el
synced 2025-03-05 17:21:41 -05:00
Change/Fix: Support images on Emacs 27+
This commit is contained in:
parent
e028736236
commit
baed04d5d5
1 changed files with 19 additions and 8 deletions
|
@ -1710,11 +1710,13 @@ For use as a `help-echo' function on `ement-user' headings."
|
||||||
"Download and show images in messages, avatars, etc."
|
"Download and show images in messages, avatars, etc."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:set (lambda (option value)
|
:set (lambda (option value)
|
||||||
(if (fboundp 'imagemagick-types)
|
(if (or (fboundp 'imagemagick-types)
|
||||||
|
(when (fboundp 'image-transforms-p)
|
||||||
|
(image-transforms-p)))
|
||||||
(set-default option value)
|
(set-default option value)
|
||||||
(set-default option nil)
|
(set-default option nil)
|
||||||
(when value
|
(when value
|
||||||
(display-warning 'ement "This Emacs was not built with ImageMagick support, so images can't be displayed in Ement")))))
|
(display-warning 'ement "This Emacs was not built with ImageMagick support, nor does it support Cairo/XRender scaling, so images can't be displayed in Ement")))))
|
||||||
|
|
||||||
(defun ement-room-image-scale-mouse (event)
|
(defun ement-room-image-scale-mouse (event)
|
||||||
"Scale image at mouse EVENT to fit in window."
|
"Scale image at mouse EVENT to fit in window."
|
||||||
|
@ -1726,8 +1728,11 @@ For use as a `help-echo' function on `ement-user' headings."
|
||||||
(pcase-let* ((image (get-text-property pos 'display))
|
(pcase-let* ((image (get-text-property pos 'display))
|
||||||
(width (window-body-width nil t))
|
(width (window-body-width nil t))
|
||||||
(height (window-body-height nil t)))
|
(height (window-body-height nil t)))
|
||||||
(setf (image-property image :type) 'imagemagick
|
(when (fboundp 'imagemagick-types)
|
||||||
(image-property image :max-width) width
|
;; Only do this when ImageMagick is supported.
|
||||||
|
;; FIXME: When requiring Emacs 27+, remove this (I guess?).
|
||||||
|
(setf (image-property image :type) 'imagemagick))
|
||||||
|
(setf (image-property image :max-width) width
|
||||||
(image-property image :max-height) height)))))
|
(image-property image :max-height) height)))))
|
||||||
|
|
||||||
(defun ement-room-image-show (event)
|
(defun ement-room-image-show (event)
|
||||||
|
@ -1742,8 +1747,11 @@ For use as a `help-echo' function on `ement-user' headings."
|
||||||
((cl-struct ement-event id) ement-event)
|
((cl-struct ement-event id) ement-event)
|
||||||
(buffer-name (format "*Ement image: %s*" id))
|
(buffer-name (format "*Ement image: %s*" id))
|
||||||
(new-buffer (get-buffer-create buffer-name)))
|
(new-buffer (get-buffer-create buffer-name)))
|
||||||
(setf (image-property image :type) 'imagemagick
|
(when (fboundp 'imagemagick-types)
|
||||||
(image-property image :scale) 1.0
|
;; Only do this when ImageMagick is supported.
|
||||||
|
;; FIXME: When requiring Emacs 27+, remove this (I guess?).
|
||||||
|
(setf (image-property image :type) 'imagemagick))
|
||||||
|
(setf (image-property image :scale) 1.0
|
||||||
(image-property image :max-width) nil
|
(image-property image :max-width) nil
|
||||||
(image-property image :max-height) nil)
|
(image-property image :max-height) nil)
|
||||||
(with-current-buffer new-buffer
|
(with-current-buffer new-buffer
|
||||||
|
@ -1789,8 +1797,11 @@ show it in the buffer."
|
||||||
;; Buffer not displayed: use frame size.
|
;; Buffer not displayed: use frame size.
|
||||||
(setf max-height (frame-pixel-height)
|
(setf max-height (frame-pixel-height)
|
||||||
max-width (frame-pixel-width))))
|
max-width (frame-pixel-width))))
|
||||||
(setf (image-property image :type) 'imagemagick
|
(when (fboundp 'imagemagick-types)
|
||||||
(image-property image :max-width) max-width
|
;; Only do this when ImageMagick is supported.
|
||||||
|
;; FIXME: When requiring Emacs 27+, remove this (I guess?).
|
||||||
|
(setf (image-property image :type) 'imagemagick))
|
||||||
|
(setf (image-property image :max-width) max-width
|
||||||
(image-property image :max-height) max-height)
|
(image-property image :max-height) max-height)
|
||||||
(concat "\n"
|
(concat "\n"
|
||||||
(propertize " " 'display image
|
(propertize " " 'display image
|
||||||
|
|
Loading…
Add table
Reference in a new issue