emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 38167fb: * lisp/mail/rmailsum.el: Fix search for en


From: Glenn Morris
Subject: [Emacs-diffs] master 38167fb: * lisp/mail/rmailsum.el: Fix search for encoded subjects. (Bug#19088)
Date: Tue, 28 Apr 2015 23:27:40 +0000

branch: master
commit 38167fb133f7c68b639f226886773900320b0b42
Author: Glenn Morris <address@hidden>
Commit: Glenn Morris <address@hidden>

    * lisp/mail/rmailsum.el: Fix search for encoded subjects.  (Bug#19088)
    
    (rmail--decode-and-apply): New function.
    (rmail-message-regexp-p-1, rmail-message-subject-p): Use it.
---
 lisp/mail/rmailsum.el |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index 7144e43..280539e 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -340,13 +340,30 @@ Emacs will list the message in the summary."
   "Return t, if for message number MSG, regexp REGEXP matches in the header."
   (rmail-apply-in-message msg 'rmail-message-regexp-p-1 msg regexp))
 
+(defun rmail--decode-and-apply (function &rest args)
+  "Make an RFC2047-decoded copy of current buffer, apply FUNCTION with ARGS."
+  (let ((buff (current-buffer)))
+    (with-temp-buffer
+      (insert-buffer-substring buff)
+      (goto-char (point-min))
+      ;; FIXME?  In rmail-show-message-1, decoding depends on
+      ;; rmail-enable-mime being non-nil (?).
+      (rfc2047-decode-region (point-min)
+                            (save-excursion
+                              (progn
+                                (search-forward "\n\n" nil 'move)
+                                (point))))
+      (apply function args))))
+
 (defun rmail-message-regexp-p-1 (msg regexp)
   ;; Search functions can expect to start from the beginning.
   (narrow-to-region (point) (save-excursion (search-forward "\n\n") (point)))
   (if (and rmail-enable-mime
           rmail-search-mime-header-function)
       (funcall rmail-search-mime-header-function msg regexp (point))
-    (re-search-forward regexp nil t)))
+    ;; We need to search the full headers, but probably want to decode
+    ;; them so they match the ones people see displayed.  (Bug#19088)
+    (rmail--decode-and-apply 're-search-forward regexp nil t)))
 
 ;;;###autoload
 (defun rmail-summary-by-topic (subject &optional whole-message)
@@ -370,7 +387,9 @@ SUBJECT is a string of regexps separated by commas."
 
 (defun rmail-message-subject-p (msg subject &optional whole-message)
   (if whole-message
-      (rmail-apply-in-message msg 're-search-forward subject nil t)
+      ;; SUBJECT and rmail-simplified-subject are 2047 decoded.
+      (rmail-apply-in-message msg 'rmail--decode-and-apply
+                             're-search-forward subject nil t)
     (string-match subject (rmail-simplified-subject msg))))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]