annotate lisp/modes/mail-abbrevs.el @ 39:06f275776fba

Added tag r19-15b102 for changeset 1a767b41a199
author cvs
date Mon, 13 Aug 2007 08:54:02 +0200
parents ec9a17fef872
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Abbrev-expansion of mail aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1985-1994 Free Software Foundation, Inc.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
3 ;;; Created: 19 oct 90, Jamie Zawinski <jwz@netscape.com>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Modified: 5 apr 92, Roland McGrath <roland@gnu.ai.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; Last change 4-may-94. jwz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
22 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; This file ensures that, when the point is in a To:, CC:, BCC:, or From:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; field, word-abbrevs are defined for each of your mail aliases. These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; aliases will be defined from your .mailrc file (or the file specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; the MAILRC environment variable) if it exists. Your mail aliases will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; expand any time you type a word-delimiter at the end of an abbreviation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; What you see is what you get: no abbreviations will be expanded after you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; have sent the mail, unlike the old system. This means you don't suffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; the annoyance of having the system do things behind your back -- if an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; address you typed is going to be rewritten, you know it immediately,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; instead of after the mail has been sent and it's too late to do anything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; about it. You will never again be screwed because you forgot to delete an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; old alias from your .mailrc when a new local user arrives and is given a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; userid which conflicts with one of your aliases, for example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; Your mail alias abbrevs will be in effect only when the point is in an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; appropriate header field. When in the body of the message, or other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; header fields, the mail aliases will not expand. Rather, the normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; mode-specific abbrev table (mail-mode-abbrev-table) will be used if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; defined. So if you use mail-mode specific abbrevs, this code will not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; adversely affect you. You can control which header fields the abbrevs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; are used in by changing the variable mail-abbrev-mode-regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; If auto-fill mode is on, abbrevs will wrap at commas instead of at word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; boundaries; also, header continuation-lines will be properly indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; You can also insert a mail alias with mail-interactive-insert-alias
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; (bound to C-c C-a), which prompts you for an alias (with completion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; and inserts its expansion at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; This file fixes a bug in the old system which prohibited your .mailrc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; file from having lines like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; alias someone "John Doe <doe@quux.com>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; That is, if you want an address to have embedded spaces, simply surround it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; with quotes. This is necessary because the format of the .mailrc file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; bogusly uses spaces as address delimiters. The following line defines an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; alias which expands to three addresses:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; alias foobar addr-1 addr-2 "address three <addr-3>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; (This is bogus because mail-delivery programs want commas, not spaces,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; but that's what the file format is, so we have to live with it.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; If you like, you can call the function define-mail-alias to define your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; mail-aliases instead of using a .mailrc file. When you call it in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; way, addresses are separated by commas.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; CAVEAT: This works on most Sun systems; I have been told that some versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; of /bin/mail do not understand double-quotes in the .mailrc file. So you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; should make sure your version does before including verbose addresses like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; this. One solution to this, if you are on a system whose /bin/mail doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;; work that way, (and you still want to be able to /bin/mail to send mail in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;; addition to emacs) is to define minimal aliases (without full names) in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; your .mailrc file, and use define-mail-alias to redefine them when sending
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; mail from emacs; this way, mail sent from /bin/mail will work, and mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;; sent from emacs will be pretty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; Aliases in the mailrc file may be nested. If you define aliases like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; alias group1 fred ethel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; alias group2 larry curly moe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; alias everybody group1 group2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; Then when you type "everybody" on the To: line, it will be expanded to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; fred, ethyl, larry, curly, moe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;; Aliases may also contain forward references; the alias of "everybody" can
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
91 ;;; precede the aliases of "group1" and "group2".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; This code also understands the "source" .mailrc command, for reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; aliases from some other file as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; Aliases may contain hyphens, as in "alias foo-bar foo@bar"; word-abbrevs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; normally cannot contain hyphens, but this code works around that for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; specific case of mail-alias word-abbrevs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; To read in the contents of another .mailrc-type file from emacs, use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; command Meta-X merge-mail-aliases. The rebuild-mail-aliases command is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; similar, but will delete existing aliases first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; If you want multiple addresses separated by a string other than ", " then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; you can set the variable mail-alias-separator-string to it. This has to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; be a comma bracketed by whitespace if you want any kind of reasonable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; behaviour.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; Some versions of /bin/mail append the contents of multiple definitions of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; the same alias together, so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; alias group one two three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;; alias group four five
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; would define "group" as "one two three four five" instead of "four five".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; This code does *not* support that syntax, because it's a horrible syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; and isn't worth the effort or added code complexity. (So there.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;; Thanks to Harald Hanche-Olsen, Michael Ernst, David Loeffler, Noah
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; Friedman, and Michelangelo Grigni for suggestions and bug reports.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;; INSTALLATION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; If you are using Emacs 18, you shouldn't have to do anything at all to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; install this code other than load this file. You might want to do this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; to have this code loaded only when needed:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;; (setq mail-setup-hook '(lambda () (require 'mail-abbrevs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;; Simply loading this file will redefine and overload the required
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; If you want to install this code more permanently (instead of loading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; it as a patch) you need to do the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;; - Remove the entire file mailalias.el;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; - Remove the definition of mail-aliases from sendmail.el;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; - Add a call to mail-aliases-setup to the front of the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;; mail-setup in the file sendmail.el;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;; - Remove the call to expand-mail-aliases from the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;; sendmail-send-it in the file sendmail.el;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; - Remove the autoload of expand-mail-aliases from the file sendmail.el;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;; - Remove the autoload of build-mail-aliases from the file sendmail.el;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;; - Add an autoload of define-mail-alias to loaddefs.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (require 'sendmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defvar mail-abbrev-mailrc-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 "Name of file with mail aliases. If nil, ~/.mailrc is used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defmacro mail-abbrev-mailrc-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 '(or mail-abbrev-mailrc-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (setq mail-abbrev-mailrc-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (or (getenv "MAILRC") "~/.mailrc"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; originally defined in sendmail.el - used to be an alist, now is a table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defvar mail-aliases nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "Word-abbrev table of mail address aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 If this is nil, it means the aliases have not yet been initialized and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 should be read from the .mailrc file. (This is distinct from there being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 no aliases, which is represented by this being a table with no entries.)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defun mail-aliases-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (and (not (vectorp mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (file-exists-p (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (build-mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (make-local-variable 'pre-abbrev-expand-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (setq pre-abbrev-expand-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (cond ((and (listp pre-abbrev-expand-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (not (eq 'lambda (car pre-abbrev-expand-hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (cons 'sendmail-pre-abbrev-expand-hook pre-abbrev-expand-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (list 'sendmail-pre-abbrev-expand-hook pre-abbrev-expand-hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (abbrev-mode 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;; Originally defined in mailalias.el. Changed to call define-mail-alias
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; with an additional argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defun build-mail-aliases (&optional file recursivep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "Read mail aliases from .mailrc and set mail-aliases."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (setq file (expand-file-name (or file (mail-abbrev-mailrc-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (or (vectorp mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (setq mail-aliases (make-abbrev-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (message "Parsing %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (let ((buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (setq buffer (generate-new-buffer "mailrc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (buffer-disable-undo buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (cond ((get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (insert (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (set-buffer (get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (buffer-substring (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ((not (file-exists-p file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (t (insert-file-contents file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; Don't lose if no final newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (or (eq (preceding-char) ?\n) (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; Delete comments from the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (while (search-forward "# " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (let ((p (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (delete-region p (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; handle "\\\n" continuation lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (if (= (preceding-char) ?\\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (progn (delete-char -1) (delete-char 1) (insert ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 "^\\(a\\(lias\\)?\\|g\\(roup\\)?\\|source\\)[ \t]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (if (looking-at "source[ \t]+\\([^ \t\n]+\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (build-mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (substitute-in-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (re-search-forward "[ \t]+\\([^ \t\n]+\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (let* ((name (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (start (progn (skip-chars-forward " \t") (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ; (message "** %s \"%s\"" name (buffer-substring start (point)))(sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (define-mail-alias
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (buffer-substring start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;; Resolve forward references in .mailrc file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; This would happen automatically before the first abbrev was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; expanded, but why not do it now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (or recursivep (mail-resolve-all-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (if buffer (kill-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (set-buffer obuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (message "Parsing %s... done" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (defvar mail-alias-separator-string ", "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 "*A string inserted between addresses in multi-address mail aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 This has to contain a comma, so \", \" is a reasonable value. You might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 also want something like \",\\n \" to get each address on its own line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; define-mail-alias sets this flag, which causes mail-resolve-all-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; to be called before expanding abbrevs if it's necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (defvar mail-abbrev-aliases-need-to-be-resolved t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; originally defined in mailalias.el ; build-mail-aliases calls this with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; stuff parsed from the .mailrc file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun define-mail-alias (name definition &optional from-mailrc-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 "Define NAME as a mail-alias that translates to DEFINITION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 If DEFINITION contains multiple addresses, separate them with commas."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; When this is called from build-mail-aliases, the third argument is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; true, and we do some evil space->comma hacking like /bin/mail does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; Read the defaults first, if we have not done so.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (if (vectorp mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq mail-aliases (make-abbrev-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (if (file-exists-p (mail-abbrev-mailrc-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (build-mail-aliases)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; strip garbage from front and end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (if (string-match "\\`[ \t\n,]+" definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (setq definition (substring definition (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (if (string-match "[ \t\n,]+\\'" definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq definition (substring definition 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (let ((result '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (start 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (L (length definition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (while start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; If we're reading from the mailrc file, then addresses are delimited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; by spaces, and addresses with embedded spaces must be surrounded by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; single or double-quotes. Otherwise, addresses are separated by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;; commas.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (if from-mailrc-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (cond ((eq ?\" (aref definition start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (setq start (1+ start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 end (string-match "\"[ \t,]*" definition start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ((eq ?\' (aref definition start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (setq start (1+ start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 end (string-match "\'[ \t,]*" definition start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq end (string-match "[ \t,]+" definition start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (setq result (cons (substring definition start end) result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq start (and end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (/= (match-end 0) L)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq definition (mapconcat (function identity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (nreverse result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 mail-alias-separator-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (setq mail-abbrev-aliases-need-to-be-resolved t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (setq name (downcase name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; use an abbrev table instead of an alist for mail-aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (let ((abbrevs-changed abbrevs-changed)) ; protect this from being changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (define-abbrev mail-aliases name definition 'mail-abbrev-expand-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defun mail-resolve-all-aliases ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "Resolve all forward references in the mail aliases table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (if mail-abbrev-aliases-need-to-be-resolved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; (message "Resolving mail aliases...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (if (vectorp mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (mapatoms (function mail-resolve-all-aliases-1) mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (setq mail-abbrev-aliases-need-to-be-resolved nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; (message "Resolving mail aliases... done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (defun mail-resolve-all-aliases-1 (sym &optional so-far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (if (memq sym so-far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (error "mail alias loop detected: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (mapconcat 'symbol-name (cons sym so-far) " <- ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (let ((definition (and (boundp sym) (symbol-value sym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (if definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (let ((result '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (start 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (while start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (let ((end (string-match "[ \t\n]*,[, \t\n]*" definition start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (setq result (cons (substring definition start end) result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 start (and end (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (mapconcat (function (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (or (mail-resolve-all-aliases-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (intern-soft (downcase x) mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (cons sym so-far))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (nreverse result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 mail-alias-separator-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (set sym definition))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (symbol-value sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (defun mail-abbrev-expand-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "For use as the fourth arg to define-abbrev.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 After expanding a mail-abbrev, if fill-mode is on and we're past the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 fill-column, break the line at the previous comma, and indent the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (let ((p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 bol comma fp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq bol (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (while (and auto-fill-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (>= (current-column) fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (search-backward "," bol t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq comma (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (forward-char 1) ; Now we are just past the comma.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (setq p (point))
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 4
diff changeset
362 ;; Prevent abbrev expansion from happening again, since
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 4
diff changeset
363 ;; sendmail-pre-abbrev-expand-hook will already have done it.
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 4
diff changeset
364 (let ((abbrev-mode nil))
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 4
diff changeset
365 (indent-relative))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (setq fp (buffer-substring p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;; Go to the end of the new line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (if (> (current-column) fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;; It's still too long; do normal auto-fill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (let ((fill-prefix (or fp "\t")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (do-auto-fill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;; Resume the search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (goto-char comma)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;;; Syntax tables and abbrev-expansion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defvar mail-abbrev-mode-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "*Regexp to select mail-headers in which mail aliases should be expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 This string it will be handed to `looking-at' with the point at the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 of the current line; if it matches, abbrev mode will be turned on, otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 it will be turned off. (You don't need to worry about continuation lines.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 This should be set to match those mail fields in which you want abbreviations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 turned on.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defvar mail-mode-syntax-table (copy-syntax-table text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "The syntax table which is used in send-mail mode message bodies.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defvar mail-mode-header-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (let ((tab (copy-syntax-table text-mode-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;; This makes the characters "@%!._-" be considered symbol-consituents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;; but not word-constituents, so forward-sexp will move you over an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;; entire address, but forward-word will only move you over a sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; of alphanumerics. (Clearly the right thing.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (modify-syntax-entry ?@ "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (modify-syntax-entry ?% "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (modify-syntax-entry ?! "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (modify-syntax-entry ?. "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (modify-syntax-entry ?_ "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (modify-syntax-entry ?- "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (modify-syntax-entry ?< "(>" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (modify-syntax-entry ?> ")<" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "The syntax table used in send-mail mode when in a mail-address header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 mail-mode-syntax-table is used when the cursor is in the message body or in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 non-address headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defvar mail-abbrev-syntax-table
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
411 (if (fboundp 'map-syntax-table)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
412 (let ((tab (copy-syntax-table mail-mode-header-syntax-table)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
413 (if (vectorp tab)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
414 (let ((i (1- (length tab)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
415 (_ (aref (standard-syntax-table) ?_))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
416 (w (aref (standard-syntax-table) ?w)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
417 (while (>= i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
418 (if (= (aref tab i) _) (aset tab i w))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
419 (setq i (1- i))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
420 (map-syntax-table
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
421 #'(lambda (key val)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
422 (if (eq (char-syntax-from-code val) ?_)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
423 (put-char-table key (set-char-syntax-in-code val ?w) tab)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
424 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
425 tab))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
426 tab)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
427 (let* ((tab (copy-syntax-table mail-mode-header-syntax-table))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
428 (i (1- (length tab)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
429 (_ (aref (standard-syntax-table) ?_))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
430 (w (aref (standard-syntax-table) ?w)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
431 (while (>= i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
432 (if (= (aref tab i) _) (aset tab i w))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
433 (setq i (1- i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
434 tab))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "The syntax-table used for abbrev-expansion purposes; this is not actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 made the current syntax table of the buffer, but simply controls the set of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 characters which may be a part of the name of a mail-alias.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (defun mail-abbrev-in-expansion-header-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 "Whether point is in a mail-address header field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (and ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; we are on an appropriate header line...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; skip backwards over continuation lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (while (and (looking-at "^[ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (not (= (point) (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; are we at the front of an appropriate header line?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (looking-at mail-abbrev-mode-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;; ...and we are before the mail-header-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (< (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (search-forward (concat "\n" mail-header-separator "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defvar mail-mode-abbrev-table) ; quiet the compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (defun sendmail-pre-abbrev-expand-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (if mail-abbrev-aliases-need-to-be-resolved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (mail-resolve-all-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (if (and mail-aliases (not (eq mail-aliases t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (if (not (mail-abbrev-in-expansion-header-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; If we're not in a mail header in which mail aliases should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;; be expanded, then use the normal mail-mode abbrev table (if any)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;; and the normal mail-mode syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (setq local-abbrev-table (and (boundp 'mail-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 mail-mode-abbrev-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (set-syntax-table mail-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;; Otherwise, we are in a To: (or CC:, or whatever) header, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; should use word-abbrevs to expand mail aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; - First, install the mail-aliases as the word-abbrev table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; - Then install the mail-abbrev-syntax-table, which temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; marks all of the non-alphanumeric-atom-characters (the "_"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; syntax ones) as being normal word-syntax. We do this because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; the C code for expand-abbrev only works on words, and we want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;; these characters to be considered words for the purpose of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;; abbrev expansion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; - Then we call expand-abbrev again, recursively, to do the abbrev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; expansion with the above syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;; - Then we do a trick which tells the expand-abbrev frame which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;; invoked us to not continue (and thus not expand twice.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; This means that any abbrev expansion will happen as a result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; of this function's call to expand-abbrev, and not as a result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; of the call to expand-abbrev which invoked *us*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;; - Then we set the syntax table to mail-mode-header-syntax-table,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;; which doesn't have anything to do with abbrev expansion, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;; is just for the user's convenience (see its doc string.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (setq local-abbrev-table mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; If the character just typed was non-alpha-symbol-syntax, then don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;; expand the abbrev now (that is, don't expand when the user types -.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;; Check the character's syntax in the mail-mode-header-syntax-table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (set-syntax-table mail-mode-header-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (or (and last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (eq (char-syntax last-command-char) ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; Use this table so that abbrevs can have hyphens in them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (set-syntax-table mail-abbrev-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; Now set it back to what it was before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (set-syntax-table mail-mode-header-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (setq abbrev-start-location (point) ; This is the trick.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 abbrev-start-location-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;;; Reading addresses from the minibuffer; by David Hughes <djh@Harston.CV.COM>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (defun mail-abbrev-minibuffer-setup-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ;; Use as the value of minibuffer-setup-hook when reading addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; from the minibuffer, as in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;; (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; (read-string "Who: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (if (and (not (vectorp mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (file-exists-p (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (build-mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (make-local-variable 'pre-abbrev-expand-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (setq pre-abbrev-expand-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (setq local-abbrev-table mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (set-syntax-table mail-mode-header-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (or (and last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (eq (char-syntax last-command-char) ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;; Use this table so that abbrevs can have hyphens in them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (set-syntax-table mail-abbrev-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; Now set it back to what it was before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (set-syntax-table mail-mode-header-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (setq abbrev-start-location (point) ; This is the trick.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 abbrev-start-location-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (abbrev-mode 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;;; utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (defun merge-mail-aliases (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 "Merge mail aliases from the given file with existing ones."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (interactive (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (let ((insert-default-directory t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (default-directory (expand-file-name "~/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (def (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (format "Read additional aliases from file: (default %s) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (expand-file-name def default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (build-mail-aliases file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (defun rebuild-mail-aliases (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 "Rebuild all the mail aliases from the given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (interactive (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (let ((insert-default-directory t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (default-directory (expand-file-name "~/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (def (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (format "Read mail aliases from file: (default %s) " def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (expand-file-name def default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (setq mail-aliases nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (build-mail-aliases file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (defun mail-interactive-insert-alias (&optional alias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 "Prompt for and insert a mail alias."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (interactive (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (if (not (vectorp mail-aliases)) (mail-aliases-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (list (completing-read "Expand alias: " mail-aliases nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (if (not (vectorp mail-aliases)) (mail-aliases-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (insert (or (and alias (symbol-value (intern-soft alias mail-aliases))) "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ;; call-interactively is so that zmacs-regions gets hacked correctly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;; without making the interactive specs incompatible with v18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (defun abbrev-hacking-next-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 "Just like `next-line' (\\<global-map>\\[next-line]) but expands abbrevs \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 when at end of line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (if (and (looking-at "[ \t]*\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (= (char-syntax (preceding-char)) ?w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (expand-abbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (setq this-command 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (call-interactively 'next-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defun abbrev-hacking-end-of-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 "Just like `end-of-buffer' (\\<global-map>\\[end-of-buffer]) but expands \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 abbrevs when at end of buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (if (and (looking-at "[ \t]*\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (= (char-syntax (preceding-char)) ?w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (expand-abbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (setq this-command 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (call-interactively 'end-of-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (define-key mail-mode-map "\C-c\C-a" 'mail-interactive-insert-alias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ;(define-key mail-mode-map "\C-n" 'abbrev-hacking-next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;(define-key mail-mode-map "\M->" 'abbrev-hacking-end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (let ((subst '((next-line . abbrev-hacking-next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (fkey-next-line . abbrev-hacking-next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (end-of-buffer . abbrev-hacking-end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (fkey-end-of-buffer . abbrev-hacking-end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (while subst
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (let ((keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (delq nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (nconc (where-is-internal (car (car subst)) mail-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (where-is-internal (car (car subst)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (while keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (define-key mail-mode-map (car keys) (cdr (car subst)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (setq keys (cdr keys))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (setq subst (cdr subst))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (provide 'mail-abbrevs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;;; V18 compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;;; All of the Emacs18 stuff is isolated down here so that it will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;;; easy to delete once v18 finally bites the dust.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;;; These defuns and defvars aren't inside the cond in deference to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;;; the intense brokenness of the v18 byte-compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;;; All the code on this page is gross and hidious and awful and might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;;; not even work all that well. Comfort yourself with knowing that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;;; v19 code above works wonderfully.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (defun sendmail-v18-self-insert-command (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 "Just like self-insert-command, but runs sendmail-pre-abbrev-expand-hook."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (not (and last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (eq (char-syntax last-command-char) ?w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (sendmail-pre-abbrev-expand-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;; Unhack expand-abbrev, so it will work right next time around.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (setq abbrev-start-location nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; this is gross and wasteful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (let ((abbrev-mode (if (mail-abbrev-in-expansion-header-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 abbrev-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (self-insert-command arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defun abbrev-hacking-next-line-v18 (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (if (looking-at "[ \t]*\n") (sendmail-pre-abbrev-expand-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (setq this-command 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (next-line arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (defun abbrev-hacking-end-of-buffer-v18 (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (if (looking-at "[ \t]*\n") (sendmail-pre-abbrev-expand-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (setq this-command 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (end-of-buffer arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (defvar mail-abbrevs-v18-map-munged nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (defun mail-abbrevs-v18-munge-map ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;; For every key that is bound to self-insert-command in global-map,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 ;; bind that key to sendmail-self-insert-command in mail-mode-map.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ;; We used to do this by making the mail-mode-map be a non-sparse map,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;; but that made the esc-map be shared in such a way that making a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;; local meta binding in the mail-mode-map made a *global* binding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;; instead. Yucko.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (let ((global-map (current-global-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 new-bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (while (< i 128)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (if (eq 'self-insert-command (or (cdr (assq i mail-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (aref global-map i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (setq new-bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (cons (cons i 'sendmail-v18-self-insert-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 new-bindings)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (setq mail-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (nconc (copy-keymap mail-mode-map) (nreverse new-bindings))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (setq mail-abbrevs-v18-map-munged t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (defun mail-aliases-setup-v18 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 "Put this on `mail-setup-hook' to use mail-abbrevs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (if (not (eq major-mode 'mail-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (or (and mail-mode-map (eq (current-local-map) mail-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (error "shut 'er down clancy, she's suckin' mud"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (if (and (not (vectorp mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (file-exists-p (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (build-mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (or mail-abbrevs-v18-map-munged (mail-abbrevs-v18-munge-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (use-local-map mail-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (abbrev-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (cond ((or (string-match "^18\\." emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (and (boundp 'epoch::version) epoch::version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ;; v19 (and this code) uses a new name for this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (or (fboundp 'buffer-disable-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (fset 'buffer-disable-undo 'buffer-flush-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ;; v19 (and this code) uses a new name for auto-fill-hook (-function).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;; Encapsulate the function that uses it to bind the new name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (or (fboundp 'mail-abbrev-expand-hook-v19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (fset 'mail-abbrev-expand-hook-v19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (symbol-function 'mail-abbrev-expand-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (fset 'mail-abbrev-expand-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (let ((auto-fill-function auto-fill-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (mail-abbrev-expand-hook-v19)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; Turn off the broken v18 code (that is still called from sendmail.el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (fset 'expand-mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (function (lambda (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 "Obsoleted by mail-abbrevs. Does nothing."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 ;; Redefine the abbrev-hacking functions. Yuck.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (fset 'abbrev-hacking-next-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (function (lambda (p) (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (abbrev-hacking-next-line-v18 p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (fset 'abbrev-hacking-end-of-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (function (lambda (p) (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (abbrev-hacking-end-of-buffer-v18 p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; Encapsulate mail-setup to do the necessary buffer initializations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (or (fboundp 'mail-setup-v18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (fset 'mail-setup-v18 (symbol-function 'mail-setup)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (fset 'mail-setup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (function (lambda (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (mail-aliases-setup-v18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (apply 'mail-setup-v18 args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ;; Encapsulate VM's version of mail-setup as well, if vm-mail is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;; defined as a function or as an autoload.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (cond ((and (fboundp 'vm-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (if (eq 'autoload (car-safe (symbol-function 'vm-mail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (load (nth 1 (symbol-function 'vm-mail)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (or (fboundp 'vm-mail-internal-v18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (fset 'vm-mail-internal-v18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (symbol-function 'vm-mail-internal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (fset 'vm-mail-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (function (lambda (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (apply 'vm-mail-internal-v18 args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (mail-aliases-setup-v18))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;; If we're being loaded from mail-setup-hook or mail-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ;; as run from inside mail-setup or vm-mail-internal, then install
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ;; right now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (if (eq major-mode 'mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (mail-aliases-setup-v18))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (t ; v19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (fmakunbound 'expand-mail-aliases)))