annotate lisp/modes/mail-abbrevs.el @ 9:6f2bbbbbe05a

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