[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 78d3f54 1/2: Make message-toggle-image-thumbnails w
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 78d3f54 1/2: Make message-toggle-image-thumbnails work better |
Date: |
Sun, 29 May 2016 15:59:45 +0000 (UTC) |
branch: master
commit 78d3f5494b3b35b96289f8dd7a6bcb0c67228584
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Make message-toggle-image-thumbnails work better
* lisp/gnus/message.el (message-toggle-image-thumbnails): Use
`insert-image' instead of `put-image' to make it possible to
edit the resulting text in a sensible manner.
---
lisp/gnus/message.el | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 1ca7c5c..a998687 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -8386,30 +8386,32 @@ Used in `message-simplify-recipients'."
(defun message-toggle-image-thumbnails ()
"For any included image files, insert a thumbnail of that image."
(interactive)
- (let ((overlays (overlays-in (point-min) (point-max)))
- (displayed nil))
- (while overlays
- (let ((overlay (car overlays)))
- (when (overlay-get overlay 'put-image)
- (delete-overlay overlay)
- (setq displayed t)))
- (setq overlays (cdr overlays)))
+ (let ((displayed nil))
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (when-let ((props (get-text-property (point) 'display)))
+ (when (and (consp props)
+ (eq (car props) 'image))
+ (put-text-property (point) (1+ (point)) 'display nil)
+ (setq displayed t)))))
(unless displayed
(save-excursion
(goto-char (point-min))
- (while (re-search-forward "<img.*src=\"\\([^\"]+\\)" nil t)
- (let ((file (match-string 1))
+ (while (re-search-forward "<img.*src=\"\\([^\"]+\\).*>" nil t)
+ (let ((string (match-string 0))
+ (file (match-string 1))
(edges (window-inside-pixel-edges
(get-buffer-window (current-buffer)))))
- (put-image
+ (delete-region (match-beginning 0) (match-end 0))
+ (insert-image
(create-image
file 'imagemagick nil
:max-width (truncate
(* 0.7 (- (nth 2 edges) (nth 0 edges))))
:max-height (truncate
(* 0.5 (- (nth 3 edges) (nth 1 edges)))))
- (match-beginning 0)
- " ")))))))
+ string)))))))
(provide 'message)