annotate lisp/mail/mailalias.el @ 2109:73485780a8f9

* simple.el (yank, yank-pop): Always return nil; don't rely on exchange-point-and-mark to return nil. * fill.el (justify-current-line): Return nil, to be sure to conform with documentation.
author Jim Blandy <jimb@redhat.com>
date Thu, 11 Mar 1993 07:05:23 +0000
parents 99fb20ef1a17
children 10e417efb12a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 474
diff changeset
1 ;;; mailalias.el --- expand mailing address aliases defined in ~/.mailrc.
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 474
diff changeset
2
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
3 ;; Copyright (C) 1985, 1987 Free Software Foundation, Inc.
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
5 ;; Maintainer: FSF
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
6 ;; Keywords: mail
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
7
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
9
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
13 ;; any later version.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
14
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
19
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
23
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
24 ;;; Code:
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
25
1448
99fb20ef1a17 (mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents: 1434
diff changeset
26 (defvar mail-aliases t
99fb20ef1a17 (mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents: 1434
diff changeset
27 "Alias of mail address aliases,
99fb20ef1a17 (mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents: 1434
diff changeset
28 or t meaning should be initialized from `~/.mailrc'.")
99fb20ef1a17 (mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents: 1434
diff changeset
29
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
30 ;; Called from sendmail-send-it, or similar functions,
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
31 ;; only if some mail aliases are defined.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
32 (defun expand-mail-aliases (beg end &optional exclude)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
33 "Expand all mail aliases in suitable header fields found between BEG and END.
221
ce8e0192266e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 219
diff changeset
34 Suitable header fields are `To', `Cc' and `Bcc' and their `Resent-' variants.
ce8e0192266e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 219
diff changeset
35 Optional second arg EXCLUDE may be a regular expression defining text to be
ce8e0192266e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 219
diff changeset
36 removed from alias expansions."
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
37 (if (eq mail-aliases t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
38 (progn (setq mail-aliases nil) (build-mail-aliases)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
39 (goto-char beg)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
40 (setq end (set-marker (make-marker) end))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
41 (let ((case-fold-search nil))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
42 (while (let ((case-fold-search t))
219
6f8afe7308eb *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 53
diff changeset
43 (re-search-forward "^\\(to\\|cc\\|bcc\\|resent-to\\|resent-cc\\|resent-bcc\\):" end t))
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
44 (skip-chars-forward " \t")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
45 (let ((beg1 (point))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
46 end1 pos epos seplen
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
47 ;; DISABLED-ALIASES records aliases temporarily disabled
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
48 ;; while we scan text that resulted from expanding those aliases.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
49 ;; Each element is (ALIAS . TILL-WHEN), where TILL-WHEN
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
50 ;; is where to reenable the alias (expressed as number of chars
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
51 ;; counting from END1).
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
52 (disabled-aliases nil))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
53 (re-search-forward "^[^ \t]" end 'move)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
54 (beginning-of-line)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
55 (skip-chars-backward " \t\n")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
56 (setq end1 (point-marker))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
57 (goto-char beg1)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
58 (while (< (point) end1)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
59 (setq pos (point))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
60 ;; Reenable any aliases which were disabled for ranges
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
61 ;; that we have passed out of.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
62 (while (and disabled-aliases (> pos (- end1 (cdr (car disabled-aliases)))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
63 (setq disabled-aliases (cdr disabled-aliases)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
64 ;; EPOS gets position of end of next name;
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
65 ;; SEPLEN gets length of whitespace&separator that follows it.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
66 (if (re-search-forward "[ \t]*[\n,][ \t]*" end1 t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
67 (setq epos (match-beginning 0)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
68 seplen (- (point) epos))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
69 (setq epos (marker-position end1) seplen 0))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
70 (let (translation
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
71 (string (buffer-substring pos epos)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
72 (if (and (not (assoc string disabled-aliases))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
73 (setq translation
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
74 (cdr (assoc string mail-aliases))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
75 (progn
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
76 ;; This name is an alias. Disable it.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
77 (setq disabled-aliases (cons (cons string (- end1 epos))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
78 disabled-aliases))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
79 ;; Replace the alias with its expansion
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
80 ;; then rescan the expansion for more aliases.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
81 (goto-char pos)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
82 (insert translation)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
83 (if exclude
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
84 (let ((regexp
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
85 (concat "\\b\\(" exclude "\\)\\b"))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
86 (end (point-marker)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
87 (goto-char pos)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
88 (while (re-search-forward regexp end t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
89 (replace-match ""))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
90 (goto-char end)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
91 (delete-region (point) (+ (point) (- epos pos)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
92 (goto-char pos))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
93 ;; Name is not an alias. Skip to start of next name.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
94 (goto-char epos)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
95 (forward-char seplen))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
96 (set-marker end1 nil)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
97 (set-marker end nil)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
98
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
99 ;; Called by mail-setup, or similar functions, only if ~/.mailrc exists.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
100 (defun build-mail-aliases (&optional file)
1434
d1f24ca467fc Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 923
diff changeset
101 "Read mail aliases from `~/.mailrc' and set `mail-aliases'."
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
102 (setq file (expand-file-name (or file "~/.mailrc")))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
103 (let ((buffer nil)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
104 (obuf (current-buffer)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
105 (unwind-protect
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
106 (progn
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
107 (setq buffer (generate-new-buffer "mailrc"))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
108 (buffer-disable-undo buffer)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
109 (set-buffer buffer)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
110 (cond ((get-file-buffer file)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
111 (insert (save-excursion
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
112 (set-buffer (get-file-buffer file))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
113 (buffer-substring (point-min) (point-max)))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
114 ((not (file-exists-p file)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
115 (t (insert-file-contents file)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
116 ;; Don't lose if no final newline.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
117 (goto-char (point-max))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
118 (or (eq (preceding-char) ?\n) (newline))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
119 (goto-char (point-min))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
120 ;; handle "\\\n" continuation lines
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
121 (while (not (eobp))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
122 (end-of-line)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
123 (if (= (preceding-char) ?\\)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
124 (progn (delete-char -1) (delete-char 1) (insert ?\ ))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
125 (forward-char 1)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
126 (goto-char (point-min))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
127 (while (or (re-search-forward "^a\\(lias\\|\\)[ \t]+" nil t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
128 (re-search-forward "^g\\(roup\\|\\)[ \t]+" nil t))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
129 (re-search-forward "[^ \t]+")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
130 (let* ((name (buffer-substring (match-beginning 0) (match-end 0)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
131 (start (progn (skip-chars-forward " \t") (point))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
132 (end-of-line)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
133 (define-mail-alias
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
134 name
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
135 (buffer-substring start (point)))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
136 mail-aliases)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
137 (if buffer (kill-buffer buffer))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
138 (set-buffer obuf))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
139
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
140 ;; Always autoloadable in case the user wants to define aliases
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
141 ;; interactively or in .emacs.
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 221
diff changeset
142 ;;;###autoload
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
143 (defun define-mail-alias (name definition)
221
ce8e0192266e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 219
diff changeset
144 "Define NAME as a mail alias that translates to DEFINITION.
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
145 This means that sending a message to NAME will actually send to DEFINITION.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
146 DEFINITION can be one or more mail addresses separated by commas."
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
147 (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
148 ;; Read the defaults first, if we have not done so.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
149 (if (eq mail-aliases t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
150 (progn
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
151 (setq mail-aliases nil)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
152 (if (file-exists-p "~/.mailrc")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
153 (build-mail-aliases))))
474
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
154 ;; Strip leading and trailing blanks.
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
155 (if (string-match "^[ \t]+" definition)
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
156 (setq definition (substring definition (match-end 0))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
157 (if (string-match "[ \t]+$" definition)
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
158 (setq definition (substring definition 0 (match-beginning 0))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
159 (let ((first (aref definition 0))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
160 (last (aref definition (1- (length definition))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
161 tem)
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
162 (if (and (= first last) (memq first '(?\' ?\")))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
163 ;; Strip quotation marks.
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
164 (setq definition (substring definition 1 (1- (length definition))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
165 ;; ~/.mailrc contains addresses separated by spaces.
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
166 ;; mailers should expect addresses separated by commas.
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
167 (while (setq tem (string-match "[^ \t,][ \t,]+" definition tem))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
168 (if (= (match-end 0) (length definition))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
169 (setq definition (substring definition 0 (1+ tem)))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
170 (setq definition (concat (substring definition
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
171 0 (1+ tem))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
172 ", "
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
173 (substring definition (match-end 0))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
174 (setq tem (+ 3 tem)))))
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
175 (setq tem (assoc name mail-aliases))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
176 (if tem
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
177 (rplacd tem definition)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
178 (setq mail-aliases (cons (cons name definition) mail-aliases)))))
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 474
diff changeset
179
923
9f3cc03dae67 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
180 (provide 'mailalias)
9f3cc03dae67 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
181
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 474
diff changeset
182 ;;; mailalias.el ends here