annotate lisp/mail/mailabbrev.el @ 15205:0f5d6cd72e21

(win_msg_worker): Use post_msg. (win32_wnd_proc): Don't abort if button_state & this, just return. Use post_msg instead of my_post_msg in some places. (win32_to_x_font): Major rewrite. (struct enumfont_t): New element logfont. (enum_font_cb2): Add special code for TRUETYPE_FONTTYPE. (Fx_list_fonts): Call x_to_win32_font.
author Richard M. Stallman <rms@gnu.org>
date Fri, 10 May 1996 20:40:49 +0000
parents 47631a15d6a2
children 1343afeec307
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
1 ;;; mailabbrev.el --- abbrev-expansion of mail aliases.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
2
14800
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
3 ;; Copyright (C) 1985, 1986, 87, 92, 93, 1996 Free Software Foundation, Inc.
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
4
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
5 ;; Author: Jamie Zawinski <jwz@lucid.com>
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
6 ;; Maintainer: Jamie Zawinski <jwz@lucid.com>
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
7 ;; Created: 19 Oct 90
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
8 ;; Keywords: mail
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
9
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
10 ;; This file is part of GNU Emacs.
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
15 ;; any later version.
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
20 ;; GNU General Public License for more details.
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
22 ;; You should have received a copy of the GNU General Public License
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
25 ;; Boston, MA 02111-1307, USA.
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
27 ;;; Commentary:
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
28
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
29 ;; This file ensures that, when the point is in a To:, CC:, BCC:, or From:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
30 ;; field, word-abbrevs are defined for each of your mail aliases. These
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
31 ;; aliases will be defined from your .mailrc file (or the file specified by
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
32 ;; the MAILRC environment variable) if it exists. Your mail aliases will
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
33 ;; expand any time you type a word-delimiter at the end of an abbreviation.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
34 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
35 ;; What you see is what you get: if mailabbrev is in use when you type
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
36 ;; a name, and the name does not expand, you know it is not an abbreviation.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
37 ;; However, if you yank abbreviations into the headers
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
38 ;; in a way that bypasses the check for abbreviations,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
39 ;; they are expanded (but not visibly) when you send the message.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
40 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
41 ;; Your mail alias abbrevs will be in effect only when the point is in an
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
42 ;; appropriate header field. When in the body of the message, or other
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
43 ;; header fields, the mail aliases will not expand. Rather, the normal
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
44 ;; mode-specific abbrev table (mail-mode-abbrev-table) will be used if
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
45 ;; defined. So if you use mail-mode specific abbrevs, this code will not
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
46 ;; adversely affect you. You can control which header fields the abbrevs
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
47 ;; are used in by changing the variable mail-abbrev-mode-regexp.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
48 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
49 ;; If auto-fill mode is on, abbrevs will wrap at commas instead of at word
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
50 ;; boundaries; also, header continuation-lines will be properly indented.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
51 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
52 ;; You can also insert a mail alias with mail-interactive-insert-alias
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
53 ;; (bound to C-c C-a), which prompts you for an alias (with completion)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
54 ;; and inserts its expansion at point.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
55 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
56 ;; This file fixes a bug in the old system which prohibited your .mailrc
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
57 ;; file from having lines like
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
58 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
59 ;; alias someone "John Doe <doe@quux.com>"
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
60 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
61 ;; That is, if you want an address to have embedded spaces, simply surround it
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
62 ;; with double-quotes. This is necessary because the format of the .mailrc
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
63 ;; file bogusly uses spaces as address delimiters. The following line defines
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
64 ;; an alias which expands to three addresses:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
65 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
66 ;; alias foobar addr-1 addr-2 "address three <addr-3>"
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
67 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
68 ;; (This is bogus because mail-delivery programs want commas, not spaces,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
69 ;; but that's what the file format is, so we have to live with it.)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
70 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
71 ;; If you like, you can call the function define-mail-abbrev to define your
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
72 ;; mail aliases instead of using a .mailrc file. When you call it in this
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
73 ;; way, addresses are separated by commas.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
74 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
75 ;; CAVEAT: This works on most Sun systems; I have been told that some versions
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
76 ;; of /bin/mail do not understand double-quotes in the .mailrc file. So you
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
77 ;; should make sure your version does before including verbose addresses like
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
78 ;; this. One solution to this, if you are on a system whose /bin/mail doesn't
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
79 ;; work that way, (and you still want to be able to /bin/mail to send mail in
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
80 ;; addition to emacs) is to define minimal aliases (without full names) in
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
81 ;; your .mailrc file, and use define-mail-abbrev to redefine them when sending
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
82 ;; mail from emacs; this way, mail sent from /bin/mail will work, and mail
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
83 ;; sent from emacs will be pretty.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
84 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
85 ;; Aliases in the mailrc file may be nested. If you define aliases like
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
86 ;; alias group1 fred ethel
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
87 ;; alias group2 larry curly moe
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
88 ;; alias everybody group1 group2
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
89 ;; Then when you type "everybody" on the To: line, it will be expanded to
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
90 ;; fred, ethyl, larry, curly, moe
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
91 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
92 ;; Aliases may also contain forward references; the alias of "everybody" can
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
93 ;; precede the aliases of "group1" and "group2".
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
94 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
95 ;; This code also understands the "source" .mailrc command, for reading
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
96 ;; aliases from some other file as well.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
97 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
98 ;; Aliases may contain hyphens, as in "alias foo-bar foo@bar"; word-abbrevs
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
99 ;; normally cannot contain hyphens, but this code works around that for the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
100 ;; specific case of mail-alias word-abbrevs.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
101 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
102 ;; To read in the contents of another .mailrc-type file from emacs, use the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
103 ;; command Meta-X merge-mail-abbrevs. The rebuild-mail-abbrevs command is
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
104 ;; similar, but will delete existing aliases first.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
105 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
106 ;; If you would like your aliases to be expanded when you type M-> or ^N to
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
107 ;; move out of the mail-header into the message body (instead of having to
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
108 ;; type SPC at the end of the abbrev before moving away) then you can do
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
109 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
110 ;; (add-hook
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
111 ;; 'mail-setup-hook
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
112 ;; '(lambda ()
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
113 ;; (substitute-key-definition 'next-line 'mail-abbrev-next-line
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
114 ;; mail-mode-map global-map)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
115 ;; (substitute-key-definition 'end-of-buffer 'mail-abbrev-end-of-buffer
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
116 ;; mail-mode-map global-map)))
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
117 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
118 ;; If you want multiple addresses separated by a string other than ", " then
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
119 ;; you can set the variable mail-alias-separator-string to it. This has to
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
120 ;; be a comma bracketed by whitespace if you want any kind of reasonable
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
121 ;; behaviour.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
122 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
123 ;; Thanks to Harald Hanche-Olsen, Michael Ernst, David Loeffler, and
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
124 ;; Noah Friedman for suggestions and bug reports.
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
125
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
126 ;; To use this package, do (add-hook 'mail-setup-hook 'mail-abbrevs-setup).
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
128 ;;; Code:
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
129
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (require 'sendmail)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;; originally defined in sendmail.el - used to be an alist, now is a table.
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
133 (defvar mail-abbrevs nil
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
134 "Word-abbrev table of mail address aliases.
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 If this is nil, it means the aliases have not yet been initialized and
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 should be read from the .mailrc file. (This is distinct from there being
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 no aliases, which is represented by this being a table with no entries.)")
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138
14800
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
139 (defvar mail-abbrev-modtime nil
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
140 "The modification time of your mail alias file when it was last examined.")
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
141
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
142 (defun mail-abbrevs-sync-aliases ()
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
143 (if (file-exists-p mail-personal-alias-file)
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
144 (let ((modtime (nth 5 (file-attributes mail-personal-alias-file))))
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
145 (if (not (equal mail-abbrev-modtime modtime))
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
146 (progn
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
147 (setq mail-abbrev-modtime modtime)
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
148 (build-mail-abbrevs))))))
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
149
474
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 459
diff changeset
150 ;;;###autoload
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
151 (defun mail-abbrevs-setup ()
14761
bef2b46521de (mail-abbrevs-setup): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
152 "Initialize use of the `mailabbrev' package."
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
153 (if (and (not (vectorp mail-abbrevs))
10328
edd33989fb23 (mail-abbrev-mailrc-file): Variable and macro deleted.
Noah Friedman <friedman@splode.com>
parents: 8215
diff changeset
154 (file-exists-p mail-personal-alias-file))
14800
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
155 (progn
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
156 (setq mail-abbrev-modtime
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
157 (nth 5 (file-attributes mail-personal-alias-file)))
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
158 (build-mail-abbrevs)))
47631a15d6a2 (mail-abbrev-modtime): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14761
diff changeset
159 (mail-abbrevs-sync-aliases)
11059
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
160 (make-local-hook 'pre-abbrev-expand-hook)
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
161 (add-hook 'pre-abbrev-expand-hook 'sendmail-pre-abbrev-expand-hook
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
162 nil t)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (abbrev-mode 1))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
165 ;;;###autoload
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
166 (defun build-mail-abbrevs (&optional file recursivep)
10328
edd33989fb23 (mail-abbrev-mailrc-file): Variable and macro deleted.
Noah Friedman <friedman@splode.com>
parents: 8215
diff changeset
167 "Read mail aliases from personal mail alias file and set `mail-abbrevs'.
edd33989fb23 (mail-abbrev-mailrc-file): Variable and macro deleted.
Noah Friedman <friedman@splode.com>
parents: 8215
diff changeset
168 By default this is the file specified by `mail-personal-alias-file'."
edd33989fb23 (mail-abbrev-mailrc-file): Variable and macro deleted.
Noah Friedman <friedman@splode.com>
parents: 8215
diff changeset
169 (setq file (expand-file-name (or file mail-personal-alias-file)))
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
170 (if (vectorp mail-abbrevs)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 nil
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
172 (setq mail-abbrevs nil)
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
173 (define-abbrev-table 'mail-abbrevs '()))
606
d9428f32691a *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 599
diff changeset
174 (message "Parsing %s..." file)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (let ((buffer nil)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (obuf (current-buffer)))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (unwind-protect
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (progn
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (setq buffer (generate-new-buffer "mailrc"))
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
180 (buffer-disable-undo buffer)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (set-buffer buffer)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (cond ((get-file-buffer file)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (insert (save-excursion
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (set-buffer (get-file-buffer file))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (buffer-substring (point-min) (point-max)))))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ((not (file-exists-p file)))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (t (insert-file-contents file)))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;; Don't lose if no final newline.
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (goto-char (point-max))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (or (eq (preceding-char) ?\n) (newline))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (goto-char (point-min))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;; Delete comments from the file
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (while (search-forward "# " nil t)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (let ((p (- (point) 2)))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (end-of-line)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (delete-region p (point))))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (goto-char (point-min))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 ;; handle "\\\n" continuation lines
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (while (not (eobp))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (end-of-line)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (if (= (preceding-char) ?\\)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (progn (delete-char -1) (delete-char 1) (insert ?\ ))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (forward-char 1)))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (goto-char (point-min))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (while (re-search-forward
907
48ca3bf4b5f8 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 846
diff changeset
206 "^\\(a\\(lias\\)?\\|g\\(roup\\)?\\|source\\)[ \t]+" nil t)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (beginning-of-line)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (if (looking-at "source[ \t]+\\([^ \t\n]+\\)")
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (progn
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (end-of-line)
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
211 (build-mail-abbrevs
3945
7a8d0a08eac7 (build-mail-abbrevs): Do substitute-in-file-name on the abbrev, for `source'.
Richard M. Stallman <rms@gnu.org>
parents: 3742
diff changeset
212 (substitute-in-file-name
7939
338a91733ff9 (build-mail-abbrevs): Pass a recursivep argument in recursive call.
Richard M. Stallman <rms@gnu.org>
parents: 5559
diff changeset
213 (buffer-substring (match-beginning 1) (match-end 1)))
338a91733ff9 (build-mail-abbrevs): Pass a recursivep argument in recursive call.
Richard M. Stallman <rms@gnu.org>
parents: 5559
diff changeset
214 t))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (re-search-forward "[ \t]+\\([^ \t\n]+\\)")
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (let* ((name (buffer-substring
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (match-beginning 1) (match-end 1)))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (start (progn (skip-chars-forward " \t") (point))))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (end-of-line)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ; (message "** %s \"%s\"" name (buffer-substring start (point)))(sit-for 1)
3742
f5bbe69b8bc5 (define-mail-abbrev): Renamed from define-mail-alias.
Richard M. Stallman <rms@gnu.org>
parents: 3741
diff changeset
221 (define-mail-abbrev
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 name
3742
f5bbe69b8bc5 (define-mail-abbrev): Renamed from define-mail-alias.
Richard M. Stallman <rms@gnu.org>
parents: 3741
diff changeset
223 (buffer-substring start (point))
f5bbe69b8bc5 (define-mail-abbrev): Renamed from define-mail-alias.
Richard M. Stallman <rms@gnu.org>
parents: 3741
diff changeset
224 t))))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 ;; Resolve forward references in .mailrc file.
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 ;; This would happen automatically before the first abbrev was
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 ;; expanded, but why not do it now.
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (or recursivep (mail-resolve-all-aliases))
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
229 mail-abbrevs)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (if buffer (kill-buffer buffer))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (set-buffer obuf)))
606
d9428f32691a *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 599
diff changeset
232 (message "Parsing %s... done" file))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233
627
59b674ceaf31 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 608
diff changeset
234 (defvar mail-alias-separator-string ", "
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 "*A string inserted between addresses in multi-address mail aliases.
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 This has to contain a comma, so \", \" is a reasonable value. You might
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 also want something like \",\\n \" to get each address on its own line.")
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
3742
f5bbe69b8bc5 (define-mail-abbrev): Renamed from define-mail-alias.
Richard M. Stallman <rms@gnu.org>
parents: 3741
diff changeset
239 ;; define-mail-abbrev sets this flag, which causes mail-resolve-all-aliases
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 ;; to be called before expanding abbrevs if it's necessary.
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (defvar mail-abbrev-aliases-need-to-be-resolved t)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
243 ;; originally defined in mailalias.el ; build-mail-abbrevs calls this with
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 ;; stuff parsed from the .mailrc file.
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ;;
474
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 459
diff changeset
246 ;;;###autoload
3742
f5bbe69b8bc5 (define-mail-abbrev): Renamed from define-mail-alias.
Richard M. Stallman <rms@gnu.org>
parents: 3741
diff changeset
247 (defun define-mail-abbrev (name definition &optional from-mailrc-file)
11059
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
248 "Define NAME as a mail alias abbrev that translates to DEFINITION.
627
59b674ceaf31 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 608
diff changeset
249 If DEFINITION contains multiple addresses, separate them with commas."
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
250 ;; When this is called from build-mail-abbrevs, the third argument is
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 ;; true, and we do some evil space->comma hacking like /bin/mail does.
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 ;; Read the defaults first, if we have not done so.
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
254 (if (vectorp mail-abbrevs)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 nil
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
256 (setq mail-abbrevs nil)
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
257 (define-abbrev-table 'mail-abbrevs '())
10328
edd33989fb23 (mail-abbrev-mailrc-file): Variable and macro deleted.
Noah Friedman <friedman@splode.com>
parents: 8215
diff changeset
258 (if (file-exists-p mail-personal-alias-file)
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
259 (build-mail-abbrevs)))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 ;; strip garbage from front and end
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (if (string-match "\\`[ \t\n,]+" definition)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (setq definition (substring definition (match-end 0))))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (if (string-match "[ \t\n,]+\\'" definition)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (setq definition (substring definition 0 (match-beginning 0))))
8215
767bef8ec35b (define-mail-abbrev): Don't try to parse empty aliases.
Richard M. Stallman <rms@gnu.org>
parents: 7939
diff changeset
265 (let* ((result '())
767bef8ec35b (define-mail-abbrev): Don't try to parse empty aliases.
Richard M. Stallman <rms@gnu.org>
parents: 7939
diff changeset
266 (L (length definition))
767bef8ec35b (define-mail-abbrev): Don't try to parse empty aliases.
Richard M. Stallman <rms@gnu.org>
parents: 7939
diff changeset
267 (start (if (> L 0) 0))
767bef8ec35b (define-mail-abbrev): Don't try to parse empty aliases.
Richard M. Stallman <rms@gnu.org>
parents: 7939
diff changeset
268 end)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (while start
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ;; If we're reading from the mailrc file, then addresses are delimited
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 ;; by spaces, and addresses with embedded spaces must be surrounded by
627
59b674ceaf31 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 608
diff changeset
272 ;; double-quotes. Otherwise, addresses are separated by commas.
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (if from-mailrc-file
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (if (eq ?\" (aref definition start))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (setq start (1+ start)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 end (string-match "\"[ \t,]*" definition start))
8215
767bef8ec35b (define-mail-abbrev): Don't try to parse empty aliases.
Richard M. Stallman <rms@gnu.org>
parents: 7939
diff changeset
277 (setq end (string-match "[ \t,]+" definition start)))
767bef8ec35b (define-mail-abbrev): Don't try to parse empty aliases.
Richard M. Stallman <rms@gnu.org>
parents: 7939
diff changeset
278 (setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (setq result (cons (substring definition start end) result))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (setq start (and end
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (/= (match-end 0) L)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (match-end 0))))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (setq definition (mapconcat (function identity)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (nreverse result)
627
59b674ceaf31 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 608
diff changeset
285 mail-alias-separator-string)))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (setq mail-abbrev-aliases-need-to-be-resolved t)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (setq name (downcase name))
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
288 ;; use an abbrev table instead of an alist for mail-abbrevs.
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (let ((abbrevs-changed abbrevs-changed)) ; protect this from being changed.
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
290 (define-abbrev mail-abbrevs name definition 'mail-abbrev-expand-hook)))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (defun mail-resolve-all-aliases ()
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 "Resolve all forward references in the mail aliases table."
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (if mail-abbrev-aliases-need-to-be-resolved
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (progn
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 ;; (message "Resolving mail aliases...")
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
298 (if (vectorp mail-abbrevs)
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
299 (mapatoms (function mail-resolve-all-aliases-1) mail-abbrevs))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (setq mail-abbrev-aliases-need-to-be-resolved nil)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ;; (message "Resolving mail aliases... done.")
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 )))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303
717
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
304 (defun mail-resolve-all-aliases-1 (sym &optional so-far)
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
305 (if (memq sym so-far)
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
306 (error "mail alias loop detected: %s"
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
307 (mapconcat 'symbol-name (cons sym so-far) " <- ")))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (let ((definition (and (boundp sym) (symbol-value sym))))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (if definition
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (let ((result '())
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (start 0))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (while start
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (let ((end (string-match "[ \t\n]*,[, \t\n]*" definition start)))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (setq result (cons (substring definition start end) result)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 start (and end (match-end 0)))))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (setq definition
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (mapconcat (function (lambda (x)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (or (mail-resolve-all-aliases-1
12444
0f96d53b31b7 (mail-resolve-all-aliases-1):
Richard M. Stallman <rms@gnu.org>
parents: 11504
diff changeset
319 (intern-soft (downcase x) mail-abbrevs)
717
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
320 (cons sym so-far))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 x)))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (nreverse result)
627
59b674ceaf31 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 608
diff changeset
323 mail-alias-separator-string))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (set sym definition))))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (symbol-value sym))
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327
627
59b674ceaf31 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 608
diff changeset
328 (defun mail-abbrev-expand-hook ()
11059
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
329 "For use as the fourth arg to `define-abbrev'.
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
330 After expanding a mail-abbrev, if Auto Fill mode is on and we're past the
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
331 fill-column, break the line at the previous comma, and indent the next line."
608
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
332 (save-excursion
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
333 (let ((p (point))
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
334 bol comma fp)
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
335 (beginning-of-line)
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
336 (setq bol (point))
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
337 (goto-char p)
606
d9428f32691a *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 599
diff changeset
338 (while (and auto-fill-function
608
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
339 (>= (current-column) fill-column)
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
340 (search-backward "," bol t))
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
341 (setq comma (point))
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
342 (forward-char 1) ; Now we are just past the comma.
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
343 (insert "\n")
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
344 (delete-horizontal-space)
627
59b674ceaf31 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 608
diff changeset
345 (setq p (point))
608
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
346 (indent-relative)
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
347 (setq fp (buffer-substring p (point)))
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
348 ;; Go to the end of the new line.
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
349 (end-of-line)
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
350 (if (> (current-column) fill-column)
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
351 ;; It's still too long; do normal auto-fill.
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
352 (let ((fill-prefix (or fp "\t")))
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
353 (do-auto-fill)))
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
354 ;; Resume the search.
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
355 (goto-char comma)
615cdef1368d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 606
diff changeset
356 ))))
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
357
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
358 ;;; Syntax tables and abbrev-expansion
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359
5559
e976a52296fc (mail-abbrev-mode-regexp): Add Reply-to.
Richard M. Stallman <rms@gnu.org>
parents: 4805
diff changeset
360 (defvar mail-abbrev-mode-regexp
e976a52296fc (mail-abbrev-mode-regexp): Add Reply-to.
Richard M. Stallman <rms@gnu.org>
parents: 4805
diff changeset
361 "^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):"
11059
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
362 "*Regexp to select mail-headers in which mail abbrevs should be expanded.
10776
52b3af3cb71a (mail-abbrev-mode-regexp): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 10328
diff changeset
363 This string will be handed to `looking-at' with point at the beginning
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 of the current line; if it matches, abbrev mode will be turned on, otherwise
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 it will be turned off. (You don't need to worry about continuation lines.)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 This should be set to match those mail fields in which you want abbreviations
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 turned on.")
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (defvar mail-mode-header-syntax-table
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (let ((tab (copy-syntax-table text-mode-syntax-table)))
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2418
diff changeset
371 ;; This makes the characters "@%!._-" be considered symbol-constituents
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 ;; but not word-constituents, so forward-sexp will move you over an
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 ;; entire address, but forward-word will only move you over a sequence
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 ;; of alphanumerics. (Clearly the right thing.)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (modify-syntax-entry ?@ "_" tab)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (modify-syntax-entry ?% "_" tab)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (modify-syntax-entry ?! "_" tab)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (modify-syntax-entry ?. "_" tab)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (modify-syntax-entry ?_ "_" tab)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (modify-syntax-entry ?- "_" tab)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (modify-syntax-entry ?< "(>" tab)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (modify-syntax-entry ?> ")<" tab)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 tab)
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
384 "The syntax table used in send-mail mode when in a mail-address header.
11059
43a05391e3e1 Various doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 10776
diff changeset
385 `mail-mode-syntax-table' is used when the cursor is in the message body or in
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
386 non-address headers.")
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
387
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
388 (defvar mail-abbrev-syntax-table
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
389 (let* ((tab (copy-syntax-table mail-mode-header-syntax-table))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
390 (_ (aref (standard-syntax-table) ?_))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
391 (w (aref (standard-syntax-table) ?w)))
13258
2a96bf08bccb (mail-abbrev-syntax-table): Rewrite using map-char-table.
Richard M. Stallman <rms@gnu.org>
parents: 13161
diff changeset
392 (map-char-table
2a96bf08bccb (mail-abbrev-syntax-table): Rewrite using map-char-table.
Richard M. Stallman <rms@gnu.org>
parents: 13161
diff changeset
393 (function (lambda (key value)
2a96bf08bccb (mail-abbrev-syntax-table): Rewrite using map-char-table.
Richard M. Stallman <rms@gnu.org>
parents: 13161
diff changeset
394 (if (equal value _)
2a96bf08bccb (mail-abbrev-syntax-table): Rewrite using map-char-table.
Richard M. Stallman <rms@gnu.org>
parents: 13161
diff changeset
395 (set-char-table-range tab key w))))
13362
1220026cd3a3 (mail-abbrev-syntax-table): Fix initialization.
Richard M. Stallman <rms@gnu.org>
parents: 13258
diff changeset
396 tab)
1220026cd3a3 (mail-abbrev-syntax-table): Fix initialization.
Richard M. Stallman <rms@gnu.org>
parents: 13258
diff changeset
397 tab)
13258
2a96bf08bccb (mail-abbrev-syntax-table): Rewrite using map-char-table.
Richard M. Stallman <rms@gnu.org>
parents: 13161
diff changeset
398 "The syntax-table used for abbrev-expansion purposes.
2a96bf08bccb (mail-abbrev-syntax-table): Rewrite using map-char-table.
Richard M. Stallman <rms@gnu.org>
parents: 13161
diff changeset
399 This is not actually made the current syntax table of the buffer, but
2a96bf08bccb (mail-abbrev-syntax-table): Rewrite using map-char-table.
Richard M. Stallman <rms@gnu.org>
parents: 13161
diff changeset
400 simply controls the set of characters which may be a part of the name
2a96bf08bccb (mail-abbrev-syntax-table): Rewrite using map-char-table.
Richard M. Stallman <rms@gnu.org>
parents: 13161
diff changeset
401 of a mail alias.")
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
402
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
404 (defun mail-abbrev-in-expansion-header-p ()
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
405 "Whether point is in a mail-address header field."
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
406 (let ((case-fold-search t))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
407 (and ;;
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
408 ;; we are on an appropriate header line...
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
409 (save-excursion
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
410 (beginning-of-line)
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
411 ;; skip backwards over continuation lines.
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
412 (while (and (looking-at "^[ \t]")
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
413 (not (= (point) (point-min))))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
414 (forward-line -1))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
415 ;; are we at the front of an appropriate header line?
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
416 (looking-at mail-abbrev-mode-regexp))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
417 ;;
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
418 ;; ...and we are before the mail-header-separator
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
419 (< (point)
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
420 (save-excursion
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
421 (goto-char (point-min))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
422 (search-forward (concat "\n" mail-header-separator "\n")
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
423 nil 0)
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
424 (point))))))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
425
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
426 (defvar mail-mode-abbrev-table) ; quiet the compiler
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
427
627
59b674ceaf31 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 608
diff changeset
428 (defun sendmail-pre-abbrev-expand-hook ()
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
429 (and (and mail-abbrevs (not (eq mail-abbrevs t)))
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
430 (if (mail-abbrev-in-expansion-header-p)
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
431 (progn
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
432 ;;
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
433 ;; We are in a To: (or CC:, or whatever) header, and
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
434 ;; should use word-abbrevs to expand mail aliases.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
435
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
436 ;; Before anything else, resolve aliases if they need it.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
437 (and mail-abbrev-aliases-need-to-be-resolved
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
438 (mail-resolve-all-aliases))
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
439
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
440 ;; Now proceed with the abbrev section.
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
441 ;; - First, install the mail-abbrevs as the word-abbrev table.
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
442 ;; - Then install the mail-abbrev-syntax-table, which
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
443 ;; temporarily marks all of the
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
444 ;; non-alphanumeric-atom-characters (the "_"
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
445 ;; syntax ones) as being normal word-syntax. We do this
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
446 ;; because the C code for expand-abbrev only works on words,
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
447 ;; and we want these characters to be considered words for
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
448 ;; the purpose of abbrev expansion.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
449 ;; - Then we call expand-abbrev again, recursively, to do
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
450 ;; the abbrev expansion with the above syntax table.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
451 ;; - Then we do a trick which tells the expand-abbrev frame
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
452 ;; which invoked us to not continue (and thus not
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
453 ;; expand twice.) This means that any abbrev expansion
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
454 ;; will happen as a result of this function's call to
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
455 ;; expand-abbrev, and not as a result of the call to
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
456 ;; expand-abbrev which invoked *us*.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
457 ;; - Then we set the syntax table to
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
458 ;; mail-mode-header-syntax-table, which doesn't have
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
459 ;; anything to do with abbrev expansion, but
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
460 ;; is just for the user's convenience (see its doc string.)
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
461 ;;
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
462
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
463 (setq local-abbrev-table mail-abbrevs)
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
464
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
465 ;; If the character just typed was non-alpha-symbol-syntax,
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
466 ;; then don't expand the abbrev now (that is, don't expand
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
467 ;; when the user types -.) Check the character's syntax in
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
468 ;; the mail-mode-header-syntax-table.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
469
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
470 (set-syntax-table mail-mode-header-syntax-table)
3668
87f7ff6bba51 (sendmail-pre-abbrev-expand-hook):
Richard M. Stallman <rms@gnu.org>
parents: 3664
diff changeset
471 (or (and (integerp last-command-char)
87f7ff6bba51 (sendmail-pre-abbrev-expand-hook):
Richard M. Stallman <rms@gnu.org>
parents: 3664
diff changeset
472 (eq (char-syntax last-command-char) ?_))
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
473 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
474 ;; Use this table so that abbrevs can have hyphens in them.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
475 (set-syntax-table mail-abbrev-syntax-table)
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
476 (expand-abbrev)
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
477 ;; Now set it back to what it was before.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
478 (set-syntax-table mail-mode-header-syntax-table)))
11504
ae5b033ad31f (sendmail-pre-abbrev-expand-hook): When setting the
Karl Heuer <kwzh@gnu.org>
parents: 11059
diff changeset
479 (setq abbrev-start-location (point-max) ; This is the trick.
1148
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
480 abbrev-start-location-buffer (current-buffer)))
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
481
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
482 ;; We're not in a mail header where mail aliases should
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
483 ;; be expanded, then use the normal mail-mode abbrev table
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
484 ;; (if any) and the normal mail-mode syntax table.
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
485
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
486 (setq local-abbrev-table (and (boundp 'mail-mode-abbrev-table)
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
487 mail-mode-abbrev-table))
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
488 (set-syntax-table mail-mode-syntax-table))
b32ae4969b78 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1147
diff changeset
489 ))
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
490
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
491 ;;; utilities
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
493 (defun merge-mail-abbrevs (file)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 "Merge mail aliases from the given file with existing ones."
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (interactive (list
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (let ((insert-default-directory t)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (default-directory (expand-file-name "~/"))
10328
edd33989fb23 (mail-abbrev-mailrc-file): Variable and macro deleted.
Noah Friedman <friedman@splode.com>
parents: 8215
diff changeset
498 (def mail-personal-alias-file))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (read-file-name
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (format "Read additional aliases from file: (default %s) "
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 def)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 default-directory
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (expand-file-name def default-directory)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 t))))
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
505 (build-mail-abbrevs file))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506
12945
14e16370799d (rebuild-mail-abbrevs): FILE defaults to visited file.
Richard M. Stallman <rms@gnu.org>
parents: 12444
diff changeset
507 (defun rebuild-mail-abbrevs (&optional file)
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 "Rebuild all the mail aliases from the given file."
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (interactive (list
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (let ((insert-default-directory t)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (default-directory (expand-file-name "~/"))
10328
edd33989fb23 (mail-abbrev-mailrc-file): Variable and macro deleted.
Noah Friedman <friedman@splode.com>
parents: 8215
diff changeset
512 (def mail-personal-alias-file))
459
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (read-file-name
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (format "Read mail aliases from file: (default %s) " def)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 default-directory
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (expand-file-name def default-directory)
a4742d1b81bc Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 t))))
12945
14e16370799d (rebuild-mail-abbrevs): FILE defaults to visited file.
Richard M. Stallman <rms@gnu.org>
parents: 12444
diff changeset
518 (if (null file)
14e16370799d (rebuild-mail-abbrevs): FILE defaults to visited file.
Richard M. Stallman <rms@gnu.org>
parents: 12444
diff changeset
519 (setq file buffer-file-name))
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
520 (setq mail-abbrevs nil)
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
521 (build-mail-abbrevs file))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 474
diff changeset
522
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
523 (defun mail-interactive-insert-alias (&optional alias)
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
524 "Prompt for and insert a mail alias."
907
48ca3bf4b5f8 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 846
diff changeset
525 (interactive (progn
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
526 (if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup))
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
527 (list (completing-read "Expand alias: " mail-abbrevs nil t))))
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
528 (if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup))
13000
a86ad056a1cd (mail-interactive-insert-alias): Call mail-abbrev-expand-hook.
Richard M. Stallman <rms@gnu.org>
parents: 12956
diff changeset
529 (insert (or (and alias (symbol-value (intern-soft alias mail-abbrevs))) ""))
a86ad056a1cd (mail-interactive-insert-alias): Call mail-abbrev-expand-hook.
Richard M. Stallman <rms@gnu.org>
parents: 12956
diff changeset
530 (mail-abbrev-expand-hook))
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
531
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
532 (defun mail-abbrev-next-line (&optional arg)
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
533 "Expand any mail abbrev, then move cursor vertically down ARG lines.
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
534 If there is no character in the target line exactly under the current column,
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
535 the cursor is positioned after the character in that line which spans this
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
536 column, or at the end of the line if it is not long enough.
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
537 If there is no line in the buffer after this one,
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
538 a newline character is inserted to create a line
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
539 and the cursor moves to that line.
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
540
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
541 The command \\[set-goal-column] can be used to create
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
542 a semipermanent goal column to which this command always moves.
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
543 Then it does not try to move vertically. This goal column is stored
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
544 in `goal-column', which is nil when there is none.
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
545
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
546 If you are thinking of using this in a Lisp program, consider
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
547 using `forward-line' instead. It is usually easier to use
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
548 and more reliable (no dependence on goal column, etc.)."
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
549 (interactive "p")
717
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
550 (if (looking-at "[ \t]*\n") (expand-abbrev))
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
551 (setq this-command 'next-line)
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
552 (next-line arg))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
553
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
554 (defun mail-abbrev-end-of-buffer (&optional arg)
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
555 "Expand any mail abbrev, then move point to end of buffer.
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
556 Leave mark at previous position.
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
557 With arg N, put point N/10 of the way from the true end.
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
558
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
559 Don't use this command in Lisp programs!
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
560 \(goto-char (point-max)) is faster and avoids clobbering the mark."
4034
9e585b42806d (mail-abbrev-end-of-buffer): Fix interactive spec to "P", same as
Roland McGrath <roland@gnu.org>
parents: 3945
diff changeset
561 (interactive "P")
717
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
562 (if (looking-at "[ \t]*\n") (expand-abbrev))
950a63133bc4 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 669
diff changeset
563 (setq this-command 'end-of-buffer)
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
564 (end-of-buffer arg))
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
565
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
566 (define-key mail-mode-map "\C-c\C-a" 'mail-interactive-insert-alias)
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
567
1432
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
568 ;;(define-key mail-mode-map "\C-n" 'mail-abbrev-next-line)
7446ab662993 Delete version 18 compatibility stuff.
Richard M. Stallman <rms@gnu.org>
parents: 1150
diff changeset
569 ;;(define-key mail-mode-map "\M->" 'mail-abbrev-end-of-buffer)
598
75b23846ac96 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 584
diff changeset
570
2418
3af5c7b9f4a1 Provide mailabbrev, not mail-abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 1832
diff changeset
571 (provide 'mailabbrev)
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
572
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13815
diff changeset
573 ;;; mailabbrev.el ends here.