]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/mail-utils.el
Doc fix.
[gnu-emacs] / lisp / mail / mail-utils.el
index e60e8358de94036686861df60ed3d3e98a429734..7c8593742e7fe9139c9b0a236966c0439afa224e 100644 (file)
@@ -1,16 +1,17 @@
 ;;; mail-utils.el --- utility functions used both by rmail and rnews
 
-;; Copyright (C) 1985, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: mail, news
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -108,11 +107,15 @@ we expect to find and remove the wrapper characters =?ISO-8859-1?Q?....?=."
       (apply 'concat (nreverse (cons (substring string i) strings))))))
 
 ;;;###autoload
-(defun mail-unquote-printable-region (beg end &optional wrapper noerror)
+(defun mail-unquote-printable-region (beg end &optional wrapper noerror
+                                         unibyte)
   "Undo the \"quoted printable\" encoding in buffer from BEG to END.
 If the optional argument WRAPPER is non-nil,
 we expect to find and remove the wrapper characters =?ISO-8859-1?Q?....?=.
-If NOERROR is non-nil, return t if successful."
+If NOERROR is non-nil, return t if successful.
+If UNIBYTE is non-nil, insert converted characters as unibyte.
+That is useful if you are going to character code decoding afterward,
+as Rmail does."
   (interactive "r\nP")
   (let (failed)
     (save-match-data
@@ -131,13 +134,16 @@ If NOERROR is non-nil, return t if successful."
                  ((= (char-after (match-beginning 1)) ?=)
                   (replace-match "="))
                  ((match-beginning 2)
-                  (replace-match
-                   (make-string 1
-                                (+ (* 16 (mail-unquote-printable-hexdigit
-                                          (char-after (match-beginning 2))))
-                                   (mail-unquote-printable-hexdigit
-                                    (char-after (1+ (match-beginning 2))))))
-                   t t))
+                  (let ((char (+ (* 16 (mail-unquote-printable-hexdigit
+                                        (char-after (match-beginning 2))))
+                                 (mail-unquote-printable-hexdigit
+                                  (char-after (1+ (match-beginning 2)))))))
+                    (if unibyte
+                        (progn
+                          (replace-match "")
+                          ;; insert-char will insert this as unibyte,
+                          (insert-char char 1))
+                      (replace-match (make-string 1 char) t t))))
                  (noerror
                   (setq failed t))
                  (t
@@ -227,9 +233,15 @@ the comma-separated list.  The pruned list is returned."
                       "")
                     (if (and user-mail-address
                              (not (equal user-mail-address user-login-name)))
-                        (concat (regexp-quote user-mail-address) "\\|")
+                       ;; Anchor the login name and email address so
+                       ;; that we don't match substrings: if the
+                       ;; login name is "foo", we shouldn't match
+                       ;; "barfoo@baz.com".
+                        (concat "\\`"
+                               (regexp-quote user-mail-address)
+                               "\\'\\|")
                       "")
-                    (concat (regexp-quote user-login-name) "\\>"))))
+                    (concat "\\`" (regexp-quote user-login-name) "@"))))
   ;; Split up DESTINATIONS and match each element separately.
   (let ((start-pos 0) (cur-pos 0)
        (case-fold-search t))
@@ -357,5 +369,5 @@ If 4th arg LIST is non-nil, return a list of all such fields."
 
 (provide 'mail-utils)
 
-;;; arch-tag: b24aec2f-fd65-4ceb-9e39-3cc2827036fd
+;; arch-tag: b24aec2f-fd65-4ceb-9e39-3cc2827036fd
 ;;; mail-utils.el ends here