changeset 59349:c3a4bd30088a

(sendmail-pre-abbrev-expand-hook): Don't expand if the character is @, period, dash, etc. (define-mail-abbrev): Quote names that contain problem characters.
author Richard M. Stallman <rms@gnu.org>
date Tue, 04 Jan 2005 14:59:27 +0000
parents e83f9b957fa5
children 4128241e0551
files lisp/mail/mailabbrev.el
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/mailabbrev.el	Tue Jan 04 14:58:16 2005 +0000
+++ b/lisp/mail/mailabbrev.el	Tue Jan 04 14:59:27 2005 +0000
@@ -305,10 +305,19 @@
 		    end (string-match "\"[ \t,]*" definition start))
 	    (setq end (string-match "[ \t,]+" definition start)))
 	(setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
-      (setq result (cons (substring definition start end) result))
-      (setq start (and end
-		       (/= (match-end 0) L)
-		       (match-end 0))))
+      (let ((tem (substring definition start end)))
+	;; Advance the loop past this address.
+	(setq start (and end
+			 (/= (match-end 0) L)
+			 (match-end 0)))
+	;; If the full name contains a problem character, quote it.
+	(when (string-match "\\(.+?\\)[ \t]*\\(<.*>\\)" tem)
+	  (if (string-match "[^- !#$%&'*+/0-9=?A-Za-z^_`{|}~]"
+			    (match-string 1 tem))
+	      (setq tem (replace-regexp-in-string
+			 "\\(.+?\\)[ \t]*\\(<.*>\\)" "\"\\1\" \\2"
+			 tem))))
+	(push tem result)))
     (setq definition (mapconcat (function identity)
 				(nreverse result)
 				mail-alias-separator-string)))
@@ -485,7 +494,9 @@
 	     ;; the usual syntax table.
 
 	     (or (and (integerp last-command-char)
-		      (eq (char-syntax last-command-char) ?_))
+		      (or (eq (char-syntax last-command-char) ?_)
+			  ;; Don't expand on @.
+			  (memq last-command-char '(?@ ?. ?% ?! ?_ ?-))))
 		 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.
 		   ;; Use this table so that abbrevs can have hyphens in them.
 		   (set-syntax-table mail-abbrev-syntax-table)
@@ -610,7 +621,8 @@
   (interactive "P")
   (if (looking-at "[ \t]*\n") (expand-abbrev))
   (setq this-command 'end-of-buffer)
-  (end-of-buffer arg))
+  (with-no-warnings
+   (end-of-buffer arg)))
 
 (eval-after-load "sendmail"
   '(progn