annotate lisp/mail/mailalias.el @ 2565:c1a1557bffde

(Fdefine_function): Changed name back to Fdefalias, so we get things in a known-good state.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Fri, 23 Apr 1993 03:40:03 +0000
parents 10e417efb12a
children e67f922b73ed
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
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1448
diff changeset
24 ;;; Commentary:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1448
diff changeset
25
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1448
diff changeset
26 ;; Basic functions for defining and expanding mail aliases.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1448
diff changeset
27 ;; These seal off the interface to the alias-definition parts of a
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1448
diff changeset
28 ;; .mailrc file formatted for BSD's Mail or USL's mailx.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1448
diff changeset
29
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
30 ;;; Code:
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
31
1448
99fb20ef1a17 (mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents: 1434
diff changeset
32 (defvar mail-aliases t
99fb20ef1a17 (mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents: 1434
diff changeset
33 "Alias of mail address aliases,
99fb20ef1a17 (mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents: 1434
diff changeset
34 or t meaning should be initialized from `~/.mailrc'.")
99fb20ef1a17 (mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents: 1434
diff changeset
35
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
36 ;; Called from sendmail-send-it, or similar functions,
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
37 ;; only if some mail aliases are defined.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
38 (defun expand-mail-aliases (beg end &optional exclude)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
39 "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
40 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
41 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
42 removed from alias expansions."
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
43 (if (eq mail-aliases t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
44 (progn (setq mail-aliases nil) (build-mail-aliases)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
45 (goto-char beg)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
46 (setq end (set-marker (make-marker) end))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
47 (let ((case-fold-search nil))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
48 (while (let ((case-fold-search t))
219
6f8afe7308eb *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 53
diff changeset
49 (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
50 (skip-chars-forward " \t")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
51 (let ((beg1 (point))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
52 end1 pos epos seplen
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
53 ;; DISABLED-ALIASES records aliases temporarily disabled
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
54 ;; while we scan text that resulted from expanding those aliases.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
55 ;; Each element is (ALIAS . TILL-WHEN), where TILL-WHEN
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
56 ;; is where to reenable the alias (expressed as number of chars
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
57 ;; counting from END1).
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
58 (disabled-aliases nil))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
59 (re-search-forward "^[^ \t]" end 'move)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
60 (beginning-of-line)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
61 (skip-chars-backward " \t\n")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
62 (setq end1 (point-marker))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
63 (goto-char beg1)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
64 (while (< (point) end1)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
65 (setq pos (point))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
66 ;; Reenable any aliases which were disabled for ranges
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
67 ;; that we have passed out of.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
68 (while (and disabled-aliases (> pos (- end1 (cdr (car disabled-aliases)))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
69 (setq disabled-aliases (cdr disabled-aliases)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
70 ;; EPOS gets position of end of next name;
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
71 ;; SEPLEN gets length of whitespace&separator that follows it.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
72 (if (re-search-forward "[ \t]*[\n,][ \t]*" end1 t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
73 (setq epos (match-beginning 0)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
74 seplen (- (point) epos))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
75 (setq epos (marker-position end1) seplen 0))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
76 (let (translation
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
77 (string (buffer-substring pos epos)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
78 (if (and (not (assoc string disabled-aliases))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
79 (setq translation
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
80 (cdr (assoc string mail-aliases))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
81 (progn
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
82 ;; This name is an alias. Disable it.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
83 (setq disabled-aliases (cons (cons string (- end1 epos))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
84 disabled-aliases))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
85 ;; Replace the alias with its expansion
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
86 ;; then rescan the expansion for more aliases.
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 (insert translation)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
89 (if exclude
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
90 (let ((regexp
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
91 (concat "\\b\\(" exclude "\\)\\b"))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
92 (end (point-marker)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
93 (goto-char pos)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
94 (while (re-search-forward regexp end t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
95 (replace-match ""))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
96 (goto-char end)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
97 (delete-region (point) (+ (point) (- epos pos)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
98 (goto-char pos))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
99 ;; Name is not an alias. Skip to start of next name.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
100 (goto-char epos)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
101 (forward-char seplen))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
102 (set-marker end1 nil)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
103 (set-marker end nil)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
104
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
105 ;; Called by mail-setup, or similar functions, only if ~/.mailrc exists.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
106 (defun build-mail-aliases (&optional file)
1434
d1f24ca467fc Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 923
diff changeset
107 "Read mail aliases from `~/.mailrc' and set `mail-aliases'."
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
108 (setq file (expand-file-name (or file "~/.mailrc")))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
109 (let ((buffer nil)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
110 (obuf (current-buffer)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
111 (unwind-protect
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
112 (progn
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
113 (setq buffer (generate-new-buffer "mailrc"))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
114 (buffer-disable-undo buffer)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
115 (set-buffer buffer)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
116 (cond ((get-file-buffer file)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
117 (insert (save-excursion
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
118 (set-buffer (get-file-buffer file))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
119 (buffer-substring (point-min) (point-max)))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
120 ((not (file-exists-p file)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
121 (t (insert-file-contents file)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
122 ;; Don't lose if no final newline.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
123 (goto-char (point-max))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
124 (or (eq (preceding-char) ?\n) (newline))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
125 (goto-char (point-min))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
126 ;; handle "\\\n" continuation lines
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
127 (while (not (eobp))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
128 (end-of-line)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
129 (if (= (preceding-char) ?\\)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
130 (progn (delete-char -1) (delete-char 1) (insert ?\ ))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
131 (forward-char 1)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
132 (goto-char (point-min))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
133 (while (or (re-search-forward "^a\\(lias\\|\\)[ \t]+" nil t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
134 (re-search-forward "^g\\(roup\\|\\)[ \t]+" nil t))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
135 (re-search-forward "[^ \t]+")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
136 (let* ((name (buffer-substring (match-beginning 0) (match-end 0)))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
137 (start (progn (skip-chars-forward " \t") (point))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
138 (end-of-line)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
139 (define-mail-alias
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
140 name
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
141 (buffer-substring start (point)))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
142 mail-aliases)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
143 (if buffer (kill-buffer buffer))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
144 (set-buffer obuf))))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
145
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
146 ;; Always autoloadable in case the user wants to define aliases
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
147 ;; interactively or in .emacs.
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 221
diff changeset
148 ;;;###autoload
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
149 (defun define-mail-alias (name definition)
221
ce8e0192266e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 219
diff changeset
150 "Define NAME as a mail alias that translates to DEFINITION.
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
151 This means that sending a message to NAME will actually send to DEFINITION.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
152 DEFINITION can be one or more mail addresses separated by commas."
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
153 (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
154 ;; Read the defaults first, if we have not done so.
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
155 (if (eq mail-aliases t)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
156 (progn
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
157 (setq mail-aliases nil)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
158 (if (file-exists-p "~/.mailrc")
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
159 (build-mail-aliases))))
474
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
160 ;; Strip leading and trailing blanks.
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
161 (if (string-match "^[ \t]+" definition)
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
162 (setq definition (substring definition (match-end 0))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
163 (if (string-match "[ \t]+$" definition)
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
164 (setq definition (substring definition 0 (match-beginning 0))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
165 (let ((first (aref definition 0))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
166 (last (aref definition (1- (length definition))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
167 tem)
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
168 (if (and (= first last) (memq first '(?\' ?\")))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
169 ;; Strip quotation marks.
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
170 (setq definition (substring definition 1 (1- (length definition))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
171 ;; ~/.mailrc contains addresses separated by spaces.
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
172 ;; mailers should expect addresses separated by commas.
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
173 (while (setq tem (string-match "[^ \t,][ \t,]+" definition tem))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
174 (if (= (match-end 0) (length definition))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
175 (setq definition (substring definition 0 (1+ tem)))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
176 (setq definition (concat (substring definition
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
177 0 (1+ tem))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
178 ", "
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
179 (substring definition (match-end 0))))
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
180 (setq tem (+ 3 tem)))))
53
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
181 (setq tem (assoc name mail-aliases))
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
182 (if tem
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
183 (rplacd tem definition)
a8efef5eb891 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
184 (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
185
923
9f3cc03dae67 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
186 (provide 'mailalias)
9f3cc03dae67 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
187
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 474
diff changeset
188 ;;; mailalias.el ends here