annotate lisp/modes/mail-abbrevs.el @ 189:489f57a838ef r20-3b21

Import from CVS: tag r20-3b21
author cvs
date Mon, 13 Aug 2007 09:57:07 +0200
parents 538048ae2ab8
children
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.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 120
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
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 76
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
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
146 (defgroup mail-abbrevs nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
147 "Mail abbreviation (addressbook)"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
148 :group 'mail)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
149
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;;###autoload
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
151 (defcustom mail-abbrev-mailrc-file nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
152 "Name of file with mail aliases. If nil, ~/.mailrc is used."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
153 :type '(choice (const :tag "Default" nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
154 file)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
155 :group 'mail-abbrevs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defmacro mail-abbrev-mailrc-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 '(or mail-abbrev-mailrc-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (setq mail-abbrev-mailrc-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (or (getenv "MAILRC") "~/.mailrc"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; 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
163 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar mail-aliases nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "Word-abbrev table of mail address aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 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
167 should be read from the .mailrc file. (This is distinct from there being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 no aliases, which is represented by this being a table with no entries.)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (defun mail-aliases-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (if (and (not (vectorp mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (file-exists-p (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (build-mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (make-local-variable 'pre-abbrev-expand-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (setq pre-abbrev-expand-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (cond ((and (listp pre-abbrev-expand-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (not (eq 'lambda (car pre-abbrev-expand-hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (cons 'sendmail-pre-abbrev-expand-hook pre-abbrev-expand-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (list 'sendmail-pre-abbrev-expand-hook pre-abbrev-expand-hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (abbrev-mode 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; Originally defined in mailalias.el. Changed to call define-mail-alias
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; with an additional argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defun build-mail-aliases (&optional file recursivep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "Read mail aliases from .mailrc and set mail-aliases."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (setq file (expand-file-name (or file (mail-abbrev-mailrc-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (or (vectorp mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (setq mail-aliases (make-abbrev-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (message "Parsing %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (let ((buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq buffer (generate-new-buffer "mailrc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (buffer-disable-undo buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (cond ((get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (insert (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (set-buffer (get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (buffer-substring (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ((not (file-exists-p file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (t (insert-file-contents file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; Don't lose if no final newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (or (eq (preceding-char) ?\n) (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; Delete comments from the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (while (search-forward "# " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (let ((p (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (delete-region p (point))))
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 ;; handle "\\\n" continuation lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (if (= (preceding-char) ?\\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (progn (delete-char -1) (delete-char 1) (insert ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 "^\\(a\\(lias\\)?\\|g\\(roup\\)?\\|source\\)[ \t]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if (looking-at "source[ \t]+\\([^ \t\n]+\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (build-mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (substitute-in-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (re-search-forward "[ \t]+\\([^ \t\n]+\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (let* ((name (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (start (progn (skip-chars-forward " \t") (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ; (message "** %s \"%s\"" name (buffer-substring start (point)))(sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (define-mail-alias
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (buffer-substring start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; Resolve forward references in .mailrc file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; This would happen automatically before the first abbrev was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; expanded, but why not do it now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (or recursivep (mail-resolve-all-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (if buffer (kill-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (set-buffer obuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (message "Parsing %s... done" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
252 (defcustom mail-alias-separator-string ", "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 "*A string inserted between addresses in multi-address mail aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 This has to contain a comma, so \", \" is a reasonable value. You might
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
255 also want something like \",\\n \" to get each address on its own line."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
256 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
257 :group 'mail-abbrevs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; define-mail-alias sets this flag, which causes mail-resolve-all-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; to be called before expanding abbrevs if it's necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defvar mail-abbrev-aliases-need-to-be-resolved t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; originally defined in mailalias.el ; build-mail-aliases calls this with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; stuff parsed from the .mailrc file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (defun define-mail-alias (name definition &optional from-mailrc-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "Define NAME as a mail-alias that translates to DEFINITION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 If DEFINITION contains multiple addresses, separate them with commas."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; When this is called from build-mail-aliases, the third argument is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; true, and we do some evil space->comma hacking like /bin/mail does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; Read the defaults first, if we have not done so.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if (vectorp mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (setq mail-aliases (make-abbrev-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (if (file-exists-p (mail-abbrev-mailrc-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (build-mail-aliases)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; strip garbage from front and end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (if (string-match "\\`[ \t\n,]+" definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (setq definition (substring definition (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (if (string-match "[ \t\n,]+\\'" definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (setq definition (substring definition 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (let ((result '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (start 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (L (length definition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (while start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; If we're reading from the mailrc file, then addresses are delimited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; by spaces, and addresses with embedded spaces must be surrounded by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; single or double-quotes. Otherwise, addresses are separated by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; commas.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (if from-mailrc-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (cond ((eq ?\" (aref definition start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq start (1+ start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 end (string-match "\"[ \t,]*" definition start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ((eq ?\' (aref definition start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq start (1+ start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 end (string-match "\'[ \t,]*" definition start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (setq end (string-match "[ \t,]+" definition start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (setq result (cons (substring definition start end) result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq start (and end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (/= (match-end 0) L)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (setq definition (mapconcat (function identity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (nreverse result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 mail-alias-separator-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq mail-abbrev-aliases-need-to-be-resolved t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (setq name (downcase name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; use an abbrev table instead of an alist for mail-aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (let ((abbrevs-changed abbrevs-changed)) ; protect this from being changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (define-abbrev mail-aliases name definition 'mail-abbrev-expand-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun mail-resolve-all-aliases ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "Resolve all forward references in the mail aliases table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (if mail-abbrev-aliases-need-to-be-resolved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; (message "Resolving mail aliases...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (if (vectorp mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (mapatoms (function mail-resolve-all-aliases-1) mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (setq mail-abbrev-aliases-need-to-be-resolved nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; (message "Resolving mail aliases... done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (defun mail-resolve-all-aliases-1 (sym &optional so-far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if (memq sym so-far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (error "mail alias loop detected: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (mapconcat 'symbol-name (cons sym so-far) " <- ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (let ((definition (and (boundp sym) (symbol-value sym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (if definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (let ((result '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (start 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (while start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (let ((end (string-match "[ \t\n]*,[, \t\n]*" definition start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (setq result (cons (substring definition start end) result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 start (and end (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (setq definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (mapconcat (function (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (or (mail-resolve-all-aliases-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (intern-soft (downcase x) mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (cons sym so-far))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (nreverse result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 mail-alias-separator-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (set sym definition))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (symbol-value sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun mail-abbrev-expand-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "For use as the fourth arg to define-abbrev.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 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
355 fill-column, break the line at the previous comma, and indent the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (let ((p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 bol comma fp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (setq bol (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (while (and auto-fill-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (>= (current-column) fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (search-backward "," bol t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (setq comma (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (forward-char 1) ; Now we are just past the comma.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (setq p (point))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
371 ;; Prevent abbrev expansion from happening again, since
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
372 ;; sendmail-pre-abbrev-expand-hook will already have done it.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
373 (let ((abbrev-mode nil))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
374 (indent-relative))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq fp (buffer-substring p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; Go to the end of the new line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (if (> (current-column) fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;; It's still too long; do normal auto-fill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (let ((fill-prefix (or fp "\t")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (do-auto-fill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; Resume the search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (goto-char comma)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;;; Syntax tables and abbrev-expansion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
388 (defcustom mail-abbrev-mode-regexp
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 "*Regexp to select mail-headers in which mail aliases should be expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 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
392 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
393 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
394 This should be set to match those mail fields in which you want abbreviations
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
395 turned on."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
396 :type 'regexp
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
397 :group 'mail-abbrevs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (defvar mail-mode-syntax-table (copy-syntax-table text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "The syntax table which is used in send-mail mode message bodies.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defvar mail-mode-header-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (let ((tab (copy-syntax-table text-mode-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; This makes the characters "@%!._-" be considered symbol-consituents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; but not word-constituents, so forward-sexp will move you over an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;; entire address, but forward-word will only move you over a sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;; of alphanumerics. (Clearly the right thing.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (modify-syntax-entry ?@ "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (modify-syntax-entry ?% "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (modify-syntax-entry ?! "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (modify-syntax-entry ?. "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (modify-syntax-entry ?_ "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (modify-syntax-entry ?- "_" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (modify-syntax-entry ?< "(>" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (modify-syntax-entry ?> ")<" tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "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
418 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
419 non-address headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (defvar mail-abbrev-syntax-table
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
422 (let ((tab (copy-syntax-table mail-mode-header-syntax-table)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
423 (if (vectorp tab)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
424 (let ((i (1- (length tab)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
425 (_ (aref (standard-syntax-table) ?_))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
426 (w (aref (standard-syntax-table) ?w)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
427 (while (>= i 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
428 (if (= (aref tab i) _) (aset tab i w))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
429 (setq i (1- i))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
430 (map-syntax-table
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
431 #'(lambda (key val)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
432 (if (eq (char-syntax-from-code val) ?_)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
433 (put-char-table key (set-char-syntax-in-code val ?w) tab)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
434 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
435 tab))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
436 tab)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 "The syntax-table used for abbrev-expansion purposes; this is not actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 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
439 characters which may be a part of the name of a mail-alias.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defun mail-abbrev-in-expansion-header-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 "Whether point is in a mail-address header field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (and ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; we are on an appropriate header line...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;; skip backwards over continuation lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (while (and (looking-at "^[ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (not (= (point) (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;; are we at the front of an appropriate header line?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (looking-at mail-abbrev-mode-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;; ...and we are before the mail-header-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (< (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (search-forward (concat "\n" mail-header-separator "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (defvar mail-mode-abbrev-table) ; quiet the compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (defun sendmail-pre-abbrev-expand-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (if mail-abbrev-aliases-need-to-be-resolved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (mail-resolve-all-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (if (and mail-aliases (not (eq mail-aliases t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (if (not (mail-abbrev-in-expansion-header-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;; If we're not in a mail header in which mail aliases should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; be expanded, then use the normal mail-mode abbrev table (if any)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;; and the normal mail-mode syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (setq local-abbrev-table (and (boundp 'mail-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 mail-mode-abbrev-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (set-syntax-table mail-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; Otherwise, we are in a To: (or CC:, or whatever) header, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; should use word-abbrevs to expand mail aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; - First, install the mail-aliases as the word-abbrev table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; - Then install the mail-abbrev-syntax-table, which temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; marks all of the non-alphanumeric-atom-characters (the "_"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;; syntax ones) as being normal word-syntax. We do this because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;; the C code for expand-abbrev only works on words, and we want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; these characters to be considered words for the purpose of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; abbrev expansion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;; - Then we call expand-abbrev again, recursively, to do the abbrev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;; expansion with the above syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; - Then we do a trick which tells the expand-abbrev frame which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; invoked us to not continue (and thus not expand twice.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; This means that any abbrev expansion will happen as a result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;; of this function's call to expand-abbrev, and not as a result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;; of the call to expand-abbrev which invoked *us*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;; - Then we set the syntax table to mail-mode-header-syntax-table,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; which doesn't have anything to do with abbrev expansion, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; is just for the user's convenience (see its doc string.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (setq local-abbrev-table mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;; If the character just typed was non-alpha-symbol-syntax, then don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ;; expand the abbrev now (that is, don't expand when the user types -.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ;; Check the character's syntax in the mail-mode-header-syntax-table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (set-syntax-table mail-mode-header-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (or (and last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (eq (char-syntax last-command-char) ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;; Use this table so that abbrevs can have hyphens in them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (set-syntax-table mail-abbrev-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; Now set it back to what it was before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (set-syntax-table mail-mode-header-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (setq abbrev-start-location (point) ; This is the trick.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 abbrev-start-location-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ;;; Reading addresses from the minibuffer; by David Hughes <djh@Harston.CV.COM>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defun mail-abbrev-minibuffer-setup-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;; Use as the value of minibuffer-setup-hook when reading addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; from the minibuffer, as in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;; (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;; (read-string "Who: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (if (and (not (vectorp mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (file-exists-p (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (build-mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (make-local-variable 'pre-abbrev-expand-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (setq pre-abbrev-expand-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (setq local-abbrev-table mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (set-syntax-table mail-mode-header-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (or (and last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (eq (char-syntax last-command-char) ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; Use this table so that abbrevs can have hyphens in them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (set-syntax-table mail-abbrev-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;; Now set it back to what it was before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (set-syntax-table mail-mode-header-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (setq abbrev-start-location (point) ; This is the trick.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 abbrev-start-location-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (abbrev-mode 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ;;; utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (defun merge-mail-aliases (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 "Merge mail aliases from the given file with existing ones."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (interactive (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (let ((insert-default-directory t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (default-directory (expand-file-name "~/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (def (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (format "Read additional aliases from file: (default %s) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (expand-file-name def default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (build-mail-aliases file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (defun rebuild-mail-aliases (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 "Rebuild all the mail aliases from the given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (interactive (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (let ((insert-default-directory t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (default-directory (expand-file-name "~/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (def (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (format "Read mail aliases from file: (default %s) " def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (expand-file-name def default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (setq mail-aliases nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (build-mail-aliases file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (defun mail-interactive-insert-alias (&optional alias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 "Prompt for and insert a mail alias."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (interactive (progn
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 (list (completing-read "Expand alias: " mail-aliases nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (if (not (vectorp mail-aliases)) (mail-aliases-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (insert (or (and alias (symbol-value (intern-soft alias mail-aliases))) "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;; call-interactively is so that zmacs-regions gets hacked correctly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; without making the interactive specs incompatible with v18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (defun abbrev-hacking-next-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 "Just like `next-line' (\\<global-map>\\[next-line]) but expands abbrevs \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 when at end of line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (if (and (looking-at "[ \t]*\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (= (char-syntax (preceding-char)) ?w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (expand-abbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (setq this-command 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (call-interactively 'next-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (defun abbrev-hacking-end-of-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 "Just like `end-of-buffer' (\\<global-map>\\[end-of-buffer]) but expands \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 abbrevs when at end of buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (if (and (looking-at "[ \t]*\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (= (char-syntax (preceding-char)) ?w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (expand-abbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (setq this-command 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (call-interactively 'end-of-buffer))
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-c\C-a" 'mail-interactive-insert-alias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ;(define-key mail-mode-map "\C-n" 'abbrev-hacking-next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;(define-key mail-mode-map "\M->" 'abbrev-hacking-end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (let ((subst '((next-line . abbrev-hacking-next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (fkey-next-line . abbrev-hacking-next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (end-of-buffer . abbrev-hacking-end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (fkey-end-of-buffer . abbrev-hacking-end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (while subst
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (let ((keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (delq nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (nconc (where-is-internal (car (car subst)) mail-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (where-is-internal (car (car subst)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (while keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (define-key mail-mode-map (car keys) (cdr (car subst)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (setq keys (cdr keys))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (setq subst (cdr subst))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (provide 'mail-abbrevs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;;; V18 compatibility
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 of the Emacs18 stuff is isolated down here so that it will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;;; easy to delete once v18 finally bites the dust.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;;; These defuns and defvars aren't inside the cond in deference to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;;; the intense brokenness of the v18 byte-compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;;; 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
640 ;;; not even work all that well. Comfort yourself with knowing that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;;; v19 code above works wonderfully.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (defun sendmail-v18-self-insert-command (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 "Just like self-insert-command, but runs sendmail-pre-abbrev-expand-hook."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (if (not (and last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (eq (char-syntax last-command-char) ?w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (sendmail-pre-abbrev-expand-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; Unhack expand-abbrev, so it will work right next time around.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (setq abbrev-start-location nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; this is gross and wasteful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (let ((abbrev-mode (if (mail-abbrev-in-expansion-header-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 abbrev-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (self-insert-command arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (defun abbrev-hacking-next-line-v18 (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (if (looking-at "[ \t]*\n") (sendmail-pre-abbrev-expand-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (setq this-command 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (next-line arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (defun abbrev-hacking-end-of-buffer-v18 (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if (looking-at "[ \t]*\n") (sendmail-pre-abbrev-expand-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (setq this-command 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (end-of-buffer arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (defvar mail-abbrevs-v18-map-munged nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (defun mail-abbrevs-v18-munge-map ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ;; For every key that is bound to self-insert-command in global-map,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;; bind that key to sendmail-self-insert-command in mail-mode-map.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;; 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
674 ;; 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
675 ;; local meta binding in the mail-mode-map made a *global* binding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;; instead. Yucko.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (let ((global-map (current-global-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 new-bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (while (< i 128)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (if (eq 'self-insert-command (or (cdr (assq i mail-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (aref global-map i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (setq new-bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (cons (cons i 'sendmail-v18-self-insert-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 new-bindings)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (setq mail-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (nconc (copy-keymap mail-mode-map) (nreverse new-bindings))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (setq mail-abbrevs-v18-map-munged t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (defun mail-aliases-setup-v18 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 "Put this on `mail-setup-hook' to use mail-abbrevs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (if (not (eq major-mode 'mail-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (or (and mail-mode-map (eq (current-local-map) mail-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (error "shut 'er down clancy, she's suckin' mud"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (if (and (not (vectorp mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (file-exists-p (mail-abbrev-mailrc-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (build-mail-aliases))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (or mail-abbrevs-v18-map-munged (mail-abbrevs-v18-munge-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (use-local-map mail-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (abbrev-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (cond ((or (string-match "^18\\." emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (and (boundp 'epoch::version) epoch::version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;; v19 (and this code) uses a new name for this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (or (fboundp 'buffer-disable-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (fset 'buffer-disable-undo 'buffer-flush-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;; v19 (and this code) uses a new name for auto-fill-hook (-function).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 ;; Encapsulate the function that uses it to bind the new name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (or (fboundp 'mail-abbrev-expand-hook-v19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (fset 'mail-abbrev-expand-hook-v19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (symbol-function 'mail-abbrev-expand-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (fset 'mail-abbrev-expand-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (let ((auto-fill-function auto-fill-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (mail-abbrev-expand-hook-v19)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 ;; Turn off the broken v18 code (that is still called from sendmail.el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (fset 'expand-mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (function (lambda (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 "Obsoleted by mail-abbrevs. Does nothing."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 ;; Redefine the abbrev-hacking functions. Yuck.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (fset 'abbrev-hacking-next-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (function (lambda (p) (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (abbrev-hacking-next-line-v18 p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (fset 'abbrev-hacking-end-of-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (function (lambda (p) (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (abbrev-hacking-end-of-buffer-v18 p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ;; Encapsulate mail-setup to do the necessary buffer initializations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (or (fboundp 'mail-setup-v18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (fset 'mail-setup-v18 (symbol-function 'mail-setup)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (fset 'mail-setup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (function (lambda (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (mail-aliases-setup-v18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (apply 'mail-setup-v18 args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 ;; Encapsulate VM's version of mail-setup as well, if vm-mail is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 ;; defined as a function or as an autoload.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (cond ((and (fboundp 'vm-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (if (eq 'autoload (car-safe (symbol-function 'vm-mail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (load (nth 1 (symbol-function 'vm-mail)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (or (fboundp 'vm-mail-internal-v18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (fset 'vm-mail-internal-v18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (symbol-function 'vm-mail-internal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (fset 'vm-mail-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (function (lambda (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (apply 'vm-mail-internal-v18 args)
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 ;; If we're being loaded from mail-setup-hook or mail-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;; as run from inside mail-setup or vm-mail-internal, then install
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 ;; right now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (if (eq major-mode 'mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (mail-aliases-setup-v18))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (t ; v19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (fmakunbound 'expand-mail-aliases)))