[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100252: Implement rmail-search-mi
From: |
Kenichi Handa |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100252: Implement rmail-search-mime-message-function. |
Date: |
Thu, 02 Dec 2010 09:44:55 +0900 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 100252 [merge]
committer: Kenichi Handa <address@hidden>
branch nick: emacs-23
timestamp: Thu 2010-12-02 09:44:55 +0900
message:
Implement rmail-search-mime-message-function.
modified:
lisp/ChangeLog
lisp/mail/rmailmm.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2010-12-01 22:34:09 +0000
+++ b/lisp/ChangeLog 2010-12-02 00:44:25 +0000
@@ -1,3 +1,12 @@
+2010-12-01 Kenichi Handa <address@hidden>
+
+ * mail/rmailmm.el (rmail-mime-parse): Call rmail-mime-process
+ within condition-case.
+ (rmail-show-mime): Don't use condition-case.
+ (rmail-search-mime-message): New function.
+ (rmail-search-mime-message-function): Set to
+ rmail-search-mime-message.
+
2010-12-01 Leo <address@hidden>
* ido.el (ido-common-initilization): New function. (bug#3274)
@@ -26,6 +35,7 @@
(smie-next-sexp): Make it accept a "start token" as argument.
(smie-indent-keyword): Be careful not to misidentify tokens that span
more than one line, as empty lines. Add argument `token'.
+>>>>>>> MERGE-SOURCE
2010-11-26 Kenichi Handa <address@hidden>
=== modified file 'lisp/mail/rmailmm.el'
--- a/lisp/mail/rmailmm.el 2010-11-26 12:58:41 +0000
+++ b/lisp/mail/rmailmm.el 2010-11-29 12:22:39 +0000
@@ -690,7 +690,9 @@
The value is a MIME-entiy object (see `rmail-mime-enty-new')."
(save-excursion
(goto-char (point-min))
- (rmail-mime-process nil t)))
+ (condition-case nil
+ (rmail-mime-process nil t)
+ (error nil))))
(defun rmail-mime-insert (entity &optional content-type disposition)
"Insert a MIME-entity ENTITY in the current buffer.
@@ -743,30 +745,31 @@
message type disposition encoding))
(defun rmail-show-mime ()
- (let ((mbox-buf rmail-buffer))
- (condition-case nil
- (let ((entity (rmail-mime-parse)))
- (with-current-buffer rmail-view-buffer
- (let ((inhibit-read-only t)
- (rmail-buffer mbox-buf))
- (erase-buffer)
- (rmail-mime-insert entity))))
- (error
- ;; Decoding failed. Insert the original message body as is.
- (let ((region (with-current-buffer mbox-buf
- (goto-char (point-min))
- (re-search-forward "^$" nil t)
- (forward-line 1)
- (cons (point) (point-max)))))
- (with-current-buffer rmail-view-buffer
- (let ((inhibit-read-only t))
- (erase-buffer)
- (insert-buffer-substring mbox-buf (car region) (cdr region))))
- (message "MIME decoding failed"))))))
+ "Function to set in `rmail-show-mime-function' (which see)."
+ (let ((mbox-buf rmail-buffer)
+ (entity (rmail-mime-parse)))
+ (if entity
+ (with-current-buffer rmail-view-buffer
+ (let ((inhibit-read-only t)
+ (rmail-buffer mbox-buf))
+ (erase-buffer)
+ (rmail-mime-insert entity)))
+ ;; Decoding failed. Insert the original message body as is.
+ (let ((region (with-current-buffer mbox-buf
+ (goto-char (point-min))
+ (re-search-forward "^$" nil t)
+ (forward-line 1)
+ (cons (point) (point-max)))))
+ (with-current-buffer rmail-view-buffer
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (insert-buffer-substring mbox-buf (car region) (cdr region))))
+ (message "MIME decoding failed")))))
(setq rmail-show-mime-function 'rmail-show-mime)
(defun rmail-insert-mime-forwarded-message (forward-buffer)
+ "Function to set in `rmail-insert-mime-forwarded-message-function' (which
see)."
(let ((mbox-buf (with-current-buffer forward-buffer rmail-view-buffer)))
(save-restriction
(narrow-to-region (point) (point))
@@ -776,6 +779,7 @@
'rmail-insert-mime-forwarded-message)
(defun rmail-insert-mime-resent-message (forward-buffer)
+ "Function to set in `rmail-insert-mime-resent-message-function' (which see)."
(insert-buffer-substring
(with-current-buffer forward-buffer rmail-view-buffer))
(goto-char (point-min))
@@ -786,6 +790,41 @@
(setq rmail-insert-mime-resent-message-function
'rmail-insert-mime-resent-message)
+(defun rmail-search-mime-message (msg regexp)
+ "Function to set in `rmail-search-mime-message-function' (which see)."
+ (save-restriction
+ (narrow-to-region (rmail-msgbeg msg) (rmail-msgend msg))
+ (let ((mbox-buf (current-buffer))
+ (header-end (save-excursion
+ (re-search-forward "^$" nil 'move) (point)))
+ (body-end (point-max))
+ (entity (rmail-mime-parse)))
+ (or
+ ;; At first, just search the headers.
+ (with-temp-buffer
+ (insert-buffer-substring mbox-buf nil header-end)
+ (rfc2047-decode-region (point-min) (point))
+ (goto-char (point-min))
+ (re-search-forward regexp nil t))
+ ;; Next, search the body.
+ (if (and entity
+ (let* ((content-type (rmail-mime-entity-type entity))
+ (charset (cdr (assq 'charset (cdr content-type)))))
+ (or (not (string-match "text/.*" (car content-type)))
+ (and charset
+ (not (string= (downcase charset) "us-ascii"))))))
+ ;; Search the decoded MIME message.
+ (with-temp-buffer
+ (let ((rmail-buffer mbox-buf))
+ (rmail-mime-insert entity))
+ (goto-char (point-min))
+ (re-search-forward regexp nil t))
+ ;; Search the body without decoding.
+ (goto-char header-end)
+ (re-search-forward regexp nil t))))))
+
+(setq rmail-search-mime-message-function 'rmail-search-mime-message)
+
(provide 'rmailmm)
;; Local Variables:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/emacs-23 r100252: Implement rmail-search-mime-message-function.,
Kenichi Handa <=