]> git.eshelyaron.com Git - emacs.git/commitdiff
(rmail-mime-bulk-handler): Print the size of attachments.
authorGlenn Morris <rgm@gnu.org>
Fri, 25 Sep 2009 06:15:01 +0000 (06:15 +0000)
committerGlenn Morris <rgm@gnu.org>
Fri, 25 Sep 2009 06:15:01 +0000 (06:15 +0000)
lisp/ChangeLog
lisp/mail/rmailmm.el

index 95aa7019901b68742e7c7296bd30398fc0969050..5c248e94cd2335189565c49d3bf7e5dcb31399fa 100644 (file)
@@ -30,7 +30,8 @@
        (rmail-mime-insert-image): New function.
        (rmail-mime-image): Use rmail-mime-insert-image.
        (rmail-mime-bulk-handler): Remove optional `image' argument, instead
-       obey the value of `rmail-mime-show-images' option.
+       obey the value of `rmail-mime-show-images' option.  Print the size of
+       attachments.
 
 2009-09-25  David Engster  <deng@randomsample.de>
 
index f7f7fb7609f7a5339a84a05c048bbdf04db3e315..077a8bfe1ffe8415a600f8673aef50eed7cf2b96 100644 (file)
@@ -177,7 +177,14 @@ depends upon the value of `rmail-mime-show-images'."
                       "noname"))
         (label (format "\nAttached %s file: " (car content-type)))
         (data (buffer-string))
+        (udata (string-as-unibyte data))
+        (size (length udata))
+        (units '(B kB MB GB))
         type)
+    (while (and (> size 1024.0)        ; cribbed from gnus-agent-expire-done-message
+               (cdr units))
+      (setq size (/ size 1024.0)
+           units (cdr units)))
     (delete-region (point-min) (point-max))
     (insert label)
     (insert-button filename
@@ -186,23 +193,22 @@ depends upon the value of `rmail-mime-show-images'."
                   'filename filename
                   'directory (file-name-as-directory directory)
                   'data data)
+    (insert (format " (%.0f%s)" size (car units)))
     (when (and rmail-mime-show-images
               (string-match "image/\\(.*\\)" (setq type (car content-type)))
               (setq type (concat "." (match-string 1 type))
                     type (image-type-from-file-name type))
               (memq type image-types)
               (image-type-available-p type))
-      (setq data (string-as-unibyte data))
       (insert " ")
-      ;; FIXME ought to check or at least display the image size.
       (cond ((eq rmail-mime-show-images 'button)
             (insert-button "Display"
                            :type 'rmail-mime-image
                            'help-echo "mouse-2, RET: Show image"
                            'image-type type
-                           'image-data data))
+                           'image-data udata))
            (t
-            (rmail-mime-insert-image type data))))))
+            (rmail-mime-insert-image type udata))))))
 
 (defun test-rmail-mime-bulk-handler ()
   "Test of a mail used as an example in RFC 2183."