Mercurial > emacs
annotate lisp/mail/mh-utils.el @ 16203:5a8275a74b25
(tq-filter): Add unwind-protect and save-match-data.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 15 Sep 1996 18:38:49 +0000 |
parents | 84b8ad02c07c |
children | 46ee9938fec6 |
rev | line source |
---|---|
6365 | 1 ;;; mh-utils.el --- mh-e code needed for both sending and reading |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
2 ;; Time-stamp: <95/10/22 17:58:16 gildea> |
6365 | 3 |
11331 | 4 ;; Copyright (C) 1993, 1995 Free Software Foundation, Inc. |
6365 | 5 |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
6 ;; This file is part of mh-e, part of GNU Emacs. |
6365 | 7 |
11333 | 8 ;; GNU Emacs is free software; you can redistribute it and/or modify |
6365 | 9 ;; it under the terms of the GNU General Public License as published by |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
12 | |
11333 | 13 ;; GNU Emacs is distributed in the hope that it will be useful, |
6365 | 14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
14169 | 19 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 ;; Boston, MA 02111-1307, USA. | |
6365 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; Internal support for mh-e package. | |
26 | |
11331 | 27 ;;; Change Log: |
28 | |
15531
84b8ad02c07c
(mail-user-agent): Replaces mua-paradigm.
Richard M. Stallman <rms@gnu.org>
parents:
14426
diff
changeset
|
29 ;; $Id: mh-utils.el,v 1.9 1996/01/29 23:17:16 kwzh Exp rms $ |
11331 | 30 |
6365 | 31 ;;; Code: |
32 | |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
33 ;;; Set for local environment: |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
34 ;;; mh-progs and mh-lib used to be set in paths.el, which tried to |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
35 ;;; figure out at build time which of several possible directories MH |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
36 ;;; was installed into. But if you installed MH after building Emacs, |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
37 ;;; this would almost certainly be wrong, so now we do it at run time. |
6365 | 38 |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
39 (defvar mh-progs nil |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
40 "Directory containing MH commands, such as inc, repl, and rmm.") |
6365 | 41 |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
42 (defvar mh-lib nil |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
43 "Directory containing the MH library. |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
44 This directory contains, among other things, |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
45 the mhl program and the components file.") |
6365 | 46 |
11331 | 47 ;;;###autoload |
48 (put 'mh-progs 'risky-local-variable t) | |
49 ;;;###autoload | |
50 (put 'mh-lib 'risky-local-variable t) | |
51 | |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
52 ;;; User preferences: |
6365 | 53 |
54 (defvar mh-auto-folder-collect t | |
55 "*Whether to start collecting MH folder names immediately in the background. | |
56 Non-nil means start a background process collecting the names of all | |
57 folders as soon as mh-e is loaded.") | |
58 | |
59 (defvar mh-recursive-folders nil | |
60 "*If non-nil, then commands which operate on folders do so recursively.") | |
61 | |
62 (defvar mh-clean-message-header nil | |
63 "*Non-nil means clean headers of messages that are displayed or inserted. | |
64 The variables `mh-visible-headers' and `mh-invisible-headers' control what | |
65 is removed.") | |
66 | |
67 (defvar mh-visible-headers nil | |
68 "*If non-nil, contains a regexp specifying the headers to keep when cleaning. | |
69 Only used if `mh-clean-message-header' is non-nil. Setting this variable | |
70 overrides `mh-invisible-headers'.") | |
71 | |
72 (defvar mh-invisible-headers | |
11331 | 73 "^Received: \\|^Message-Id: \\|^Remailed-\\|^Via: \\|^Mail-from: \\|^Return-Path: \\|^Delivery-Date: \\|^In-Reply-To: \\|^Resent-" |
6365 | 74 "Regexp matching lines in a message header that are not to be shown. |
75 If `mh-visible-headers' is non-nil, it is used instead to specify what | |
76 to keep.") | |
77 | |
78 (defvar mh-bury-show-buffer t | |
79 "*Non-nil means that the displayed show buffer for a folder is buried.") | |
80 | |
81 (defvar mh-summary-height 4 | |
82 "*Number of lines in MH-Folder window (including the mode line).") | |
83 | |
84 (defvar mh-msg-number-regexp "^ *\\([0-9]+\\)" | |
85 "Regexp to find the number of a message in a scan line. | |
86 The message's number must be surrounded with \\( \\)") | |
87 | |
88 (defvar mh-msg-search-regexp "^[^0-9]*%d[^0-9]" | |
89 "Format string containing a regexp matching the scan listing for a message. | |
90 The desired message's number will be an argument to format.") | |
91 | |
92 (defvar mhl-formfile nil | |
93 "*Name of format file to be used by mhl to show and print messages. | |
94 A value of T means use the default format file. | |
95 Nil means don't use mhl to format messages when showing; mhl is still used, | |
96 with the default format file, to format messages when printing them. | |
97 The format used should specify a non-zero value for overflowoffset so | |
98 the message continues to conform to RFC 822 and mh-e can parse the headers.") | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
99 (put 'mhl-formfile 'info-file "mh-e") |
6365 | 100 |
11331 | 101 (defvar mh-default-folder-for-message-function nil |
102 "Function to select a default folder for refiling or Fcc. | |
103 If set to a function, that function is called with no arguments by | |
104 `\\[mh-refile-msg]' and `\\[mh-to-fcc]' to get a default when | |
105 prompting the user for a folder. The function is called from within a | |
106 save-excursion, with point at the start of the message. It should | |
107 return the folder to offer as the refile or Fcc folder, as a string | |
108 with a leading `+' sign. It can also return an empty string to use no | |
109 default, or NIL to calculate the default the usual way. | |
110 NOTE: This variable is not an ordinary hook; | |
111 It may not be a list of functions.") | |
6365 | 112 |
11331 | 113 (defvar mh-find-path-hook nil |
114 "Invoked by mh-find-path while reading the user's MH profile.") | |
115 | |
116 (defvar mh-folder-list-change-hook nil | |
117 "Invoked whenever the cached folder list `mh-folder-list' is changed.") | |
118 | |
119 (defvar mh-show-buffer-mode-line-buffer-id "{show-%s} %d" | |
120 "Format string to produce `mode-line-buffer-identification' for show buffers. | |
121 First argument is folder name. Second is message number.") | |
6365 | 122 |
123 (defvar mh-cmd-note 4 | |
124 "Offset to insert notation.") | |
125 | |
11331 | 126 (defvar mh-note-seq "%" |
127 "String whose first character is used to notate messages in a sequence.") | |
128 | |
129 ;;; Internal bookkeeping variables: | |
6365 | 130 |
11331 | 131 ;; The value of `mh-folder-list-change-hook' is called whenever |
132 ;; mh-folder-list variable is set. | |
133 (defvar mh-folder-list nil) ;List of folder names for completion. | |
134 | |
135 ;; Cached value of the `Path:' component in the user's MH profile. | |
136 (defvar mh-user-path nil) ;User's mail folder directory. | |
6365 | 137 |
11331 | 138 ;; An mh-draft-folder of NIL means do not use a draft folder. |
139 ;; Cached value of the `Draft-Folder:' component in the user's MH profile. | |
140 (defvar mh-draft-folder nil) ;Name of folder containing draft messages. | |
141 | |
142 ;; Cached value of the `Unseen-Sequence:' component in the user's MH profile. | |
143 (defvar mh-unseen-seq nil) ;Name of the Unseen sequence. | |
6365 | 144 |
11331 | 145 ;; Cached value of the `Previous-Sequence:' component in the user's MH profile. |
146 (defvar mh-previous-seq nil) ;Name of the Previous sequence. | |
6365 | 147 |
11331 | 148 ;; Cached value of the `Inbox:' component in the user's MH profile, |
149 ;; or "+inbox" if no such component. | |
150 (defvar mh-inbox nil) ;Name of the Inbox folder. | |
6365 | 151 |
11331 | 152 (defconst mh-temp-buffer " *mh-temp*") ;Name of mh-e scratch buffer. |
153 | |
154 (defvar mh-previous-window-config nil) ;Window configuration before mh-e command. | |
155 | |
156 ;;; Internal variables local to a folder. | |
6365 | 157 |
11331 | 158 (defvar mh-current-folder nil) ;Name of current folder, a string. |
159 | |
160 (defvar mh-show-buffer nil) ;Buffer that displays message for this folder. | |
6365 | 161 |
11331 | 162 (defvar mh-folder-filename nil) ;Full path of directory for this folder. |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
163 |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
164 (defvar mh-msg-count nil) ;Number of msgs in buffer. |
11331 | 165 |
166 (defvar mh-showing nil) ;If non-nil, show the message in a separate window. | |
6365 | 167 |
11331 | 168 ;;; This holds a documentation string used by describe-mode. |
169 (defun mh-showing () | |
170 "When moving to a new message in the Folder window, | |
171 also show it in a separate Show window." | |
172 nil) | |
6365 | 173 |
11331 | 174 (defvar mh-seq-list nil) ;The sequences of this folder. An alist of (seq . msgs). |
175 | |
176 (defvar mh-seen-list nil) ;List of displayed messages to be removed from the Unseen sequence. | |
6365 | 177 |
11331 | 178 ;; If non-nil, show buffer contains message with all headers. |
179 ;; If nil, show buffer contains message processed normally. | |
180 (defvar mh-showing-with-headers nil) ;Showing message with headers or normally. | |
6365 | 181 |
182 | |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
183 ;;; mh-e macros |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
184 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
185 (defmacro with-mh-folder-updating (save-modification-flag-p &rest body) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
186 ;; Format is (with-mh-folder-updating (SAVE-MODIFICATION-FLAG-P) &body BODY). |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
187 ;; Execute BODY, which can modify the folder buffer without having to |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
188 ;; worry about file locking or the read-only flag, and return its result. |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
189 ;; If SAVE-MODIFICATION-FLAG-P is non-nil, the buffer's modification |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
190 ;; flag is unchanged, otherwise it is cleared. |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
191 (setq save-modification-flag-p (car save-modification-flag-p)) ; CL style |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
192 (` (prog1 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
193 (let ((mh-folder-updating-mod-flag (buffer-modified-p)) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
194 (buffer-read-only nil) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
195 (buffer-file-name nil)) ;don't let the buffer get locked |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
196 (prog1 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
197 (progn |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
198 (,@ body)) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
199 (mh-set-folder-modified-p mh-folder-updating-mod-flag))) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
200 (,@ (if (not save-modification-flag-p) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
201 '((mh-set-folder-modified-p nil))))))) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
202 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
203 (put 'with-mh-folder-updating 'lisp-indent-hook 1) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
204 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
205 (defmacro mh-in-show-buffer (show-buffer &rest body) |
11331 | 206 ;; Format is (mh-in-show-buffer (SHOW-BUFFER) &body BODY). |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
207 ;; Display buffer SHOW-BUFFER in other window and execute BODY in it. |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
208 ;; Stronger than save-excursion, weaker than save-window-excursion. |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
209 (setq show-buffer (car show-buffer)) ; CL style |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
210 (` (let ((mh-in-show-buffer-saved-window (selected-window))) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
211 (switch-to-buffer-other-window (, show-buffer)) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
212 (if mh-bury-show-buffer (bury-buffer (current-buffer))) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
213 (unwind-protect |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
214 (progn |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
215 (,@ body)) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
216 (select-window mh-in-show-buffer-saved-window))))) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
217 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
218 (put 'mh-in-show-buffer 'lisp-indent-hook 1) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
219 |
11331 | 220 (defmacro mh-make-seq (name msgs) (list 'cons name msgs)) |
221 | |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
222 (defmacro mh-seq-name (pair) (list 'car pair)) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
223 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
224 (defmacro mh-seq-msgs (pair) (list 'cdr pair)) |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
225 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
226 |
6365 | 227 ;;; Ensure new buffers won't get this mode if default-major-mode is nil. |
228 (put 'mh-show-mode 'mode-class 'special) | |
229 | |
230 (defun mh-show-mode () | |
231 "Major mode for showing messages in mh-e. | |
232 The value of mh-show-mode-hook is called when a new message is displayed." | |
233 (kill-all-local-variables) | |
234 (setq major-mode 'mh-show-mode) | |
235 (mh-set-mode-name "MH-Show") | |
236 (run-hooks 'mh-show-mode-hook)) | |
237 | |
238 | |
239 (defun mh-maybe-show (&optional msg) | |
240 ;; If in showing mode, then display the message pointed to by the cursor. | |
241 (if mh-showing (mh-show msg))) | |
242 | |
11331 | 243 (defun mh-show (&optional message) |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
244 "Show MESSAGE (default: message at cursor). |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
245 Force a two-window display with the folder window on top (size |
6365 | 246 mh-summary-height) and the show buffer below it. |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
247 If the message is already visible, display the start of the message. |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
248 |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
249 Display of the message is controlled by setting the variables |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
250 `mh-clean-message-header' and `mhl-formfile'. The default behavior is |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
251 to scroll uninteresting headers off the top of the window. |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
252 Type \"\\[mh-header-display]\" to see the message with all its headers." |
6365 | 253 (interactive) |
254 (and mh-showing-with-headers | |
255 (or mhl-formfile mh-clean-message-header) | |
256 (mh-invalidate-show-buffer)) | |
11331 | 257 (mh-show-msg message)) |
6365 | 258 |
259 | |
260 (defun mh-show-msg (msg) | |
261 (if (not msg) | |
262 (setq msg (mh-get-msg-num t))) | |
263 (setq mh-showing t) | |
264 (let ((folder mh-current-folder) | |
265 (clean-message-header mh-clean-message-header) | |
266 (show-window (get-buffer-window mh-show-buffer))) | |
267 (if (not (eql (next-window (minibuffer-window)) (selected-window))) | |
268 (delete-other-windows)) ; force ourself to the top window | |
269 (mh-in-show-buffer (mh-show-buffer) | |
270 (if (and show-window | |
271 (equal (mh-msg-filename msg folder) buffer-file-name)) | |
272 (progn ;just back up to start | |
273 (goto-char (point-min)) | |
274 (if (not clean-message-header) | |
275 (mh-start-of-uncleaned-message))) | |
276 (mh-display-msg msg folder)))) | |
277 (if (not (= (1+ (window-height)) (screen-height))) ;not horizontally split | |
278 (shrink-window (- (window-height) mh-summary-height))) | |
279 (mh-recenter nil) | |
280 (if (not (memq msg mh-seen-list)) (setq mh-seen-list (cons msg mh-seen-list))) | |
281 (run-hooks 'mh-show-hook)) | |
282 | |
283 | |
284 (defun mh-display-msg (msg-num folder) | |
285 ;; Display message NUMBER of FOLDER. | |
286 ;; Sets the current buffer to the show buffer. | |
287 (set-buffer folder) | |
288 ;; Bind variables in folder buffer in case they are local | |
289 (let ((formfile mhl-formfile) | |
290 (clean-message-header mh-clean-message-header) | |
291 (invisible-headers mh-invisible-headers) | |
292 (visible-headers mh-visible-headers) | |
293 (msg-filename (mh-msg-filename msg-num)) | |
294 (show-buffer mh-show-buffer)) | |
295 (if (not (file-exists-p msg-filename)) | |
296 (error "Message %d does not exist" msg-num)) | |
297 (set-buffer show-buffer) | |
298 (cond ((not (equal msg-filename buffer-file-name)) | |
11331 | 299 (mh-unvisit-file) |
6365 | 300 (erase-buffer) |
11331 | 301 ;; Changing contents, so this hook needs to be reinitialized. |
302 ;; pgp.el uses this. | |
303 (if (boundp 'write-contents-hooks) ;Emacs 19 | |
14118
e7809b53da4d
(mh-display-msg): Use kill-local-variable
Karl Heuer <kwzh@gnu.org>
parents:
13386
diff
changeset
|
304 (kill-local-variable 'write-contents-hooks)) |
6365 | 305 (if formfile |
306 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear" | |
307 (if (stringp formfile) | |
308 (list "-form" formfile)) | |
309 msg-filename) | |
310 (insert-file-contents msg-filename)) | |
311 (goto-char (point-min)) | |
312 (cond (clean-message-header | |
313 (mh-clean-msg-header (point-min) | |
314 invisible-headers | |
315 visible-headers) | |
316 (goto-char (point-min))) | |
317 (t | |
318 (mh-start-of-uncleaned-message))) | |
11331 | 319 ;; the parts of visiting we want to do (no locking) |
6365 | 320 (or (eq buffer-undo-list t) ;don't save undo info for prev msgs |
321 (setq buffer-undo-list nil)) | |
11331 | 322 (set-buffer-modified-p nil) |
323 (set-buffer-auto-saved) | |
324 ;; the parts of set-visited-file-name we want to do (no locking) | |
6365 | 325 (setq buffer-file-name msg-filename) |
11331 | 326 (setq buffer-backed-up nil) |
327 (auto-save-mode 1) | |
6365 | 328 (set-mark nil) |
329 (mh-show-mode) | |
330 (setq mode-line-buffer-identification | |
331 (list (format mh-show-buffer-mode-line-buffer-id | |
332 folder msg-num))) | |
333 (set-buffer folder) | |
334 (setq mh-showing-with-headers nil))))) | |
335 | |
336 (defun mh-start-of-uncleaned-message () | |
337 ;; position uninteresting headers off the top of the window | |
338 (let ((case-fold-search t)) | |
339 (re-search-forward | |
11331 | 340 "^To:\\|^Cc:\\|^From:\\|^Subject:\\|^Date:" nil t) |
6365 | 341 (beginning-of-line) |
342 (mh-recenter 0))) | |
343 | |
344 | |
345 (defun mh-invalidate-show-buffer () | |
346 ;; Invalidate the show buffer so we must update it to use it. | |
347 (if (get-buffer mh-show-buffer) | |
348 (save-excursion | |
349 (set-buffer mh-show-buffer) | |
11331 | 350 (mh-unvisit-file)))) |
6365 | 351 |
352 | |
11331 | 353 (defun mh-unvisit-file () |
354 ;; Separate current buffer from the message file it was visiting. | |
355 (or (not (buffer-modified-p)) | |
356 (null buffer-file-name) ;we've been here before | |
357 (yes-or-no-p (format "Message %s modified; flush changes? " | |
358 (file-name-nondirectory buffer-file-name))) | |
359 (error "Flushing changes not confirmed")) | |
360 (clear-visited-file-modtime) | |
361 (unlock-buffer) | |
362 (setq buffer-file-name nil)) | |
363 | |
364 | |
6365 | 365 (defun mh-get-msg-num (error-if-no-message) |
366 ;; Return the message number of the displayed message. If the argument | |
367 ;; ERROR-IF-NO-MESSAGE is non-nil, then complain if the cursor is not | |
368 ;; pointing to a message. | |
369 (save-excursion | |
370 (beginning-of-line) | |
371 (cond ((looking-at mh-msg-number-regexp) | |
372 (string-to-int (buffer-substring (match-beginning 1) | |
373 (match-end 1)))) | |
374 (error-if-no-message | |
375 (error "Cursor not pointing to message")) | |
376 (t nil)))) | |
377 | |
378 | |
379 (defun mh-msg-filename (msg &optional folder) | |
380 ;; Return the file name of MESSAGE in FOLDER (default current folder). | |
381 (expand-file-name (int-to-string msg) | |
382 (if folder | |
383 (mh-expand-file-name folder) | |
384 mh-folder-filename))) | |
385 | |
386 | |
387 (defun mh-clean-msg-header (start invisible-headers visible-headers) | |
388 ;; Flush extraneous lines in a message header, from the given POINT to the | |
389 ;; end of the message header. If VISIBLE-HEADERS is non-nil, it contains a | |
390 ;; regular expression specifying the lines to display, otherwise | |
391 ;; INVISIBLE-HEADERS contains a regular expression specifying lines to | |
392 ;; delete from the header. | |
393 (let ((case-fold-search t)) | |
394 (save-restriction | |
395 (goto-char start) | |
396 (if (search-forward "\n\n" nil 'move) | |
397 (backward-char 1)) | |
398 (narrow-to-region start (point)) | |
399 (goto-char (point-min)) | |
400 (if visible-headers | |
401 (while (< (point) (point-max)) | |
402 (cond ((looking-at visible-headers) | |
403 (forward-line 1) | |
404 (while (looking-at "[ \t]") (forward-line 1))) | |
405 (t | |
406 (mh-delete-line 1) | |
407 (while (looking-at "[ \t]") | |
408 (mh-delete-line 1))))) | |
409 (while (re-search-forward invisible-headers nil t) | |
410 (beginning-of-line) | |
411 (mh-delete-line 1) | |
412 (while (looking-at "[ \t]") | |
413 (mh-delete-line 1)))) | |
414 (unlock-buffer)))) | |
415 | |
416 | |
417 (defun mh-recenter (arg) | |
418 ;; Like recenter but with two improvements: nil arg means recenter, | |
419 ;; and only does anything if the current buffer is in the selected | |
420 ;; window. (Commands like save-some-buffers can make this false.) | |
421 (if (eql (get-buffer-window (current-buffer)) | |
422 (selected-window)) | |
423 (recenter (if arg arg '(t))))) | |
424 | |
425 | |
426 (defun mh-delete-line (lines) | |
427 ;; Delete version of kill-line. | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
428 (delete-region (point) (progn (forward-line lines) (point)))) |
6365 | 429 |
430 | |
431 (defun mh-notate (msg notation offset) | |
432 ;; Marks MESSAGE with the character NOTATION at position OFFSET. | |
433 ;; Null MESSAGE means the message that the cursor points to. | |
434 (save-excursion | |
435 (if (or (null msg) | |
436 (mh-goto-msg msg t t)) | |
437 (with-mh-folder-updating (t) | |
438 (beginning-of-line) | |
439 (forward-char offset) | |
440 (delete-char 1) | |
441 (insert notation))))) | |
442 | |
443 | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
444 (defun mh-find-msg-get-num (step) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
445 ;; Return the message number of the message on the current scan line |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
446 ;; or one nearby. Jumps over non-message lines, such as inc errors. |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
447 ;; STEP tells whether to search forward or backward if we have to search. |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
448 (or (mh-get-msg-num nil) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
449 (let ((msg-num nil) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
450 (nreverses 0)) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
451 (while (and (not msg-num) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
452 (< nreverses 2)) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
453 (cond ((eobp) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
454 (setq step -1) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
455 (setq nreverses (1+ nreverses))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
456 ((bobp) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
457 (setq step 1) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
458 (setq nreverses (1+ nreverses)))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
459 (forward-line step) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
460 (setq msg-num (mh-get-msg-num nil))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
461 msg-num))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
462 |
6365 | 463 (defun mh-goto-msg (number &optional no-error-if-no-message dont-show) |
464 "Position the cursor at message NUMBER. | |
11331 | 465 Optional non-nil second argument means return nil instead of |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
466 signaling an error if message does not exist; in this case, |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
467 the cursor is positioned near where the message would have been. |
11331 | 468 Non-nil third argument means not to show the message." |
469 (interactive "NGo to message: ") | |
470 (setq number (prefix-numeric-value number)) ;Emacs 19 | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
471 ;; This basic routine tries to be as fast as possible, |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
472 ;; using a binary search and minimal regexps. |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
473 (let ((cur-msg (mh-find-msg-get-num -1)) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
474 (jump-size mh-msg-count)) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
475 (while (and (> jump-size 1) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
476 cur-msg |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
477 (not (eq cur-msg number))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
478 (cond ((< cur-msg number) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
479 (setq jump-size (min (- number cur-msg) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
480 (ash (1+ jump-size) -1))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
481 (forward-line jump-size) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
482 (setq cur-msg (mh-find-msg-get-num 1))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
483 (t |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
484 (setq jump-size (min (- cur-msg number) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
485 (ash (1+ jump-size) -1))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
486 (forward-line (- jump-size)) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
487 (setq cur-msg (mh-find-msg-get-num -1))))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
488 (if (eq cur-msg number) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
489 (progn |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
490 (beginning-of-line) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
491 (or dont-show |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
492 (mh-maybe-show number) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
493 t)) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
494 (if (not no-error-if-no-message) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
495 (error "No message %d" number))))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
496 |
6365 | 497 |
498 (defun mh-msg-search-pat (n) | |
499 ;; Return a search pattern for message N in the scan listing. | |
500 (format mh-msg-search-regexp n)) | |
501 | |
502 | |
11331 | 503 (defun mh-get-profile-field (field) |
504 ;; Find and return the value of FIELD in the current buffer. | |
505 ;; Returns NIL if the field is not in the buffer. | |
506 (let ((case-fold-search t)) | |
507 (goto-char (point-min)) | |
508 (cond ((not (re-search-forward (format "^%s" field) nil t)) nil) | |
509 ((looking-at "[\t ]*$") nil) | |
510 (t | |
511 (re-search-forward "[\t ]*\\([^\t \n].*\\)$" nil t) | |
512 (let ((start (match-beginning 1))) | |
513 (end-of-line) | |
514 (buffer-substring start (point))))))) | |
515 | |
15531
84b8ad02c07c
(mail-user-agent): Replaces mua-paradigm.
Richard M. Stallman <rms@gnu.org>
parents:
14426
diff
changeset
|
516 (defvar mail-user-agent 'mh-e-user-agent) ;from reporter.el 3.2 |
11331 | 517 |
6365 | 518 (defun mh-find-path () |
519 ;; Set mh-progs and mh-lib. | |
520 ;; (This step is necessary if MH was installed after this Emacs was dumped.) | |
11331 | 521 ;; From profile file, set mh-user-path, mh-draft-folder, |
522 ;; mh-unseen-seq, mh-previous-seq, mh-inbox. | |
6365 | 523 (mh-find-progs) |
524 (save-excursion | |
525 ;; Be sure profile is fully expanded before switching buffers | |
526 (let ((profile (expand-file-name (or (getenv "MH") "~/.mh_profile")))) | |
11331 | 527 (set-buffer (get-buffer-create mh-temp-buffer)) |
6365 | 528 (setq buffer-offer-save nil) ;for people who set default to t |
529 (erase-buffer) | |
530 (condition-case err | |
531 (insert-file-contents profile) | |
532 (file-error | |
533 (mh-install profile err))) | |
11331 | 534 (setq mh-user-path (mh-get-profile-field "Path:")) |
535 (if (not mh-user-path) | |
6365 | 536 (setq mh-user-path "Mail")) |
537 (setq mh-user-path | |
538 (file-name-as-directory | |
539 (expand-file-name mh-user-path (expand-file-name "~")))) | |
11331 | 540 (setq mh-draft-folder (mh-get-profile-field "Draft-Folder:")) |
541 (if mh-draft-folder | |
542 (progn | |
543 (if (not (mh-folder-name-p mh-draft-folder)) | |
544 (setq mh-draft-folder (format "+%s" mh-draft-folder))) | |
545 (if (not (file-exists-p (mh-expand-file-name mh-draft-folder))) | |
546 (error "Draft folder \"%s\" not found. Create it and try again." | |
547 (mh-expand-file-name mh-draft-folder))))) | |
548 (setq mh-inbox (mh-get-profile-field "Inbox:")) | |
549 (cond ((not mh-inbox) | |
550 (setq mh-inbox "+inbox")) | |
551 ((not (mh-folder-name-p mh-inbox)) | |
552 (setq mh-inbox (format "+%s" mh-inbox)))) | |
553 (setq mh-unseen-seq (mh-get-profile-field "Unseen-Sequence:")) | |
554 (if mh-unseen-seq | |
555 (setq mh-unseen-seq (intern mh-unseen-seq)) | |
556 (setq mh-unseen-seq 'unseen)) ;old MH default? | |
557 (setq mh-previous-seq (mh-get-profile-field "Previous-Sequence:")) | |
558 (if mh-previous-seq | |
559 (setq mh-previous-seq (intern mh-previous-seq))) | |
15531
84b8ad02c07c
(mail-user-agent): Replaces mua-paradigm.
Richard M. Stallman <rms@gnu.org>
parents:
14426
diff
changeset
|
560 (setq mail-user-agent 'mh-e-user-agent) |
11331 | 561 (run-hooks 'mh-find-path-hook)))) |
6365 | 562 |
563 (defun mh-find-progs () | |
564 (or (file-exists-p (expand-file-name "inc" mh-progs)) | |
565 (setq mh-progs | |
566 (or (mh-path-search exec-path "inc") | |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
567 (mh-path-search '("/usr/local/bin/mh/" |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
568 "/usr/local/mh/" |
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
569 "/usr/bin/mh/" ;Ultrix 4.2 |
6365 | 570 "/usr/new/mh/" ;Ultrix <4.2 |
11331 | 571 "/usr/contrib/mh/bin/" ;BSDI |
572 "/usr/local/bin/" | |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
573 ) |
6365 | 574 "inc") |
11331 | 575 mh-progs |
6365 | 576 "/usr/local/bin/"))) |
577 (or (file-exists-p (expand-file-name "mhl" mh-lib)) | |
578 (setq mh-lib | |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
579 (or (mh-path-search '("/usr/local/lib/mh/" |
11331 | 580 "/usr/local/mh/lib/" |
581 "/usr/local/bin/mh/" | |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
582 "/usr/lib/mh/" ;Ultrix 4.2 |
6365 | 583 "/usr/new/lib/mh/" ;Ultrix <4.2 |
11331 | 584 "/usr/contrib/mh/lib/" ;BSDI |
6856
396254137b30
(mh-progs, mh-lib): Move from mh-e.el
Richard M. Stallman <rms@gnu.org>
parents:
6365
diff
changeset
|
585 ) |
6365 | 586 "mhl") |
587 (mh-path-search exec-path "mhl") ;unlikely | |
11331 | 588 mh-lib |
589 "/usr/local/lib/mh/")))) | |
6365 | 590 |
591 (defun mh-path-search (path file) | |
592 ;; Search PATH, a list of directory names, for FILE. | |
593 ;; Returns the element of PATH that contains FILE, or nil if not found. | |
594 (while (and path | |
595 (not (file-exists-p (expand-file-name file (car path))))) | |
596 (setq path (cdr path))) | |
597 (car path)) | |
598 | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
599 (defvar mh-no-install nil) ;do not run install-mh |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
600 |
6365 | 601 (defun mh-install (profile error-val) |
602 ;; Called to do error recovery if we fail to read the profile file. | |
603 ;; If possible, initialize the MH environment. | |
604 (if (or (getenv "MH") | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
605 (file-exists-p profile) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
606 mh-no-install) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
607 (signal (car error-val) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
608 (list (format "Cannot read MH profile \"%s\"" profile) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
609 (car (cdr (cdr error-val)))))) |
6365 | 610 ;; The "install-mh" command will output a short note which |
611 ;; mh-exec-cmd will display to the user. | |
11331 | 612 ;; The MH 5 version of install-mh might try prompt the user |
613 ;; for information, which would fail here. | |
6365 | 614 (mh-exec-cmd (expand-file-name "install-mh" mh-lib) "-auto") |
615 ;; now try again to read the profile file | |
616 (erase-buffer) | |
617 (condition-case err | |
618 (insert-file-contents profile) | |
619 (file-error | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
620 (signal (car err) ;re-signal with more specific msg |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
621 (list (format "Cannot read MH profile \"%s\"" profile) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
622 (car (cdr (cdr err)))))))) |
6365 | 623 |
624 | |
625 (defun mh-set-folder-modified-p (flag) | |
11331 | 626 ;; Mark current folder as modified or unmodified according to FLAG. |
6365 | 627 (set-buffer-modified-p flag)) |
628 | |
629 | |
630 (defun mh-find-seq (name) (assoc name mh-seq-list)) | |
631 | |
632 (defun mh-seq-to-msgs (seq) | |
11331 | 633 ;; Return a list of the messages in SEQUENCE. |
6365 | 634 (mh-seq-msgs (mh-find-seq seq))) |
635 | |
636 | |
637 (defun mh-add-msgs-to-seq (msgs seq &optional internal-flag) | |
638 ;; Add MESSAGE(s) to the SEQUENCE. If optional FLAG is non-nil, do not mark | |
639 ;; the message in the scan listing or inform MH of the addition. | |
640 (let ((entry (mh-find-seq seq))) | |
641 (if (and msgs (atom msgs)) (setq msgs (list msgs))) | |
642 (if (null entry) | |
643 (setq mh-seq-list (cons (mh-make-seq seq msgs) mh-seq-list)) | |
11331 | 644 (if msgs (setcdr entry (append msgs (mh-seq-msgs entry))))) |
6365 | 645 (cond ((not internal-flag) |
646 (mh-add-to-sequence seq msgs) | |
11331 | 647 (mh-notate-seq seq mh-note-seq (1+ mh-cmd-note)))))) |
6365 | 648 |
649 (autoload 'mh-add-to-sequence "mh-seq") | |
650 (autoload 'mh-notate-seq "mh-seq") | |
651 (autoload 'mh-read-seq-default "mh-seq") | |
652 (autoload 'mh-map-to-seq-msgs "mh-seq") | |
653 | |
654 | |
655 (defun mh-set-mode-name (mode-name-string) | |
656 ;; Set the mode-name and ensure that the mode line is updated. | |
657 (setq mode-name mode-name-string) | |
11576
f0906608aa63
(mh-set-mode-name): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
11333
diff
changeset
|
658 (force-mode-line-update t)) |
6365 | 659 |
660 | |
661 (defun mh-prompt-for-folder (prompt default can-create) | |
662 ;; Prompt for a folder name with PROMPT. Returns the folder's name as a | |
663 ;; string. DEFAULT is used if the folder exists and the user types return. | |
664 ;; If the CAN-CREATE flag is t, then a non-existent folder is made. | |
665 (if (null default) | |
666 (setq default "")) | |
667 (let* ((prompt (format "%s folder%s" prompt | |
668 (if (equal "" default) | |
669 "? " | |
670 (format " [%s]? " default)))) | |
671 read-name folder-name) | |
672 (if (null mh-folder-list) | |
673 (mh-set-folder-list)) | |
674 (while (and (setq read-name (completing-read prompt mh-folder-list | |
675 nil nil "+")) | |
676 (equal read-name "") | |
677 (equal default ""))) | |
678 (cond ((or (equal read-name "") (equal read-name "+")) | |
679 (setq read-name default)) | |
680 ((not (mh-folder-name-p read-name)) | |
681 (setq read-name (format "+%s" read-name)))) | |
682 (setq folder-name read-name) | |
683 (cond ((and (> (length folder-name) 0) | |
684 (eql (aref folder-name (1- (length folder-name))) ?/)) | |
685 (setq folder-name (substring folder-name 0 -1)))) | |
686 (let ((new-file-p (not (file-exists-p (mh-expand-file-name folder-name))))) | |
687 (cond ((and new-file-p | |
688 (y-or-n-p | |
689 (format "Folder %s does not exist. Create it? " folder-name))) | |
690 (message "Creating %s" folder-name) | |
691 (call-process "mkdir" nil nil nil (mh-expand-file-name folder-name)) | |
692 (message "Creating %s...done" folder-name) | |
11331 | 693 (setq mh-folder-list (cons (list read-name) mh-folder-list)) |
694 (run-hooks 'mh-folder-list-change-hook)) | |
6365 | 695 (new-file-p |
696 (error "Folder %s is not created" folder-name)) | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
697 ((not (file-directory-p (mh-expand-file-name folder-name))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
698 (error "\"%s\" is not a directory" |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
699 (mh-expand-file-name folder-name))) |
6365 | 700 ((and (null (assoc read-name mh-folder-list)) |
701 (null (assoc (concat read-name "/") mh-folder-list))) | |
11331 | 702 (setq mh-folder-list (cons (list read-name) mh-folder-list)) |
703 (run-hooks 'mh-folder-list-change-hook)))) | |
6365 | 704 folder-name)) |
705 | |
706 | |
11331 | 707 (defvar mh-make-folder-list-process nil) ;The background process collecting the folder list. |
6365 | 708 |
11331 | 709 (defvar mh-folder-list-temp nil) ;mh-folder-list as it is being built. |
6365 | 710 |
11331 | 711 (defvar mh-folder-list-partial-line "") ;Start of last incomplete line from folder process. |
6365 | 712 |
713 (defun mh-set-folder-list () | |
11331 | 714 ;; Sets mh-folder-list correctly. |
715 ;; A useful function for the command line or for when you need to | |
716 ;; sync by hand. Format is in a form suitable for completing read. | |
6365 | 717 (message "Collecting folder names...") |
718 (if (not mh-make-folder-list-process) | |
719 (mh-make-folder-list-background)) | |
720 (while (eq (process-status mh-make-folder-list-process) 'run) | |
721 (accept-process-output mh-make-folder-list-process)) | |
722 (setq mh-folder-list mh-folder-list-temp) | |
11331 | 723 (run-hooks 'mh-folder-list-change-hook) |
6365 | 724 (setq mh-folder-list-temp nil) |
725 (delete-process mh-make-folder-list-process) | |
726 (setq mh-make-folder-list-process nil) | |
727 (message "Collecting folder names...done")) | |
728 | |
729 (defun mh-make-folder-list-background () | |
11331 | 730 ;; Start a background process to compute a list of the user's folders. |
731 ;; Call mh-set-folder-list to wait for the result. | |
6365 | 732 (cond |
733 ((not mh-make-folder-list-process) | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
734 (mh-find-path) |
6365 | 735 (let ((process-connection-type nil)) |
736 (setq mh-make-folder-list-process | |
737 (start-process "folders" nil (expand-file-name "folders" mh-progs) | |
738 "-fast" | |
739 (if mh-recursive-folders | |
740 "-recurse" | |
741 "-norecurse"))) | |
742 (set-process-filter mh-make-folder-list-process | |
743 'mh-make-folder-list-filter) | |
744 (process-kill-without-query mh-make-folder-list-process))))) | |
745 | |
746 (defun mh-make-folder-list-filter (process output) | |
747 ;; parse output from "folders -fast" | |
748 (let ((position 0) | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
749 line-end |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
750 new-folder |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
751 (prevailing-match-data (match-data))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
752 (unwind-protect |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
753 ;; make sure got complete line |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
754 (while (setq line-end (string-match "\n" output position)) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
755 (setq new-folder (format "+%s%s" |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
756 mh-folder-list-partial-line |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
757 (substring output position line-end))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
758 (setq mh-folder-list-partial-line "") |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
759 ;; is new folder a subfolder of previous? |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
760 (if (and mh-folder-list-temp |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
761 (string-match |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
762 (regexp-quote |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
763 (concat (car (car mh-folder-list-temp)) "/")) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
764 new-folder)) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
765 ;; append slash to parent folder for better completion |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
766 ;; (undone by mh-prompt-for-folder) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
767 (setq mh-folder-list-temp |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
768 (cons |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
769 (list new-folder) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
770 (cons |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
771 (list (concat (car (car mh-folder-list-temp)) "/")) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
772 (cdr mh-folder-list-temp)))) |
6365 | 773 (setq mh-folder-list-temp |
774 (cons (list new-folder) | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
775 mh-folder-list-temp))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
776 (setq position (1+ line-end))) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
777 (store-match-data prevailing-match-data)) |
6365 | 778 (setq mh-folder-list-partial-line (substring output position)))) |
779 | |
780 | |
781 (defun mh-folder-name-p (name) | |
782 ;; Return non-NIL if NAME is possibly the name of a folder. | |
783 ;; A name (a string or symbol) can be a folder name if it begins with "+". | |
784 (if (symbolp name) | |
785 (eql (aref (symbol-name name) 0) ?+) | |
786 (and (> (length name) 0) | |
787 (eql (aref name 0) ?+)))) | |
788 | |
789 | |
790 ;;; Issue commands to MH. | |
791 | |
792 | |
793 (defun mh-exec-cmd (command &rest args) | |
794 ;; Execute mh-command COMMAND with ARGS. | |
11331 | 795 ;; The side effects are what is desired. |
6365 | 796 ;; Any output is assumed to be an error and is shown to the user. |
11331 | 797 ;; The output is not read or parsed by mh-e. |
6365 | 798 (save-excursion |
11331 | 799 (set-buffer (get-buffer-create mh-temp-buffer)) |
6365 | 800 (erase-buffer) |
801 (apply 'call-process | |
802 (expand-file-name command mh-progs) nil t nil | |
803 (mh-list-to-string args)) | |
804 (if (> (buffer-size) 0) | |
805 (save-window-excursion | |
11331 | 806 (switch-to-buffer-other-window mh-temp-buffer) |
6365 | 807 (sit-for 5))))) |
808 | |
809 | |
810 (defun mh-exec-cmd-error (env command &rest args) | |
811 ;; In environment ENV, execute mh-command COMMAND with args ARGS. | |
812 ;; ENV is nil or a string of space-separated "var=value" elements. | |
813 ;; Signals an error if process does not complete successfully. | |
814 (save-excursion | |
11331 | 815 (set-buffer (get-buffer-create mh-temp-buffer)) |
6365 | 816 (erase-buffer) |
817 (let ((status | |
818 (if env | |
819 ;; the shell hacks necessary here shows just how broken Unix is | |
820 (apply 'call-process "/bin/sh" nil t nil "-c" | |
821 (format "%s %s ${1+\"$@\"}" | |
822 env | |
823 (expand-file-name command mh-progs)) | |
824 command | |
825 (mh-list-to-string args)) | |
826 (apply 'call-process | |
827 (expand-file-name command mh-progs) nil t nil | |
828 (mh-list-to-string args))))) | |
829 (mh-handle-process-error command status)))) | |
830 | |
831 | |
832 (defun mh-exec-cmd-daemon (command &rest args) | |
11331 | 833 ;; Execute MH command COMMAND with ARGS in the background. |
834 ;; Any output from command is displayed in an asynchronous pop-up window. | |
6365 | 835 (save-excursion |
11331 | 836 (set-buffer (get-buffer-create mh-temp-buffer)) |
6365 | 837 (erase-buffer)) |
838 (let* ((process-connection-type nil) | |
839 (process (apply 'start-process | |
840 command nil | |
841 (expand-file-name command mh-progs) | |
842 (mh-list-to-string args)))) | |
843 (set-process-filter process 'mh-process-daemon))) | |
844 | |
845 (defun mh-process-daemon (process output) | |
846 ;; Process daemon that puts output into a temporary buffer. | |
11331 | 847 (set-buffer (get-buffer-create mh-temp-buffer)) |
6365 | 848 (insert-before-markers output) |
11331 | 849 (display-buffer mh-temp-buffer)) |
6365 | 850 |
851 | |
852 (defun mh-exec-cmd-quiet (raise-error command &rest args) | |
853 ;; Args are RAISE-ERROR, COMMANDS, ARGS.... | |
854 ;; Execute MH command COMMAND with ARGS. ARGS is a list of strings. | |
855 ;; Return at start of mh-temp buffer, where output can be parsed and used. | |
856 ;; Returns value of call-process, which is 0 for success, | |
857 ;; unless RAISE-ERROR is non-nil, in which case an error is signaled | |
858 ;; if call-process returns non-0. | |
11331 | 859 (set-buffer (get-buffer-create mh-temp-buffer)) |
6365 | 860 (erase-buffer) |
861 (let ((value | |
862 (apply 'call-process | |
863 (expand-file-name command mh-progs) nil t nil | |
864 args))) | |
865 (goto-char (point-min)) | |
866 (if raise-error | |
867 (mh-handle-process-error command value) | |
868 value))) | |
869 | |
870 | |
871 (defun mh-exec-cmd-output (command display &rest args) | |
872 ;; Execute MH command COMMAND with DISPLAY flag and ARGS. | |
873 ;; Put the output into buffer after point. Set mark after inserted text. | |
11331 | 874 ;; Output is expected to be shown to user, not parsed by mh-e. |
6365 | 875 (push-mark (point) t) |
876 (apply 'call-process | |
877 (expand-file-name command mh-progs) nil t display | |
878 (mh-list-to-string args)) | |
879 (exchange-point-and-mark)) | |
880 | |
881 | |
882 (defun mh-exec-lib-cmd-output (command &rest args) | |
883 ;; Execute MH library command COMMAND with ARGS. | |
884 ;; Put the output into buffer after point. Set mark after inserted text. | |
885 (apply 'mh-exec-cmd-output (expand-file-name command mh-lib) nil args)) | |
886 | |
887 | |
888 (defun mh-handle-process-error (command status) | |
889 ;; Raise error if COMMAND returned non-0 STATUS, otherwise return STATUS. | |
890 ;; STATUS is return value from call-process. | |
891 ;; Program output is in current buffer. | |
11331 | 892 ;; If output is too long to include in error message, display the buffer. |
6365 | 893 (cond ((eql status 0) ;success |
894 status) | |
895 ((stringp status) ;kill string | |
14426
9f18c1b097ce
(mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
896 (error "%s: %s" command status)) |
6365 | 897 (t ;exit code |
898 (cond | |
899 ((= (buffer-size) 0) ;program produced no error message | |
14426
9f18c1b097ce
(mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
900 (error "%s: exit code %d" command status)) |
6365 | 901 (t |
902 ;; will error message fit on one line? | |
903 (goto-line 2) | |
904 (if (and (< (buffer-size) (screen-width)) | |
905 (eobp)) | |
14426
9f18c1b097ce
(mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
906 (error "%s" |
9f18c1b097ce
(mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
907 (buffer-substring 1 (progn (goto-char 1) |
6365 | 908 (end-of-line) |
909 (point)))) | |
910 (display-buffer (current-buffer)) | |
14426
9f18c1b097ce
(mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
911 (error "%s failed with status %d. See error message in other window." |
9f18c1b097ce
(mh-handle-process-error): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
912 command status))))))) |
6365 | 913 |
914 | |
915 (defun mh-expand-file-name (filename &optional default) | |
11331 | 916 ;; Just like `expand-file-name', but also handles MH folder names. |
917 ;; Assumes that any filename that starts with '+' is a folder name. | |
6365 | 918 (if (mh-folder-name-p filename) |
919 (expand-file-name (substring filename 1) mh-user-path) | |
920 (expand-file-name filename default))) | |
921 | |
922 | |
923 (defun mh-list-to-string (l) | |
924 ;; Flattens the list L and makes every element of the new list into a string. | |
925 (nreverse (mh-list-to-string-1 l))) | |
926 | |
927 (defun mh-list-to-string-1 (l) | |
928 (let ((new-list nil)) | |
929 (while l | |
930 (cond ((null (car l))) | |
931 ((symbolp (car l)) | |
932 (setq new-list (cons (symbol-name (car l)) new-list))) | |
933 ((numberp (car l)) | |
934 (setq new-list (cons (int-to-string (car l)) new-list))) | |
935 ((equal (car l) "")) | |
936 ((stringp (car l)) (setq new-list (cons (car l) new-list))) | |
937 ((listp (car l)) | |
938 (setq new-list (nconc (mh-list-to-string-1 (car l)) | |
939 new-list))) | |
940 (t (error "Bad element in mh-list-to-string: %s" (car l)))) | |
941 (setq l (cdr l))) | |
942 new-list)) | |
943 | |
944 (provide 'mh-utils) | |
945 | |
946 (and (not noninteractive) | |
947 mh-auto-folder-collect | |
13386
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
948 (let ((mh-no-install t)) ;only get folders if MH installed |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
949 (condition-case err |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
950 (mh-make-folder-list-background) |
78c7ebcbd9fe
(mh-goto-msg): binary search (much faster!).
Karl Heuer <kwzh@gnu.org>
parents:
11576
diff
changeset
|
951 (file-error)))) ;so don't complain if not installed |
6365 | 952 |
953 ;;; mh-utils.el ends here |