[gnus git] branch master updated: m0-13-40-g37b1b9e =1= * message.el (message-toggle-image-thumbnails): New command.

Lars Magne Ingebrigtsen <[email protected]> Mon, 17 Aug 2015 23:50:41 +0200
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  37b1b9ea0c7f7482525330d35a752bdd3ba43d68 (commit)
      from  f4a053c5739d1bd3374fad6591b6779fda5f0b43 (commit)


- Log -----------------------------------------------------------------
commit 37b1b9ea0c7f7482525330d35a752bdd3ba43d68
Author: Lars Magne Ingebrigtsen <[email protected]>
Date:   Mon Aug 17 23:50:34 2015 +0200

    * message.el (message-toggle-image-thumbnails): New command.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 324f473..ae950f1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2015-08-17  Lars Magne Ingebrigtsen  <[email protected]>
+
+	* message.el (message-toggle-image-thumbnails): New command.
+
 2015-08-06  Paul Eggert  <[email protected]>
 
 	* message.el (message-send-form-letter): Change (message (format ...))
diff --git a/lisp/message.el b/lisp/message.el
index 26655f3..4775af7 100644
--- a/lisp/message.el
+++ b/lisp/message.el
@@ -8591,14 +8591,44 @@ Used in `message-simplify-recipients'."
 ;;; multipart/related and HTML support.
 
 (defun message-make-html-message-with-image-files (files)
+  "Make a message containing the current dired-marked image files."
   (interactive (list (dired-get-marked-files nil current-prefix-arg)))
   (message-mail)
   (message-goto-body)
   (insert "<#part type=text/html>\n\n")
   (dolist (file files)
     (insert (format "<img src=%S>\n\n" file)))
+  (message-toggle-image-thumbnails)
   (message-goto-to))
 
+(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)))
+    (unless displayed
+      (save-excursion
+	(goto-char (point-min))
+	(while (re-search-forward "<img.*src=\"\\([^\"]+\\)" nil t)
+	  (let ((file (match-string 1))
+		(edges (window-inside-pixel-edges
+			(get-buffer-window (current-buffer)))))
+	    (put-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)
+	     " ")))))))
+
 (when (featurep 'xemacs)
   (require 'messagexmas)
   (message-xmas-redefine))

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog  |    4 ++++
 lisp/message.el |   30 ++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project