aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-06-19 19:52:02 +0000
committerRichard M. Stallman1994-06-19 19:52:02 +0000
commit37e379dd0912919c2f3990680593309492bc2e77 (patch)
tree3c42512b4b415d7abc9c3b21bf51f9bb5e98c054
parentd066345bcf9bae839a93902de8d03cbe901a544f (diff)
downloademacs-37e379dd0912919c2f3990680593309492bc2e77.tar.gz
emacs-37e379dd0912919c2f3990680593309492bc2e77.zip
(define-mail-alias): Copy parsing code from mailabbrev.el.
New arg from-mailrc-file. (build-mail-aliases): Pass t as new arg.
-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."
151 (end-of-line) 151 (end-of-line)
152 (define-mail-alias 152 (define-mail-alias
153 name 153 name
154 (buffer-substring start (point))))) 154 (buffer-substring start (point))
155 t)))
155 mail-aliases) 156 mail-aliases)
156 (if buffer (kill-buffer buffer)) 157 (if buffer (kill-buffer buffer))
157 (set-buffer obuf)))) 158 (set-buffer obuf))))
@@ -159,7 +160,7 @@ removed from alias expansions."
159;; Always autoloadable in case the user wants to define aliases 160;; Always autoloadable in case the user wants to define aliases
160;; interactively or in .emacs. 161;; interactively or in .emacs.
161;;;###autoload 162;;;###autoload
162(defun define-mail-alias (name definition) 163(defun define-mail-alias (name definition &optional from-mailrc-file)
163 "Define NAME as a mail alias that translates to DEFINITION. 164 "Define NAME as a mail alias that translates to DEFINITION.
164This means that sending a message to NAME will actually send to DEFINITION. 165This means that sending a message to NAME will actually send to DEFINITION.
165DEFINITION can be one or more mail addresses separated by spaces. 166DEFINITION 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."
176 (setq definition (substring definition (match-end 0)))) 177 (setq definition (substring definition (match-end 0))))
177 (if (string-match "[ \t\n,]+\\'" definition) 178 (if (string-match "[ \t\n,]+\\'" definition)
178 (setq definition (substring definition 0 (match-beginning 0)))) 179 (setq definition (substring definition 0 (match-beginning 0))))
179 (let ((first (aref definition 0)) 180 (let ((result '())
180 (last (aref definition (1- (length definition)))) 181 (start 0)
181 tem) 182 (L (length definition))
182 (if (and (= first last) (memq first '(?\' ?\"))) 183 end tem)
183 ;; Strip quotation marks. 184 (while start
184 (setq definition (substring definition 1 (1- (length definition)))) 185 ;; If we're reading from the mailrc file, then addresses are delimited
185 ;; ~/.mailrc contains addresses separated by spaces. 186 ;; by spaces, and addresses with embedded spaces must be surrounded by
186 ;; Mailers should expect addresses separated by commas. 187 ;; double-quotes. Otherwise, addresses are separated by commas.
187 (while (setq tem (string-match "[^ \t,][ \t,]+" definition tem)) 188 (if from-mailrc-file
188 (if (= (match-end 0) (length definition)) 189 (if (eq ?\" (aref definition start))
189 (setq definition (substring definition 0 (1+ tem))) 190 (setq start (1+ start)
190 (setq definition (concat (substring definition 191 end (string-match "\"[ \t,]*" definition start))
191 0 (1+ tem)) 192 (setq end (string-match "[ \t,]+" definition start)))
192 ", " 193 (setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
193 (substring definition (match-end 0)))) 194 (setq result (cons (substring definition start end) result))
194 (setq tem (+ 3 tem))))) 195 (setq start (and end
196 (/= (match-end 0) L)
197 (match-end 0))))
198 (setq definition (mapconcat (function identity)
199 (nreverse result)
200 ", "))
195 (setq tem (assoc name mail-aliases)) 201 (setq tem (assoc name mail-aliases))
196 (if tem 202 (if tem
197 (rplacd tem definition) 203 (rplacd tem definition)