Mercurial > emacs
annotate lisp/mail/mailalias.el @ 17405:1c2363f760ef
Add defgroup's; change use defcustom for user vars.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 12 Apr 1997 01:50:50 +0000 |
parents | 9c0ece61d60a |
children | 7faea977229c |
rev | line source |
---|---|
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1 ;;; mailalias.el --- expand and complete mailing address aliases |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
474
diff
changeset
|
2 |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
3 ;; Copyright (C) 1985, 1987, 1995, 1996, 1997 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
5 ;; Maintainer: FSF |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: mail |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
7 |
53 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
53 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
53 | 24 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1448
diff
changeset
|
25 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1448
diff
changeset
|
26 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1448
diff
changeset
|
27 ;; Basic functions for defining and expanding mail aliases. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1448
diff
changeset
|
28 ;; These seal off the interface to the alias-definition parts of a |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1448
diff
changeset
|
29 ;; .mailrc file formatted for BSD's Mail or USL's mailx. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1448
diff
changeset
|
30 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
31 ;;; Code: |
53 | 32 |
8801
eee06aef6f56
Require sendmail. Delete redundant defvar.
Karl Heuer <kwzh@gnu.org>
parents:
8494
diff
changeset
|
33 (require 'sendmail) |
1448
99fb20ef1a17
(mail-aliases): Add definition here.
Richard M. Stallman <rms@gnu.org>
parents:
1434
diff
changeset
|
34 |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
35 (defvar mail-names t |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
36 "Alist of local users, aliases and directory entries as available. |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
37 Elements have the form (MAILNAME) or (MAILNAME . FULLNAME). |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
38 If the value means t, it means the real value should be calculated |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
39 for the next use. this is used in `mail-complete'.") |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
40 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
41 (defvar mail-local-names t |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
42 "Alist of local users. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
43 When t this still needs to be initialized.") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
44 |
17210
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
45 (defvar mail-passwd-files '("/etc/passwd") |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
46 "List of files from which to determine valid user names.") |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
47 |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
48 (defvar mail-passwd-command nil |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
49 "Shell command to retrieve text to add to `/etc/passwd', or nil.") |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
50 |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
51 (defvar mail-directory-names t |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 "Alist of mail address directory entries. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
53 When t this still needs to be initialized.") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
54 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 (defvar mail-address-field-regexp |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
56 "^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
58 (defvar mail-complete-alist |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 `((,mail-address-field-regexp mail-get-names pattern) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 ("Newsgroups:" . (if (boundp 'gnus-active-hashtb) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
61 gnus-active-hashtb |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
62 (if (boundp news-group-article-assoc) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
63 news-group-article-assoc))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
64 ("Followup-To:" . (mail-sentto-newsgroups)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
65 ;;("Distribution:" ???) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 ) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
67 "Alist of header field and expression to return alist for completion. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
68 Expression may reference variable `pattern' which is the string being completed. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
69 If not on matching header, `mail-complete-function' gets called instead.") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
70 |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
71 ;;;###autoload |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
72 (defvar mail-complete-style 'angles |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
73 "*Specifies how \\[mail-complete] formats the full name when it completes. |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
74 If `nil', they contain just the return address like: |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
75 king@grassland.com |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
76 If `parens', they look like: |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
77 king@grassland.com (Elvis Parsley) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
78 If `angles', they look like: |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
79 Elvis Parsley <king@grassland.com>") |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
80 |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
81 (defvar mail-complete-function 'ispell-complete-word |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
82 "Function to call when completing outside `mail-complete-alist'-header.") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
83 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
84 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
85 (defvar mail-directory-function nil |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
86 "Function to get completions from directory service or `nil' for none. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
87 See `mail-directory-requery'.") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
88 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
89 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
90 ;; This is for when the directory is huge, or changes frequently. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
91 (defvar mail-directory-requery nil |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
92 "When non-`nil' call `mail-directory-function' for each completion. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
93 In that case, one argument gets passed to the function, the partial string |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
94 entered so far.") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
95 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
96 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
97 (defvar mail-directory-process nil |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
98 "Unix command when `mail-directory-function' is `mail-directory-process'. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
99 This is a list of the form (COMMAND ARG ...), where each of the list elements |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
100 is evaluated. When `mail-directory-requery' is non-`nil', during |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
101 evaluation the variable `pattern' contains the partial input being completed. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
102 This might look like |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
103 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
104 '(remote-shell-program \"HOST\" \"-nl\" \"USER\" \"COMMAND\") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
105 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
106 or |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
107 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
108 '(remote-shell-program \"HOST\" \"-n\" \"COMMAND '^\" pattern \"'\")") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
109 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
110 (defvar mail-directory-stream () |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
111 "List of (HOST SERVICE) for stream connection to mail directory.") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
112 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
113 (defvar mail-directory-parser nil |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
114 "How to interpret the output of `mail-directory-function'. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
115 Three types of values are possible: |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
116 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
117 - nil means to gather each line as one name |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
118 - regexp means first \\(grouping\\) in successive matches is name |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
119 - function called at beginning of buffer that returns an alist of names") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
120 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
121 |
53 | 122 ;; Called from sendmail-send-it, or similar functions, |
123 ;; only if some mail aliases are defined. | |
124 (defun expand-mail-aliases (beg end &optional exclude) | |
125 "Expand all mail aliases in suitable header fields found between BEG and END. | |
11856
abf2dbc46f7d
(expand-mail-aliases): Expand aliases in
Karl Heuer <kwzh@gnu.org>
parents:
11639
diff
changeset
|
126 Suitable header fields are `To', `From', `CC' and `BCC', `Reply-to', and |
abf2dbc46f7d
(expand-mail-aliases): Expand aliases in
Karl Heuer <kwzh@gnu.org>
parents:
11639
diff
changeset
|
127 their `Resent-' variants. |
abf2dbc46f7d
(expand-mail-aliases): Expand aliases in
Karl Heuer <kwzh@gnu.org>
parents:
11639
diff
changeset
|
128 |
221
ce8e0192266e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
219
diff
changeset
|
129 Optional second arg EXCLUDE may be a regular expression defining text to be |
ce8e0192266e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
219
diff
changeset
|
130 removed from alias expansions." |
14038
49642146f16c
(expand-mail-aliases, define-mail-alias): Fix calls to `sendmail-sync-aliases'
Karl Heuer <kwzh@gnu.org>
parents:
13653
diff
changeset
|
131 (sendmail-sync-aliases) |
53 | 132 (if (eq mail-aliases t) |
133 (progn (setq mail-aliases nil) (build-mail-aliases))) | |
134 (goto-char beg) | |
135 (setq end (set-marker (make-marker) end)) | |
136 (let ((case-fold-search nil)) | |
137 (while (let ((case-fold-search t)) | |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
138 (re-search-forward mail-address-field-regexp end t)) |
53 | 139 (skip-chars-forward " \t") |
140 (let ((beg1 (point)) | |
141 end1 pos epos seplen | |
142 ;; DISABLED-ALIASES records aliases temporarily disabled | |
143 ;; while we scan text that resulted from expanding those aliases. | |
144 ;; Each element is (ALIAS . TILL-WHEN), where TILL-WHEN | |
145 ;; is where to reenable the alias (expressed as number of chars | |
146 ;; counting from END1). | |
147 (disabled-aliases nil)) | |
148 (re-search-forward "^[^ \t]" end 'move) | |
149 (beginning-of-line) | |
150 (skip-chars-backward " \t\n") | |
151 (setq end1 (point-marker)) | |
152 (goto-char beg1) | |
153 (while (< (point) end1) | |
154 (setq pos (point)) | |
155 ;; Reenable any aliases which were disabled for ranges | |
156 ;; that we have passed out of. | |
157 (while (and disabled-aliases (> pos (- end1 (cdr (car disabled-aliases))))) | |
158 (setq disabled-aliases (cdr disabled-aliases))) | |
159 ;; EPOS gets position of end of next name; | |
160 ;; SEPLEN gets length of whitespace&separator that follows it. | |
161 (if (re-search-forward "[ \t]*[\n,][ \t]*" end1 t) | |
162 (setq epos (match-beginning 0) | |
163 seplen (- (point) epos)) | |
164 (setq epos (marker-position end1) seplen 0)) | |
165 (let (translation | |
11639
462d55b84265
(expand-mail-aliases): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
parents:
10327
diff
changeset
|
166 (string (buffer-substring-no-properties pos epos))) |
53 | 167 (if (and (not (assoc string disabled-aliases)) |
168 (setq translation | |
169 (cdr (assoc string mail-aliases)))) | |
170 (progn | |
171 ;; This name is an alias. Disable it. | |
172 (setq disabled-aliases (cons (cons string (- end1 epos)) | |
173 disabled-aliases)) | |
174 ;; Replace the alias with its expansion | |
175 ;; then rescan the expansion for more aliases. | |
176 (goto-char pos) | |
177 (insert translation) | |
178 (if exclude | |
179 (let ((regexp | |
180 (concat "\\b\\(" exclude "\\)\\b")) | |
181 (end (point-marker))) | |
182 (goto-char pos) | |
183 (while (re-search-forward regexp end t) | |
184 (replace-match "")) | |
185 (goto-char end))) | |
186 (delete-region (point) (+ (point) (- epos pos))) | |
187 (goto-char pos)) | |
188 ;; Name is not an alias. Skip to start of next name. | |
189 (goto-char epos) | |
190 (forward-char seplen)))) | |
191 (set-marker end1 nil))) | |
192 (set-marker end nil))) | |
193 | |
10327
8822b968b11c
Use `mail-personal-alias-file' globally in place of hardwired "~/.mailrc".
Noah Friedman <friedman@splode.com>
parents:
9644
diff
changeset
|
194 ;; Called by mail-setup, or similar functions, only if the file specified |
8822b968b11c
Use `mail-personal-alias-file' globally in place of hardwired "~/.mailrc".
Noah Friedman <friedman@splode.com>
parents:
9644
diff
changeset
|
195 ;; by mail-personal-alias-file (usually `~/.mailrc') exists. |
53 | 196 (defun build-mail-aliases (&optional file) |
10327
8822b968b11c
Use `mail-personal-alias-file' globally in place of hardwired "~/.mailrc".
Noah Friedman <friedman@splode.com>
parents:
9644
diff
changeset
|
197 "Read mail aliases from personal aliases file and set `mail-aliases'. |
8822b968b11c
Use `mail-personal-alias-file' globally in place of hardwired "~/.mailrc".
Noah Friedman <friedman@splode.com>
parents:
9644
diff
changeset
|
198 By default, this is the file specified by `mail-personal-alias-file'." |
8822b968b11c
Use `mail-personal-alias-file' globally in place of hardwired "~/.mailrc".
Noah Friedman <friedman@splode.com>
parents:
9644
diff
changeset
|
199 (setq file (expand-file-name (or file mail-personal-alias-file))) |
53 | 200 (let ((buffer nil) |
201 (obuf (current-buffer))) | |
202 (unwind-protect | |
203 (progn | |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
204 (setq buffer (generate-new-buffer " mailrc")) |
53 | 205 (set-buffer buffer) |
7732
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
206 (while file |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
207 (cond ((get-file-buffer file) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
208 (insert (save-excursion |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
209 (set-buffer (get-file-buffer file)) |
13653
acde2327c000
(build-mail-aliases): Use buffer-substring-no-properties not buffer-substring.
Richard M. Stallman <rms@gnu.org>
parents:
12516
diff
changeset
|
210 (buffer-substring-no-properties |
acde2327c000
(build-mail-aliases): Use buffer-substring-no-properties not buffer-substring.
Richard M. Stallman <rms@gnu.org>
parents:
12516
diff
changeset
|
211 (point-min) (point-max))))) |
7732
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
212 ((file-exists-p file) (insert-file-contents file)) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
213 ((file-exists-p (setq file (concat "~/" file))) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
214 (insert-file-contents file)) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
215 (t (setq file nil))) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
216 ;; Don't lose if no final newline. |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
217 (goto-char (point-max)) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
218 (or (eq (preceding-char) ?\n) (newline)) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
219 (goto-char (point-min)) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
220 ;; handle "\\\n" continuation lines |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
221 (while (not (eobp)) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
222 (end-of-line) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
223 (if (= (preceding-char) ?\\) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
224 (progn (delete-char -1) (delete-char 1) (insert ?\ )) |
53 | 225 (forward-char 1))) |
7732
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
226 (goto-char (point-min)) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
227 ;; handle `source' directives -- Eddy/1994/May/25 |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
228 (cond ((re-search-forward "^source[ \t]+" nil t) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
229 (re-search-forward "\\S-+") |
13653
acde2327c000
(build-mail-aliases): Use buffer-substring-no-properties not buffer-substring.
Richard M. Stallman <rms@gnu.org>
parents:
12516
diff
changeset
|
230 (setq file (buffer-substring-no-properties |
acde2327c000
(build-mail-aliases): Use buffer-substring-no-properties not buffer-substring.
Richard M. Stallman <rms@gnu.org>
parents:
12516
diff
changeset
|
231 (match-beginning 0) (match-end 0))) |
7732
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
232 (beginning-of-line) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
233 (insert "# ") ; to ensure we don't re-process this file |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
234 (beginning-of-line)) |
b99162ca5247
(build-mail-aliases): Handle source directives.
Richard M. Stallman <rms@gnu.org>
parents:
3743
diff
changeset
|
235 (t (setq file nil)))) |
53 | 236 (goto-char (point-min)) |
12516
254987dd395f
* mailalias.el (build-mail-aliases): Fixed the regexp for "^group".
Francesco Potortì <pot@gnu.org>
parents:
12448
diff
changeset
|
237 (while (re-search-forward |
254987dd395f
* mailalias.el (build-mail-aliases): Fixed the regexp for "^group".
Francesco Potortì <pot@gnu.org>
parents:
12448
diff
changeset
|
238 "^\\(a\\|alias\\|g\\|group\\)[ \t]+\\([^ \t]+\\)" nil t) |
254987dd395f
* mailalias.el (build-mail-aliases): Fixed the regexp for "^group".
Francesco Potortì <pot@gnu.org>
parents:
12448
diff
changeset
|
239 (let* ((name (match-string 2)) |
53 | 240 (start (progn (skip-chars-forward " \t") (point)))) |
241 (end-of-line) | |
242 (define-mail-alias | |
243 name | |
13653
acde2327c000
(build-mail-aliases): Use buffer-substring-no-properties not buffer-substring.
Richard M. Stallman <rms@gnu.org>
parents:
12516
diff
changeset
|
244 (buffer-substring-no-properties start (point)) |
7971
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
245 t))) |
53 | 246 mail-aliases) |
247 (if buffer (kill-buffer buffer)) | |
248 (set-buffer obuf)))) | |
249 | |
250 ;; Always autoloadable in case the user wants to define aliases | |
251 ;; interactively or in .emacs. | |
256 | 252 ;;;###autoload |
7971
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
253 (defun define-mail-alias (name definition &optional from-mailrc-file) |
221
ce8e0192266e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
219
diff
changeset
|
254 "Define NAME as a mail alias that translates to DEFINITION. |
53 | 255 This means that sending a message to NAME will actually send to DEFINITION. |
12448
7291d1627d2c
(define-mail-alias): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11856
diff
changeset
|
256 |
7291d1627d2c
(define-mail-alias): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11856
diff
changeset
|
257 Normally, the addresses in DEFINITION must be separated by commas. |
7291d1627d2c
(define-mail-alias): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11856
diff
changeset
|
258 If FROM-MAILRC-FILE is non-nil, then addresses in DEFINITION |
7291d1627d2c
(define-mail-alias): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11856
diff
changeset
|
259 can be separated by spaces; an address can contain spaces |
7291d1627d2c
(define-mail-alias): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11856
diff
changeset
|
260 if it is quoted with double-quotes." |
7291d1627d2c
(define-mail-alias): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11856
diff
changeset
|
261 |
53 | 262 (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ") |
263 ;; Read the defaults first, if we have not done so. | |
14038
49642146f16c
(expand-mail-aliases, define-mail-alias): Fix calls to `sendmail-sync-aliases'
Karl Heuer <kwzh@gnu.org>
parents:
13653
diff
changeset
|
264 (sendmail-sync-aliases) |
53 | 265 (if (eq mail-aliases t) |
266 (progn | |
267 (setq mail-aliases nil) | |
10327
8822b968b11c
Use `mail-personal-alias-file' globally in place of hardwired "~/.mailrc".
Noah Friedman <friedman@splode.com>
parents:
9644
diff
changeset
|
268 (if (file-exists-p mail-personal-alias-file) |
53 | 269 (build-mail-aliases)))) |
3743
e67f922b73ed
(define-mail-alias): Remove excess whitespace better.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
270 ;; strip garbage from front and end |
e67f922b73ed
(define-mail-alias): Remove excess whitespace better.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
271 (if (string-match "\\`[ \t\n,]+" definition) |
474 | 272 (setq definition (substring definition (match-end 0)))) |
3743
e67f922b73ed
(define-mail-alias): Remove excess whitespace better.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
273 (if (string-match "[ \t\n,]+\\'" definition) |
474 | 274 (setq definition (substring definition 0 (match-beginning 0)))) |
7971
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
275 (let ((result '()) |
8494
ae554ccf4fb5
(define-mail-alias): Avoid error if DEFINITION is "".
Richard M. Stallman <rms@gnu.org>
parents:
7971
diff
changeset
|
276 ;; If DEFINITION is null string, avoid looping even once. |
ae554ccf4fb5
(define-mail-alias): Avoid error if DEFINITION is "".
Richard M. Stallman <rms@gnu.org>
parents:
7971
diff
changeset
|
277 (start (and (not (equal definition "")) 0)) |
7971
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
278 (L (length definition)) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
279 end tem) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
280 (while start |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
281 ;; If we're reading from the mailrc file, then addresses are delimited |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
282 ;; by spaces, and addresses with embedded spaces must be surrounded by |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
283 ;; double-quotes. Otherwise, addresses are separated by commas. |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
284 (if from-mailrc-file |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
285 (if (eq ?\" (aref definition start)) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
286 (setq start (1+ start) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
287 end (string-match "\"[ \t,]*" definition start)) |
8494
ae554ccf4fb5
(define-mail-alias): Avoid error if DEFINITION is "".
Richard M. Stallman <rms@gnu.org>
parents:
7971
diff
changeset
|
288 (setq end (string-match "[ \t,]+" definition start))) |
ae554ccf4fb5
(define-mail-alias): Avoid error if DEFINITION is "".
Richard M. Stallman <rms@gnu.org>
parents:
7971
diff
changeset
|
289 (setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start))) |
7971
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
290 (setq result (cons (substring definition start end) result)) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
291 (setq start (and end |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
292 (/= (match-end 0) L) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
293 (match-end 0)))) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
294 (setq definition (mapconcat (function identity) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
295 (nreverse result) |
e02c5d5d76cd
(define-mail-alias): Copy parsing code from mailabbrev.el.
Richard M. Stallman <rms@gnu.org>
parents:
7970
diff
changeset
|
296 ", ")) |
53 | 297 (setq tem (assoc name mail-aliases)) |
298 (if tem | |
299 (rplacd tem definition) | |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
300 (setq mail-aliases (cons (cons name definition) mail-aliases) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
301 mail-names t)))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
302 |
14678
f77d51b836d0
(mail-complete): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
14551
diff
changeset
|
303 ;;;###autoload |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
304 (defun mail-complete (arg) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
305 "Perform completion on header field or word preceding point. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
306 Completable headers are according to `mail-complete-alist'. If none matches |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
307 current header, calls `mail-complete-function' and passes prefix arg if any." |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
308 (interactive "P") |
15501
3cc16244b779
Resync mail aliases if necessary.
Simon Marshall <simon@gnu.org>
parents:
14799
diff
changeset
|
309 ;; Read the defaults first, if we have not done so. |
3cc16244b779
Resync mail aliases if necessary.
Simon Marshall <simon@gnu.org>
parents:
14799
diff
changeset
|
310 (sendmail-sync-aliases) |
3cc16244b779
Resync mail aliases if necessary.
Simon Marshall <simon@gnu.org>
parents:
14799
diff
changeset
|
311 (if (eq mail-aliases t) |
3cc16244b779
Resync mail aliases if necessary.
Simon Marshall <simon@gnu.org>
parents:
14799
diff
changeset
|
312 (progn |
3cc16244b779
Resync mail aliases if necessary.
Simon Marshall <simon@gnu.org>
parents:
14799
diff
changeset
|
313 (setq mail-aliases nil) |
3cc16244b779
Resync mail aliases if necessary.
Simon Marshall <simon@gnu.org>
parents:
14799
diff
changeset
|
314 (if (file-exists-p mail-personal-alias-file) |
3cc16244b779
Resync mail aliases if necessary.
Simon Marshall <simon@gnu.org>
parents:
14799
diff
changeset
|
315 (build-mail-aliases)))) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
316 (let ((list mail-complete-alist)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
317 (if (and (save-excursion (search-forward |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
318 (concat "\n" mail-header-separator "\n") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
319 nil t)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
320 (save-excursion |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
321 (if (re-search-backward "^[^\t]" nil t) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
322 (while list |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
323 (if (looking-at (car (car list))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
324 (setq arg (cdr (car list)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
325 list ()) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
326 (setq list (cdr list))))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
327 arg)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
328 (let* ((end (point)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
329 (beg (save-excursion |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
330 (skip-chars-backward "^ \t<,:") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
331 (point))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
332 (pattern (buffer-substring beg end)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
333 completion) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
334 (setq list (eval arg) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
335 completion (try-completion pattern list)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
336 (cond ((eq completion t)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
337 ((null completion) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
338 (message "Can't find completion for \"%s\"" pattern) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
339 (ding)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
340 ((not (string= pattern completion)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
341 (delete-region beg end) |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
342 (let ((alist-elt (assoc completion mail-names))) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
343 (if (cdr alist-elt) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
344 (cond ((eq mail-complete-style 'parens) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
345 (insert completion " (" (cdr alist-elt) ")")) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
346 ((eq mail-complete-style 'angles) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
347 (insert (cdr alist-elt) " <" completion ">")) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
348 (t |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
349 (insert completion))) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
350 (insert completion)))) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
351 (t |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
352 (message "Making completion list...") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
353 (with-output-to-temp-buffer "*Completions*" |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
354 (display-completion-list |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
355 (all-completions pattern list))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
356 (message "Making completion list...%s" "done")))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
357 (funcall mail-complete-function arg)))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
358 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
359 (defun mail-get-names (pattern) |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
360 "Fetch local users and global mail addresses for completion. |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
361 Consults `/etc/passwd' and a directory service if one is set up via |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
362 `mail-directory-function'. |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
363 PATTERN is the string we want to complete." |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
364 (if (eq mail-local-names t) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
365 (save-excursion |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
366 (set-buffer (generate-new-buffer " passwd")) |
17210
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
367 (let ((files mail-passwd-files)) |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
368 (while files |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
369 (insert-file-contents (car files) nil nil nil t) |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
370 (setq files (cdr files)))) |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
371 (if mail-passwd-command |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
372 (call-process shell-file-name nil t nil |
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
373 shell-command-switch mail-passwd-command)) |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
374 (beginning-of-buffer) |
17210
5c7c572f57f8
(mail-passwd-command): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15501
diff
changeset
|
375 (setq mail-local-names nil) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
376 (while (not (eobp)) |
14799
619266555aec
(mail-get-names): Understand "+username" format for /etc/passwd lines.
Richard M. Stallman <rms@gnu.org>
parents:
14678
diff
changeset
|
377 ;;Recognize lines like |
619266555aec
(mail-get-names): Understand "+username" format for /etc/passwd lines.
Richard M. Stallman <rms@gnu.org>
parents:
14678
diff
changeset
|
378 ;; nobody:*:65534:65534::/: |
619266555aec
(mail-get-names): Understand "+username" format for /etc/passwd lines.
Richard M. Stallman <rms@gnu.org>
parents:
14678
diff
changeset
|
379 ;; +demo::::::/bin/csh |
619266555aec
(mail-get-names): Understand "+username" format for /etc/passwd lines.
Richard M. Stallman <rms@gnu.org>
parents:
14678
diff
changeset
|
380 ;; +ethanb |
619266555aec
(mail-get-names): Understand "+username" format for /etc/passwd lines.
Richard M. Stallman <rms@gnu.org>
parents:
14678
diff
changeset
|
381 ;;while skipping |
619266555aec
(mail-get-names): Understand "+username" format for /etc/passwd lines.
Richard M. Stallman <rms@gnu.org>
parents:
14678
diff
changeset
|
382 ;; +@SOFTWARE |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
383 ;; The second \(...\) matches the user id. |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
384 (if (looking-at "\\+?\\([^:@\n+]+\\):[^:\n]*:\\([^\n:]*\\):") |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
385 (add-to-list 'mail-local-names |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
386 (cons (match-string 1) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
387 (user-full-name |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
388 (string-to-int (match-string 2)))))) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
389 (beginning-of-line 2)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
390 (kill-buffer (current-buffer)))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
391 (if (or (eq mail-names t) |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
392 (eq mail-directory-names t)) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
393 (let (directory) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
394 (and mail-directory-function |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
395 (eq mail-directory-names t) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
396 (setq directory |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
397 (mail-directory (if mail-directory-requery pattern)))) |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
398 (or mail-directory-requery |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
399 (setq mail-directory-names directory)) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
400 (if (or directory |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
401 (eq mail-names t)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
402 (setq mail-names |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
403 (sort (append (if (consp mail-aliases) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
404 (mapcar |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
405 (function (lambda (a) (list (car a)))) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
406 mail-aliases)) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
407 (if (consp mail-local-names) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
408 mail-local-names) |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
409 (or directory mail-directory-names)) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
410 (lambda (a b) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
411 ;; should cache downcased strings |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
412 (string< (downcase (car a)) |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
413 (downcase (car b))))))))) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
414 mail-names) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
415 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
416 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
417 (defun mail-directory (pattern) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
418 "Call directory to get names matching PATTERN or all if `nil'. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
419 Calls `mail-directory-function' and applies `mail-directory-parser' to output." |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
420 (save-excursion |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
421 (message "Querying directory...") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
422 (set-buffer (generate-new-buffer " *mail-directory*")) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
423 (funcall mail-directory-function pattern) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
424 (goto-char 1) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
425 (let (directory) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
426 (if (stringp mail-directory-parser) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
427 (while (re-search-forward mail-directory-parser nil t) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
428 (setq directory |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
429 (cons (match-string 1) directory))) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
430 (if mail-directory-parser |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
431 (setq directory (funcall mail-directory-parser)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
432 (while (not (eobp)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
433 (setq directory |
17310
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
434 (cons (buffer-substring (point) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
435 (progn |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
436 (forward-line) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
437 (if (bolp) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
438 (1- (point)) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
439 (point)))) |
9c0ece61d60a
(mail-complete-style): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17210
diff
changeset
|
440 directory))))) |
14551
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
441 (kill-buffer (current-buffer)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
442 (message "Querying directory...done") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
443 directory))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
444 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
445 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
446 (defun mail-directory-process (pattern) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
447 "Call a Unix process to output names in directory. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
448 See `mail-directory-process'." |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
449 (apply 'call-process (eval (car mail-directory-process)) nil t nil |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
450 (mapcar 'eval (cdr mail-directory-process)))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
451 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
452 ;; This should handle a dialog. Currently expects port to spit out names. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
453 (defun mail-directory-stream (pattern) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
454 "Open a stream to retrieve names in directory. |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
455 See `mail-directory-stream'." |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
456 (let (mailalias-done) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
457 (set-process-sentinel |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
458 (apply 'open-network-stream "mailalias" (current-buffer) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
459 mail-directory-stream) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
460 (lambda (x x) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
461 (setq mailalias-done t))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
462 (while (not mailalias-done) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
463 (sit-for .1)))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
464 |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
465 (defun mail-sentto-newsgroups () |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
466 "Return all entries from Newsgroups: header as completion alist." |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
467 (save-excursion |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
468 (if (mail-position-on-field "newsgroups" t) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
469 (let ((point (point)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
470 list) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
471 (while (< (skip-chars-backward "^:, \t\n") 0) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
472 (setq list `((,(buffer-substring (point) point)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
473 ,@list)) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
474 (skip-chars-backward ", \t\n") |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
475 (setq point (point))) |
dc2881fa11ea
(mail-names, mail-local-names, mail-directory-names)
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
476 list)))) |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
474
diff
changeset
|
477 |
923 | 478 (provide 'mailalias) |
479 | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
474
diff
changeset
|
480 ;;; mailalias.el ends here |