summaryrefslogtreecommitdiff
path: root/lisp/mail/mailalias.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-06-19 19:52:02 +0000
committerRichard M. Stallman <rms@gnu.org>1994-06-19 19:52:02 +0000
commitd780bef5dbc5ff94fb64203407054847cf229919 (patch)
tree64fa6cffa0cec42115b01e453935f3fa4a695fbb /lisp/mail/mailalias.el
parent5182d211928f4becc980b2cc97169bc4239ed30c (diff)
downloademacs-d780bef5dbc5ff94fb64203407054847cf229919.tar.gz
(define-mail-alias): Copy parsing code from mailabbrev.el.
New arg from-mailrc-file. (build-mail-aliases): Pass t as new arg.
Diffstat (limited to 'lisp/mail/mailalias.el')
-rw-r--r--lisp/mail/mailalias.el42
1 files changed, 24 insertions, 18 deletions
diff --git a/lisp/mail/mailalias.el b/lisp/mail/mailalias.el
index 3353731431c..25d52cfae23 100644
--- a/lisp/mail/mailalias.el
+++ b/lisp/mail/mailalias.el
@@ -151,7 +151,8 @@ removed from alias expansions."
(end-of-line)
(define-mail-alias
name
- (buffer-substring start (point)))))
+ (buffer-substring start (point))
+ t)))
mail-aliases)
(if buffer (kill-buffer buffer))
(set-buffer obuf))))
@@ -159,7 +160,7 @@ removed from alias expansions."
;; Always autoloadable in case the user wants to define aliases
;; interactively or in .emacs.
;;;###autoload
-(defun define-mail-alias (name definition)
+(defun define-mail-alias (name definition &optional from-mailrc-file)
"Define NAME as a mail alias that translates to DEFINITION.
This means that sending a message to NAME will actually send to DEFINITION.
DEFINITION can be one or more mail addresses separated by spaces.
@@ -176,22 +177,27 @@ An address can contain spaces if it is quoted with double-quotes."
(setq definition (substring definition (match-end 0))))
(if (string-match "[ \t\n,]+\\'" definition)
(setq definition (substring definition 0 (match-beginning 0))))
- (let ((first (aref definition 0))
- (last (aref definition (1- (length definition))))
- tem)
- (if (and (= first last) (memq first '(?\' ?\")))
- ;; Strip quotation marks.
- (setq definition (substring definition 1 (1- (length definition))))
- ;; ~/.mailrc contains addresses separated by spaces.
- ;; Mailers should expect addresses separated by commas.
- (while (setq tem (string-match "[^ \t,][ \t,]+" definition tem))
- (if (= (match-end 0) (length definition))
- (setq definition (substring definition 0 (1+ tem)))
- (setq definition (concat (substring definition
- 0 (1+ tem))
- ", "
- (substring definition (match-end 0))))
- (setq tem (+ 3 tem)))))
+ (let ((result '())
+ (start 0)
+ (L (length definition))
+ end tem)
+ (while start
+ ;; If we're reading from the mailrc file, then addresses are delimited
+ ;; by spaces, and addresses with embedded spaces must be surrounded by
+ ;; double-quotes. Otherwise, addresses are separated by commas.
+ (if from-mailrc-file
+ (if (eq ?\" (aref definition start))
+ (setq start (1+ start)
+ 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))))
+ (setq definition (mapconcat (function identity)
+ (nreverse result)
+ ", "))
(setq tem (assoc name mail-aliases))
(if tem
(rplacd tem definition)