aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2010-11-29 21:22:39 +0900
committerKenichi Handa2010-11-29 21:22:39 +0900
commit7e116860bbae843e00c29b08919e10fc37f7aaa2 (patch)
tree3768985c92fa6f4434b7d37b995b6ab0ff37a270
parentafde451abef73d7b4b21af427c48621dedc60f4b (diff)
downloademacs-7e116860bbae843e00c29b08919e10fc37f7aaa2.tar.gz
emacs-7e116860bbae843e00c29b08919e10fc37f7aaa2.zip
Implement rmail-search-mime-message-function.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/mail/rmailmm.el81
2 files changed, 69 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1b35c13377c..c09e7a7a441 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12010-11-29 Kenichi Handa <handa@m17n.org>
2
3 * mail/rmailmm.el (rmail-mime-parse): Call rmail-mime-process
4 within condition-case.
5 (rmail-show-mime): Don't use condition-case.
6 (rmail-search-mime-message): New function.
7 (rmail-search-mime-message-function): Set to
8 rmail-search-mime-message.
9
12010-11-26 Kenichi Handa <handa@m17n.org> 102010-11-26 Kenichi Handa <handa@m17n.org>
2 11
3 * mail/rmailmm.el (rmail-mime-insert-multipart): For unsupported 12 * mail/rmailmm.el (rmail-mime-insert-multipart): For unsupported
diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el
index 2c1269ee3f1..1cd765cbf9f 100644
--- a/lisp/mail/rmailmm.el
+++ b/lisp/mail/rmailmm.el
@@ -690,7 +690,9 @@ modified."
690The value is a MIME-entiy object (see `rmail-mime-enty-new')." 690The value is a MIME-entiy object (see `rmail-mime-enty-new')."
691 (save-excursion 691 (save-excursion
692 (goto-char (point-min)) 692 (goto-char (point-min))
693 (rmail-mime-process nil t))) 693 (condition-case nil
694 (rmail-mime-process nil t)
695 (error nil))))
694 696
695(defun rmail-mime-insert (entity &optional content-type disposition) 697(defun rmail-mime-insert (entity &optional content-type disposition)
696 "Insert a MIME-entity ENTITY in the current buffer. 698 "Insert a MIME-entity ENTITY in the current buffer.
@@ -743,30 +745,31 @@ attachments as specfied by `rmail-mime-attachment-dirs-alist'."
743 message type disposition encoding)) 745 message type disposition encoding))
744 746
745(defun rmail-show-mime () 747(defun rmail-show-mime ()
746 (let ((mbox-buf rmail-buffer)) 748 "Function to set in `rmail-show-mime-function' (which see)."
747 (condition-case nil 749 (let ((mbox-buf rmail-buffer)
748 (let ((entity (rmail-mime-parse))) 750 (entity (rmail-mime-parse)))
749 (with-current-buffer rmail-view-buffer 751 (if entity
750 (let ((inhibit-read-only t) 752 (with-current-buffer rmail-view-buffer
751 (rmail-buffer mbox-buf)) 753 (let ((inhibit-read-only t)
752 (erase-buffer) 754 (rmail-buffer mbox-buf))
753 (rmail-mime-insert entity)))) 755 (erase-buffer)
754 (error 756 (rmail-mime-insert entity)))
755 ;; Decoding failed. Insert the original message body as is. 757 ;; Decoding failed. Insert the original message body as is.
756 (let ((region (with-current-buffer mbox-buf 758 (let ((region (with-current-buffer mbox-buf
757 (goto-char (point-min)) 759 (goto-char (point-min))
758 (re-search-forward "^$" nil t) 760 (re-search-forward "^$" nil t)
759 (forward-line 1) 761 (forward-line 1)
760 (cons (point) (point-max))))) 762 (cons (point) (point-max)))))
761 (with-current-buffer rmail-view-buffer 763 (with-current-buffer rmail-view-buffer
762 (let ((inhibit-read-only t)) 764 (let ((inhibit-read-only t))
763 (erase-buffer) 765 (erase-buffer)
764 (insert-buffer-substring mbox-buf (car region) (cdr region)))) 766 (insert-buffer-substring mbox-buf (car region) (cdr region))))
765 (message "MIME decoding failed")))))) 767 (message "MIME decoding failed")))))
766 768
767(setq rmail-show-mime-function 'rmail-show-mime) 769(setq rmail-show-mime-function 'rmail-show-mime)
768 770
769(defun rmail-insert-mime-forwarded-message (forward-buffer) 771(defun rmail-insert-mime-forwarded-message (forward-buffer)
772 "Function to set in `rmail-insert-mime-forwarded-message-function' (which see)."
770 (let ((mbox-buf (with-current-buffer forward-buffer rmail-view-buffer))) 773 (let ((mbox-buf (with-current-buffer forward-buffer rmail-view-buffer)))
771 (save-restriction 774 (save-restriction
772 (narrow-to-region (point) (point)) 775 (narrow-to-region (point) (point))
@@ -776,6 +779,7 @@ attachments as specfied by `rmail-mime-attachment-dirs-alist'."
776 'rmail-insert-mime-forwarded-message) 779 'rmail-insert-mime-forwarded-message)
777 780
778(defun rmail-insert-mime-resent-message (forward-buffer) 781(defun rmail-insert-mime-resent-message (forward-buffer)
782 "Function to set in `rmail-insert-mime-resent-message-function' (which see)."
779 (insert-buffer-substring 783 (insert-buffer-substring
780 (with-current-buffer forward-buffer rmail-view-buffer)) 784 (with-current-buffer forward-buffer rmail-view-buffer))
781 (goto-char (point-min)) 785 (goto-char (point-min))
@@ -786,6 +790,41 @@ attachments as specfied by `rmail-mime-attachment-dirs-alist'."
786(setq rmail-insert-mime-resent-message-function 790(setq rmail-insert-mime-resent-message-function
787 'rmail-insert-mime-resent-message) 791 'rmail-insert-mime-resent-message)
788 792
793(defun rmail-search-mime-message (msg regexp)
794 "Function to set in `rmail-search-mime-message-function' (which see)."
795 (save-restriction
796 (narrow-to-region (rmail-msgbeg msg) (rmail-msgend msg))
797 (let ((mbox-buf (current-buffer))
798 (header-end (save-excursion
799 (re-search-forward "^$" nil 'move) (point)))
800 (body-end (point-max))
801 (entity (rmail-mime-parse)))
802 (or
803 ;; At first, just search the headers.
804 (with-temp-buffer
805 (insert-buffer-substring mbox-buf nil header-end)
806 (rfc2047-decode-region (point-min) (point))
807 (goto-char (point-min))
808 (re-search-forward regexp nil t))
809 ;; Next, search the body.
810 (if (and entity
811 (let* ((content-type (rmail-mime-entity-type entity))
812 (charset (cdr (assq 'charset (cdr content-type)))))
813 (or (not (string-match "text/.*" (car content-type)))
814 (and charset
815 (not (string= (downcase charset) "us-ascii"))))))
816 ;; Search the decoded MIME message.
817 (with-temp-buffer
818 (let ((rmail-buffer mbox-buf))
819 (rmail-mime-insert entity))
820 (goto-char (point-min))
821 (re-search-forward regexp nil t))
822 ;; Search the body without decoding.
823 (goto-char header-end)
824 (re-search-forward regexp nil t))))))
825
826(setq rmail-search-mime-message-function 'rmail-search-mime-message)
827
789(provide 'rmailmm) 828(provide 'rmailmm)
790 829
791;; Local Variables: 830;; Local Variables: