aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2009-09-26 19:20:48 +0000
committerGlenn Morris2009-09-26 19:20:48 +0000
commita92cdd49b11b3c97602b49637f79d9936fa49cd4 (patch)
tree4b2c379e8fe6ba3d0d933a3113ebd93d51760e42
parent4ab5d55036e5b84a8316fea886325606107c1326 (diff)
downloademacs-a92cdd49b11b3c97602b49637f79d9936fa49cd4.tar.gz
emacs-a92cdd49b11b3c97602b49637f79d9936fa49cd4.zip
(rmail-mime-show-images, rmail-mime-bulk-handler):
Add option to only show images below a certain size. (rmail-mime-multipart-handler): Remove unnecessary save-match-data and save-excursion calls.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/mail/rmailmm.el27
2 files changed, 22 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 808d420218d..9140b96cf8e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12009-09-26 Glenn Morris <rgm@gnu.org>
2
3 * mail/rmailmm.el (rmail-mime-show-images, rmail-mime-bulk-handler):
4 Add option to only show images below a certain size.
5 (rmail-mime-multipart-handler): Remove unnecessary save-match-data and
6 save-excursion calls.
7
12009-09-26 Eli Zaretskii <eliz@gnu.org> 82009-09-26 Eli Zaretskii <eliz@gnu.org>
2 9
3 * makefile.w32-in (WINS_ALMOST): Add cedet (with its 10 * makefile.w32-in (WINS_ALMOST): Add cedet (with its
diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el
index 077a8bfe1ff..29aa869523e 100644
--- a/lisp/mail/rmailmm.el
+++ b/lisp/mail/rmailmm.el
@@ -31,6 +31,7 @@
31;; Todo: 31;; Todo:
32 32
33;; Handle multipart/alternative. 33;; Handle multipart/alternative.
34;; Offer the option to call external/internal viewers (doc-view, xpdf, etc).
34 35
35;;; Code: 36;;; Code:
36 37
@@ -48,8 +49,6 @@
48 '(("multipart/.*" rmail-mime-multipart-handler) 49 '(("multipart/.*" rmail-mime-multipart-handler)
49 ("text/.*" rmail-mime-text-handler) 50 ("text/.*" rmail-mime-text-handler)
50 ("text/\\(x-\\)?patch" rmail-mime-bulk-handler) 51 ("text/\\(x-\\)?patch" rmail-mime-bulk-handler)
51 ;; FIXME this handler not defined anywhere?
52;;; ("application/pgp-signature" rmail-mime-application/pgp-signature-handler)
53 ("\\(image\\|audio\\|video\\|application\\)/.*" rmail-mime-bulk-handler)) 52 ("\\(image\\|audio\\|video\\|application\\)/.*" rmail-mime-bulk-handler))
54 "Functions to handle various content types. 53 "Functions to handle various content types.
55This is an alist with elements of the form (REGEXP FUNCTION ...). 54This is an alist with elements of the form (REGEXP FUNCTION ...).
@@ -78,10 +77,13 @@ The first directory that exists is used."
78(defcustom rmail-mime-show-images 'button 77(defcustom rmail-mime-show-images 'button
79 "What to do with image attachments that Emacs is capable of displaying. 78 "What to do with image attachments that Emacs is capable of displaying.
80If nil, do nothing special. If `button', add an extra button 79If nil, do nothing special. If `button', add an extra button
81that when pushed displays the image in the buffer. Anything else 80that when pushed displays the image in the buffer. If a number,
82means to automatically display the image in the buffer." 81automatically show images if they are smaller than that size (in
82bytes), otherwise add a display button. Anything else means to
83automatically display the image in the buffer."
83 :type '(choice (const :tag "Add button to view image" button) 84 :type '(choice (const :tag "Add button to view image" button)
84 (const :tag "No special treatment" nil) 85 (const :tag "No special treatment" nil)
86 (number :tag "Show if smaller than certain size")
85 (other :tag "Always show" show)) 87 (other :tag "Always show" show))
86 :version "23.2" 88 :version "23.2"
87 :group 'rmail-mime) 89 :group 'rmail-mime)
@@ -179,6 +181,7 @@ depends upon the value of `rmail-mime-show-images'."
179 (data (buffer-string)) 181 (data (buffer-string))
180 (udata (string-as-unibyte data)) 182 (udata (string-as-unibyte data))
181 (size (length udata)) 183 (size (length udata))
184 (osize size)
182 (units '(B kB MB GB)) 185 (units '(B kB MB GB))
183 type) 186 type)
184 (while (and (> size 1024.0) ; cribbed from gnus-agent-expire-done-message 187 (while (and (> size 1024.0) ; cribbed from gnus-agent-expire-done-message
@@ -201,7 +204,9 @@ depends upon the value of `rmail-mime-show-images'."
201 (memq type image-types) 204 (memq type image-types)
202 (image-type-available-p type)) 205 (image-type-available-p type))
203 (insert " ") 206 (insert " ")
204 (cond ((eq rmail-mime-show-images 'button) 207 (cond ((or (eq rmail-mime-show-images 'button)
208 (and (numberp rmail-mime-show-images)
209 (>= osize rmail-mime-show-images)))
205 (insert-button "Display" 210 (insert-button "Display"
206 :type 'rmail-mime-image 211 :type 'rmail-mime-image
207 'help-echo "mouse-2, RET: Show image" 212 'help-echo "mouse-2, RET: Show image"
@@ -277,13 +282,11 @@ format."
277 content-transfer-encoding))) 282 content-transfer-encoding)))
278 (delete-region end next) 283 (delete-region end next)
279 ;; Handle the part. 284 ;; Handle the part.
280 (save-match-data 285 (save-restriction
281 (save-excursion 286 (narrow-to-region beg end)
282 (save-restriction 287 (rmail-mime-show))
283 (narrow-to-region beg end) 288 (goto-char (setq beg next)))))
284 (rmail-mime-show)))) 289
285 (setq beg next)
286 (goto-char beg))))
287 290
288(defun test-rmail-mime-multipart-handler () 291(defun test-rmail-mime-multipart-handler ()
289 "Test of a mail used as an example in RFC 2046." 292 "Test of a mail used as an example in RFC 2046."