Mercurial > emacs
annotate lisp/mh-e/mh-folder.el @ 99548:d47ff67f1a11
Updated with additional credits, from ns-emacs.texi.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 14 Nov 2008 20:45:28 +0000 |
parents | 4882b599444d |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
68465 | 1 ;;; mh-folder.el --- MH-Folder mode |
2 | |
95843 | 3 ;; Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 |
4 ;; Free Software Foundation, Inc. | |
68465 | 5 |
6 ;; Author: Bill Wohler <wohler@newt.com> | |
7 ;; Maintainer: Bill Wohler <wohler@newt.com> | |
8 ;; Keywords: mail | |
9 ;; See: mh-e.el | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94663
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
68465 | 14 ;; it under the terms of the GNU General Public License as published by |
94663
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
16 ;; (at your option) any later version. |
68465 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94663
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
68465 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; Mode for browsing folders | |
29 | |
30 ;;; Change Log: | |
31 | |
32 ;;; Code: | |
33 | |
34 (require 'mh-e) | |
35 (require 'mh-scan) | |
36 (mh-require-cl) | |
37 | |
69245
f3bbf5f32462
* mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents:
68529
diff
changeset
|
38 ;; Dynamically-created functions not found in mh-loaddefs.el. |
68465 | 39 (autoload 'mh-tool-bar-folder-buttons-init "mh-tool-bar") |
69245
f3bbf5f32462
* mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents:
68529
diff
changeset
|
40 (autoload 'mh-tool-bar-init "mh-tool-bar") |
68465 | 41 |
42 (require 'gnus-util) | |
43 (autoload 'message-fetch-field "message") | |
44 | |
45 | |
46 | |
47 ;;; MH-E Entry Points | |
48 | |
49 ;;;###autoload | |
50 (defun mh-rmail (&optional arg) | |
51 "Incorporate new mail with MH. | |
52 Scan an MH folder if ARG is non-nil. | |
53 | |
54 This function is an entry point to MH-E, the Emacs interface to | |
55 the MH mail system." | |
56 (interactive "P") | |
57 (mh-find-path) | |
58 (if arg | |
59 (call-interactively 'mh-visit-folder) | |
60 (unless (get-buffer mh-inbox) | |
61 (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq))) | |
62 (mh-inc-folder))) | |
63 | |
64 ;;;###autoload | |
65 (defun mh-nmail (&optional arg) | |
66 "Check for new mail in inbox folder. | |
67 Scan an MH folder if ARG is non-nil. | |
68 | |
69 This function is an entry point to MH-E, the Emacs interface to | |
70 the MH mail system." | |
71 (interactive "P") | |
72 (mh-find-path) ; init mh-inbox | |
73 (if arg | |
74 (call-interactively 'mh-visit-folder) | |
75 (mh-visit-folder mh-inbox))) | |
76 | |
77 | |
78 ;;; Desktop Integration | |
79 | |
80 ;; desktop-buffer-mode-handlers appeared in Emacs 22. | |
81 (if (fboundp 'desktop-buffer-mode-handlers) | |
82 (add-to-list 'desktop-buffer-mode-handlers | |
83 '(mh-folder-mode . mh-restore-desktop-buffer))) | |
84 | |
85 (defun mh-restore-desktop-buffer (desktop-buffer-file-name | |
86 desktop-buffer-name | |
87 desktop-buffer-misc) | |
88 "Restore an MH folder buffer specified in a desktop file. | |
89 When desktop creates a buffer, DESKTOP-BUFFER-FILE-NAME holds the | |
90 file name to visit, DESKTOP-BUFFER-NAME holds the desired buffer | |
91 name, and DESKTOP-BUFFER-MISC holds a list of miscellaneous info | |
92 used by the `desktop-buffer-handlers' functions." | |
93 (mh-find-path) | |
94 (mh-visit-folder desktop-buffer-name) | |
95 (current-buffer)) | |
96 | |
97 | |
98 | |
99 ;;; Variables | |
100 | |
101 (defvar mh-folder-filename nil | |
102 "Full path of directory for this folder.") | |
103 | |
104 (defvar mh-partial-folder-mode-line-annotation "select" | |
105 "Annotation when displaying part of a folder. | |
106 The string is displayed after the folder's name. nil for no | |
107 annotation.") | |
108 | |
109 (defvar mh-last-destination nil | |
110 "Destination of last refile or write command.") | |
111 | |
112 (defvar mh-last-destination-folder nil | |
113 "Destination of last refile command.") | |
114 | |
115 (defvar mh-last-destination-write nil | |
116 "Destination of last write command.") | |
117 | |
118 (defvar mh-first-msg-num nil | |
119 "Number of first message in buffer.") | |
120 | |
121 (defvar mh-last-msg-num nil | |
122 "Number of last msg in buffer.") | |
123 | |
124 (defvar mh-msg-count nil | |
125 "Number of msgs in buffer.") | |
126 | |
127 | |
128 | |
129 ;;; Sequence Menu | |
130 | |
131 (easy-menu-define | |
132 mh-folder-sequence-menu mh-folder-mode-map "Menu for MH-E folder-sequence." | |
133 '("Sequence" | |
134 ["Add Message to Sequence..." mh-put-msg-in-seq (mh-get-msg-num nil)] | |
135 ["List Sequences for Message" mh-msg-is-in-seq (mh-get-msg-num nil)] | |
136 ["Delete Message from Sequence..." mh-delete-msg-from-seq | |
137 (mh-get-msg-num nil)] | |
138 ["List Sequences in Folder..." mh-list-sequences t] | |
139 ["Delete Sequence..." mh-delete-seq t] | |
140 ["Narrow to Sequence..." mh-narrow-to-seq t] | |
141 ["Widen from Sequence" mh-widen mh-folder-view-stack] | |
142 "--" | |
143 ["Narrow to Subject Sequence" mh-narrow-to-subject t] | |
144 ["Narrow to Tick Sequence" mh-narrow-to-tick | |
145 (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq)))] | |
146 ["Delete Rest of Same Subject" mh-delete-subject t] | |
147 ["Toggle Tick Mark" mh-toggle-tick t] | |
148 "--" | |
149 ["Push State Out to MH" mh-update-sequences t])) | |
150 | |
151 ;;; Message Menu | |
152 | |
153 (easy-menu-define | |
154 mh-folder-message-menu mh-folder-mode-map "Menu for MH-E folder-message." | |
155 '("Message" | |
156 ["Show Message" mh-show (mh-get-msg-num nil)] | |
157 ["Show Message with Header" mh-header-display (mh-get-msg-num nil)] | |
82497
c490a6236b89
(mh-folder-message-menu, mh-folder-mode-map): Add
Jeffrey C Honig <jch@bsdi.com>
parents:
78479
diff
changeset
|
158 ["Show Message with Preferred Alternative" |
c490a6236b89
(mh-folder-message-menu, mh-folder-mode-map): Add
Jeffrey C Honig <jch@bsdi.com>
parents:
78479
diff
changeset
|
159 mh-show-preferred-alternative (mh-get-msg-num nil)] |
68465 | 160 ["Next Message" mh-next-undeleted-msg t] |
161 ["Previous Message" mh-previous-undeleted-msg t] | |
162 ["Go to First Message" mh-first-msg t] | |
163 ["Go to Last Message" mh-last-msg t] | |
164 ["Go to Message by Number..." mh-goto-msg t] | |
165 ["Modify Message" mh-modify t] | |
166 ["Delete Message" mh-delete-msg (mh-get-msg-num nil)] | |
167 ["Refile Message" mh-refile-msg (mh-get-msg-num nil)] | |
168 ["Undo Delete/Refile" mh-undo (mh-outstanding-commands-p)] | |
169 ["Execute Delete/Refile" mh-execute-commands | |
170 (mh-outstanding-commands-p)] | |
171 "--" | |
172 ["Compose a New Message" mh-send t] | |
173 ["Reply to Message..." mh-reply (mh-get-msg-num nil)] | |
174 ["Forward Message..." mh-forward (mh-get-msg-num nil)] | |
175 ["Redistribute Message..." mh-redistribute (mh-get-msg-num nil)] | |
176 ["Edit Message Again" mh-edit-again (mh-get-msg-num nil)] | |
177 ["Re-edit a Bounced Message" mh-extract-rejected-mail t] | |
178 "--" | |
179 ["Copy Message to Folder..." mh-copy-msg (mh-get-msg-num nil)] | |
180 ["Print Message" mh-print-msg (mh-get-msg-num nil)] | |
181 ["Write Message to File..." mh-write-msg-to-file | |
182 (mh-get-msg-num nil)] | |
183 ["Pipe Message to Command..." mh-pipe-msg (mh-get-msg-num nil)] | |
184 ["Unpack Uuencoded Message..." mh-store-msg (mh-get-msg-num nil)] | |
185 ["Burst Digest Message" mh-burst-digest (mh-get-msg-num nil)])) | |
186 | |
187 ;;; Folder Menu | |
188 | |
189 (easy-menu-define | |
190 mh-folder-folder-menu mh-folder-mode-map "Menu for MH-E folder." | |
191 '("Folder" | |
192 ["Incorporate New Mail" mh-inc-folder t] | |
193 ["Toggle Show/Folder" mh-toggle-showing t] | |
194 ["Execute Delete/Refile" mh-execute-commands | |
195 (mh-outstanding-commands-p)] | |
196 ["Rescan Folder" mh-rescan-folder t] | |
197 ["Thread Folder" mh-toggle-threads | |
198 (not (memq 'unthread mh-view-ops))] | |
199 ["Pack Folder" mh-pack-folder t] | |
200 ["Sort Folder" mh-sort-folder t] | |
201 "--" | |
202 ["List Folders" mh-list-folders t] | |
203 ["Visit a Folder..." mh-visit-folder t] | |
204 ["View New Messages" mh-index-new-messages t] | |
205 ["Search..." mh-search t] | |
206 "--" | |
207 ["Quit MH-E" mh-quit t])) | |
208 | |
209 | |
210 | |
211 ;;; MH-Folder Keys | |
212 | |
213 (suppress-keymap mh-folder-mode-map) | |
214 | |
215 ;; Use defalias to make sure the documented primary key bindings | |
216 ;; appear in menu lists. | |
217 (defalias 'mh-alt-show 'mh-show) | |
218 (defalias 'mh-alt-refile-msg 'mh-refile-msg) | |
219 (defalias 'mh-alt-send 'mh-send) | |
220 (defalias 'mh-alt-visit-folder 'mh-visit-folder) | |
221 | |
222 ;; Save the "b" binding for a future `back'. Maybe? | |
223 (gnus-define-keys mh-folder-mode-map | |
224 " " mh-page-msg | |
225 "!" mh-refile-or-write-again | |
226 "'" mh-toggle-tick | |
227 "," mh-header-display | |
228 "." mh-alt-show | |
82497
c490a6236b89
(mh-folder-message-menu, mh-folder-mode-map): Add
Jeffrey C Honig <jch@bsdi.com>
parents:
78479
diff
changeset
|
229 ":" mh-show-preferred-alternative |
68465 | 230 ";" mh-toggle-mh-decode-mime-flag |
231 ">" mh-write-msg-to-file | |
232 "?" mh-help | |
233 "E" mh-extract-rejected-mail | |
234 "M" mh-modify | |
235 "\177" mh-previous-page | |
236 "\C-d" mh-delete-msg-no-motion | |
237 "\t" mh-index-next-folder | |
238 [backtab] mh-index-previous-folder | |
239 "\M-\t" mh-index-previous-folder | |
240 "\e<" mh-first-msg | |
241 "\e>" mh-last-msg | |
242 "\ed" mh-redistribute | |
243 "\r" mh-show | |
244 "^" mh-alt-refile-msg | |
245 "c" mh-copy-msg | |
246 "d" mh-delete-msg | |
247 "e" mh-edit-again | |
248 "f" mh-forward | |
249 "g" mh-goto-msg | |
250 "i" mh-inc-folder | |
251 "k" mh-delete-subject-or-thread | |
252 "m" mh-alt-send | |
253 "n" mh-next-undeleted-msg | |
254 "\M-n" mh-next-unread-msg | |
255 "o" mh-refile-msg | |
256 "p" mh-previous-undeleted-msg | |
257 "\M-p" mh-previous-unread-msg | |
258 "q" mh-quit | |
259 "r" mh-reply | |
260 "s" mh-send | |
261 "t" mh-toggle-showing | |
262 "u" mh-undo | |
263 "v" mh-index-visit-folder | |
264 "x" mh-execute-commands | |
265 "|" mh-pipe-msg) | |
266 | |
267 (gnus-define-keys (mh-folder-map "F" mh-folder-mode-map) | |
268 "?" mh-prefix-help | |
269 "'" mh-index-ticked-messages | |
270 "S" mh-sort-folder | |
271 "c" mh-catchup | |
272 "f" mh-alt-visit-folder | |
273 "k" mh-kill-folder | |
274 "l" mh-list-folders | |
275 "n" mh-index-new-messages | |
276 "o" mh-alt-visit-folder | |
277 "p" mh-pack-folder | |
278 "q" mh-index-sequenced-messages | |
279 "r" mh-rescan-folder | |
280 "s" mh-search | |
281 "u" mh-undo-folder | |
282 "v" mh-visit-folder) | |
283 | |
284 (define-key mh-folder-mode-map "I" mh-inc-spool-map) | |
285 | |
286 (gnus-define-keys (mh-junk-map "J" mh-folder-mode-map) | |
287 "?" mh-prefix-help | |
288 "b" mh-junk-blacklist | |
289 "w" mh-junk-whitelist) | |
290 | |
291 (gnus-define-keys (mh-ps-print-map "P" mh-folder-mode-map) | |
292 "?" mh-prefix-help | |
293 "C" mh-ps-print-toggle-color | |
294 "F" mh-ps-print-toggle-faces | |
295 "f" mh-ps-print-msg-file | |
296 "l" mh-print-msg | |
297 "p" mh-ps-print-msg) | |
298 | |
299 (gnus-define-keys (mh-sequence-map "S" mh-folder-mode-map) | |
300 "'" mh-narrow-to-tick | |
301 "?" mh-prefix-help | |
302 "d" mh-delete-msg-from-seq | |
303 "k" mh-delete-seq | |
304 "l" mh-list-sequences | |
305 "n" mh-narrow-to-seq | |
306 "p" mh-put-msg-in-seq | |
307 "s" mh-msg-is-in-seq | |
308 "w" mh-widen) | |
309 | |
310 (gnus-define-keys (mh-thread-map "T" mh-folder-mode-map) | |
311 "?" mh-prefix-help | |
312 "u" mh-thread-ancestor | |
313 "p" mh-thread-previous-sibling | |
314 "n" mh-thread-next-sibling | |
315 "t" mh-toggle-threads | |
316 "d" mh-thread-delete | |
317 "o" mh-thread-refile) | |
318 | |
319 (gnus-define-keys (mh-limit-map "/" mh-folder-mode-map) | |
320 "'" mh-narrow-to-tick | |
321 "?" mh-prefix-help | |
322 "c" mh-narrow-to-cc | |
323 "g" mh-narrow-to-range | |
324 "m" mh-narrow-to-from | |
325 "s" mh-narrow-to-subject | |
326 "t" mh-narrow-to-to | |
327 "w" mh-widen) | |
328 | |
329 (gnus-define-keys (mh-extract-map "X" mh-folder-mode-map) | |
330 "?" mh-prefix-help | |
331 "s" mh-store-msg ;shar | |
332 "u" mh-store-msg) ;uuencode | |
333 | |
334 (gnus-define-keys (mh-digest-map "D" mh-folder-mode-map) | |
335 " " mh-page-digest | |
336 "?" mh-prefix-help | |
337 "\177" mh-page-digest-backwards | |
338 "b" mh-burst-digest) | |
339 | |
340 (gnus-define-keys (mh-mime-map "K" mh-folder-mode-map) | |
341 "?" mh-prefix-help | |
342 "a" mh-mime-save-parts | |
343 "e" mh-display-with-external-viewer | |
344 "i" mh-folder-inline-mime-part | |
345 "o" mh-folder-save-mime-part | |
346 "t" mh-toggle-mime-buttons | |
347 "v" mh-folder-toggle-mime-part | |
348 "\t" mh-next-button | |
349 [backtab] mh-prev-button | |
350 "\M-\t" mh-prev-button) | |
351 | |
352 (cond | |
86202
794e428cd497
* eshell/esh-util.el (eshell-under-xemacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82497
diff
changeset
|
353 ((featurep 'xemacs) |
68465 | 354 (define-key mh-folder-mode-map [button2] 'mh-show-mouse)) |
355 (t | |
356 (define-key mh-folder-mode-map [mouse-2] 'mh-show-mouse))) | |
357 | |
358 ;; "C-c /" prefix is used in mh-folder-mode by pgp.el and mailcrypt | |
359 | |
360 | |
361 | |
362 ;;; MH-Folder Help Messages | |
363 | |
364 ;; If you add a new prefix, add appropriate text to the nil key. | |
365 | |
366 ;; In general, messages are grouped logically. Taking the main commands for | |
367 ;; example, the first line is "ways to view messages," the second line is | |
368 ;; "things you can do with messages", and the third is "composing" messages. | |
369 | |
370 ;; When adding a new prefix, ensure that the help message contains "what" the | |
371 ;; prefix is for. For example, if the word "folder" were not present in the | |
372 ;; "F" entry, it would not be clear what these commands operated upon. | |
373 (defvar mh-folder-mode-help-messages | |
374 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n" | |
375 "[d]elete, [o]refile, e[x]ecute,\n" | |
376 "[s]end, [r]eply,\n" | |
377 "[;]toggle MIME decoding.\n" | |
378 "Prefix characters:\n [F]older, [S]equence, [J]unk, MIME [K]eys," | |
379 "\n [T]hread, [/]limit, e[X]tract, [D]igest, [I]nc spools.") | |
380 | |
381 (?F "[l]ist; [v]isit folder;\n" | |
382 "[n]ew messages; [']ticked messages; [s]earch;\n" | |
383 "[p]ack; [S]ort; [r]escan; [k]ill") | |
384 (?P "[p]rint message to [f]ile; old-style [l]pr printing;\n" | |
385 "Toggle printing of [C]olors, [F]aces") | |
386 (?S "[p]ut message in sequence, [n]arrow, [']narrow to ticked, [w]iden,\n" | |
387 "[s]equences, [l]ist,\n" | |
388 "[d]elete message from sequence, [k]ill sequence") | |
389 (?T "[t]oggle, [d]elete, [o]refile thread") | |
390 (?/ "Limit to [c]c, ran[g]e, fro[m], [s]ubject, [t]o; [w]iden") | |
391 (?X "un[s]har, [u]udecode message") | |
392 (?D "[b]urst digest") | |
393 (?K "[v]iew, [i]nline, [o]utput/save MIME part; save [a]ll parts; \n" | |
394 "[TAB] next; [SHIFT-TAB] previous") | |
395 (?J "[b]lacklist, [w]hitelist message")) | |
396 "Key binding cheat sheet. | |
397 See `mh-set-help'.") | |
398 | |
399 | |
400 | |
401 ;;; MH-Folder Font Lock | |
402 | |
403 (defvar mh-folder-font-lock-keywords | |
404 (list | |
405 ;; Folders when displaying index buffer | |
406 (list "^\\+.*" | |
407 '(0 'mh-search-folder)) | |
408 ;; Marked for deletion | |
409 (list (concat mh-scan-deleted-msg-regexp ".*") | |
410 '(0 'mh-folder-deleted)) | |
411 ;; Marked for refile | |
412 (list (concat mh-scan-refiled-msg-regexp ".*") | |
413 '(0 'mh-folder-refiled)) | |
414 ;; After subject | |
415 (list mh-scan-body-regexp | |
416 '(1 'mh-folder-body nil t)) | |
417 ;; Subject | |
418 '(mh-folder-font-lock-subject | |
419 (1 'mh-folder-followup append t) | |
420 (2 'mh-folder-subject append t)) | |
421 ;; Current message number | |
422 (list mh-scan-cur-msg-number-regexp | |
423 '(1 'mh-folder-cur-msg-number)) | |
424 ;; Message number | |
425 (list mh-scan-good-msg-regexp | |
426 '(1 'mh-folder-msg-number)) | |
427 ;; Date | |
428 (list mh-scan-date-regexp | |
429 '(1 'mh-folder-date)) | |
430 ;; Messages from me (To:) | |
431 (list mh-scan-rcpt-regexp | |
432 '(1 'mh-folder-to) | |
433 '(2 'mh-folder-address)) | |
434 ;; Messages to me | |
435 (list mh-scan-sent-to-me-sender-regexp | |
436 '(1 'mh-folder-sent-to-me-hint) | |
437 '(2 'mh-folder-sent-to-me-sender))) | |
438 "Keywords (regular expressions) used to fontify the MH-Folder buffer.") | |
439 | |
440 (defun mh-folder-font-lock-subject (limit) | |
441 "Return MH-E scan subject strings to font-lock between point and LIMIT." | |
442 (if (not (re-search-forward mh-scan-subject-regexp limit t)) | |
443 nil | |
444 (if (match-beginning 1) | |
445 (set-match-data (list (match-beginning 1) (match-end 3) | |
446 (match-beginning 1) (match-end 3) nil nil)) | |
447 (set-match-data (list (match-beginning 3) (match-end 3) | |
448 nil nil (match-beginning 3) (match-end 3)))) | |
449 t)) | |
450 | |
451 ;; Fontify unseen messages in bold. | |
452 | |
453 (defmacro mh-generate-sequence-font-lock (seq prefix face) | |
454 "Generate the appropriate code to fontify messages in SEQ. | |
455 PREFIX is used to generate unique names for the variables and | |
456 functions defined by the macro. So a different prefix should be | |
457 provided for every invocation. | |
458 FACE is the font-lock face used to display the matching scan lines." | |
459 (let ((cache (intern (format "mh-folder-%s-seq-cache" prefix))) | |
460 (func (intern (format "mh-folder-font-lock-%s" prefix)))) | |
461 `(progn | |
462 (defvar ,cache nil | |
463 "Internal cache variable used for font-lock in MH-E. | |
464 Should only be non-nil through font-lock stepping, and nil once | |
465 font-lock is done highlighting.") | |
466 (make-variable-buffer-local ',cache) | |
467 | |
468 (defun ,func (limit) | |
469 "Return unseen message lines to font-lock between point and LIMIT." | |
470 (if (not ,cache) (setq ,cache (mh-seq-msgs (mh-find-seq ,seq)))) | |
471 (let ((cur-msg (mh-get-msg-num nil))) | |
472 (cond ((not ,cache) | |
473 nil) | |
474 ((>= (point) limit) ;Presumably at end of buffer | |
475 (setq ,cache nil) | |
476 nil) | |
477 ((member cur-msg ,cache) | |
478 (let ((bpoint (progn (beginning-of-line)(point))) | |
479 (epoint (progn (forward-line 1)(point)))) | |
480 (if (<= limit (point)) (setq ,cache nil)) | |
481 (set-match-data (list bpoint epoint bpoint epoint)) | |
482 t)) | |
483 (t | |
484 ;; move forward one line at a time, checking each message | |
485 (while (and (= 0 (forward-line 1)) | |
486 (> limit (point)) | |
487 (not (member (mh-get-msg-num nil) ,cache)))) | |
488 ;; Examine how we must have exited the loop... | |
489 (let ((cur-msg (mh-get-msg-num nil))) | |
490 (cond ((or (<= limit (point)) | |
491 (not (member cur-msg ,cache))) | |
492 (setq ,cache nil) | |
493 nil) | |
494 ((member cur-msg ,cache) | |
495 (let ((bpoint (progn (beginning-of-line) (point))) | |
496 (epoint (progn (forward-line 1) (point)))) | |
497 (if (<= limit (point)) (setq ,cache nil)) | |
498 (set-match-data | |
499 (list bpoint epoint bpoint epoint)) | |
500 t)))))))) | |
501 | |
502 (setq mh-folder-font-lock-keywords | |
503 (append mh-folder-font-lock-keywords | |
504 (list (list ',func (list 1 '',face 'prepend t)))))))) | |
505 | |
506 (mh-generate-sequence-font-lock mh-unseen-seq unseen bold) | |
507 (mh-generate-sequence-font-lock mh-tick-seq tick mh-folder-tick) | |
508 | |
509 | |
510 | |
511 ;;; MH-Folder Mode | |
512 | |
513 (defmacro mh-remove-xemacs-horizontal-scrollbar () | |
514 "Get rid of the horizontal scrollbar that XEmacs insists on putting in." | |
86202
794e428cd497
* eshell/esh-util.el (eshell-under-xemacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82497
diff
changeset
|
515 (when (featurep 'xemacs) |
68465 | 516 `(if (and (featurep 'scrollbar) |
517 (fboundp 'set-specifier)) | |
518 (set-specifier horizontal-scrollbar-visible-p nil | |
519 (cons (current-buffer) nil))))) | |
520 | |
521 ;; Register mh-folder-mode as supporting which-function-mode... | |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
522 (mh-require 'which-func nil t) |
68465 | 523 (when (boundp 'which-func-modes) |
524 (add-to-list 'which-func-modes 'mh-folder-mode)) | |
525 | |
526 ;; Shush compiler. | |
70028
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
69712
diff
changeset
|
527 (defvar desktop-save-buffer) |
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
69712
diff
changeset
|
528 (defvar font-lock-auto-fontify) |
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
69712
diff
changeset
|
529 (defvar font-lock-defaults) ; XEmacs |
68465 | 530 |
531 ;; Ensure new buffers won't get this mode if default-major-mode is nil. | |
532 (put 'mh-folder-mode 'mode-class 'special) | |
533 | |
534 ;; Autoload cookie needed by desktop.el | |
535 ;;;###autoload | |
536 (define-derived-mode mh-folder-mode fundamental-mode "MH-Folder" | |
537 "Major MH-E mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map> | |
538 | |
539 You can show the message the cursor is pointing to, and step through | |
540 the messages. Messages can be marked for deletion or refiling into | |
541 another folder; these commands are executed all at once with a | |
542 separate command. | |
543 | |
544 Options that control this mode can be changed with | |
545 \\[customize-group]; specify the \"mh\" group. In particular, please | |
546 see the `mh-scan-format-file' option if you wish to modify scan's | |
547 format. | |
548 | |
549 When a folder is visited, the hook `mh-folder-mode-hook' is run. | |
550 | |
551 Ranges | |
552 ====== | |
553 Many commands that operate on individual messages, such as | |
554 `mh-forward' or `mh-refile-msg' take a RANGE argument. This argument | |
555 can be used in several ways. | |
556 | |
557 If you provide the prefix argument (\\[universal-argument]) to | |
558 these commands, then you will be prompted for the message range. | |
559 This can be any valid MH range which can include messages, | |
560 sequences, and the abbreviations (described in the mh(1) man | |
561 page): | |
562 | |
563 <num1>-<num2> | |
564 Indicates all messages in the range <num1> to <num2>, inclusive. | |
565 The range must be nonempty. | |
566 | |
567 <num>:N | |
568 <num>:+N | |
569 <num>:-N | |
570 Up to N messages beginning with (or ending with) message num. Num | |
571 may be any of the predefined symbols: first, prev, cur, next or | |
572 last. | |
573 | |
574 first:N | |
575 prev:N | |
576 next:N | |
577 last:N | |
578 The first, previous, next or last messages, if they exist. | |
579 | |
580 all | |
581 All of the messages. | |
582 | |
583 For example, a range that shows all of these things is `1 2 3 | |
584 5-10 last:5 unseen'. | |
585 | |
586 If the option `transient-mark-mode' is set to t and you set a | |
587 region in the MH-Folder buffer, then the MH-E command will | |
588 perform the operation on all messages in that region. | |
589 | |
590 \\{mh-folder-mode-map}" | |
591 (mh-do-in-gnu-emacs | |
70145
00cb3fe5fed5
* mh-tool-bar.el (image-load-path): Define to shush compiler.
Bill Wohler <wohler@newt.com>
parents:
70028
diff
changeset
|
592 (unless mh-folder-tool-bar-map |
00cb3fe5fed5
* mh-tool-bar.el (image-load-path): Define to shush compiler.
Bill Wohler <wohler@newt.com>
parents:
70028
diff
changeset
|
593 (mh-tool-bar-folder-buttons-init)) |
95843 | 594 (if (boundp 'tool-bar-map) |
595 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map))) | |
69245
f3bbf5f32462
* mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents:
68529
diff
changeset
|
596 (mh-do-in-xemacs |
f3bbf5f32462
* mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents:
68529
diff
changeset
|
597 (mh-tool-bar-init :folder)) |
68465 | 598 (make-local-variable 'font-lock-defaults) |
599 (setq font-lock-defaults '(mh-folder-font-lock-keywords t)) | |
600 (make-local-variable 'desktop-save-buffer) | |
601 (setq desktop-save-buffer t) | |
602 (mh-make-local-vars | |
603 'mh-colors-available-flag (mh-colors-available-p) | |
604 ; Do we have colors available | |
605 'mh-current-folder (buffer-name) ; Name of folder, a string | |
606 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs | |
607 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/" | |
608 (file-name-as-directory (mh-expand-file-name (buffer-name))) | |
609 'mh-display-buttons-for-inline-parts-flag | |
610 mh-display-buttons-for-inline-parts-flag ; Allow for display of buttons to | |
611 ; be toggled. | |
612 'mh-arrow-marker (make-marker) ; Marker where arrow is displayed | |
613 'overlay-arrow-position nil ; Allow for simultaneous display in | |
614 'overlay-arrow-string ">" ; different MH-E buffers. | |
615 'mh-showing-mode nil ; Show message also? | |
616 'mh-delete-list nil ; List of msgs nums to delete | |
617 'mh-refile-list nil ; List of folder names in mh-seq-list | |
618 'mh-seq-list nil ; Alist of (seq . msgs) nums | |
619 'mh-seen-list nil ; List of displayed messages | |
620 'mh-next-direction 'forward ; Direction to move to next message | |
621 'mh-view-ops () ; Stack that keeps track of the order | |
622 ; in which narrowing/threading has been | |
623 ; carried out. | |
624 'mh-folder-view-stack () ; Stack of previous views of the | |
625 ; folder. | |
626 'mh-index-data nil ; If the folder was created by a call | |
627 ; to mh-search, this contains info | |
628 ; about the search results. | |
629 'mh-index-previous-search nil ; folder, indexer, search-regexp | |
630 'mh-index-msg-checksum-map nil ; msg -> checksum map | |
631 'mh-index-checksum-origin-map nil ; checksum -> ( orig-folder, orig-msg ) | |
632 'mh-index-sequence-search-flag nil ; folder resulted from sequence search | |
633 'mh-first-msg-num nil ; Number of first msg in buffer | |
634 'mh-last-msg-num nil ; Number of last msg in buffer | |
635 'mh-msg-count nil ; Number of msgs in buffer | |
636 'mh-mode-line-annotation nil ; Indicates message range | |
637 'mh-sequence-notation-history (make-hash-table) | |
638 ; Remember what is overwritten by | |
639 ; mh-note-seq. | |
640 'imenu-create-index-function 'mh-index-create-imenu-index | |
641 ; Setup imenu support | |
642 'mh-previous-window-config nil) ; Previous window configuration | |
643 (mh-remove-xemacs-horizontal-scrollbar) | |
644 (setq truncate-lines t) | |
645 (auto-save-mode -1) | |
646 (setq buffer-offer-save t) | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68474
diff
changeset
|
647 (mh-make-local-hook (mh-write-file-functions)) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68474
diff
changeset
|
648 (add-hook (mh-write-file-functions) 'mh-execute-commands nil t) |
68465 | 649 (make-local-variable 'revert-buffer-function) |
650 (make-local-variable 'hl-line-mode) ; avoid pollution | |
651 (mh-funcall-if-exists hl-line-mode 1) | |
652 (setq revert-buffer-function 'mh-undo-folder) | |
68474
07c20c57ee3d
(mh-folder-mode): Use add-to-list to modify minor-mode-alias.
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
653 (add-to-list 'minor-mode-alist '(mh-showing-mode " Show")) |
68465 | 654 (easy-menu-add mh-folder-sequence-menu) |
655 (easy-menu-add mh-folder-message-menu) | |
656 (easy-menu-add mh-folder-folder-menu) | |
657 (mh-inc-spool-make) | |
658 (mh-set-help mh-folder-mode-help-messages) | |
86202
794e428cd497
* eshell/esh-util.el (eshell-under-xemacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82497
diff
changeset
|
659 (if (and (featurep 'xemacs) |
68465 | 660 font-lock-auto-fontify) |
661 (turn-on-font-lock))) ; Force font-lock in XEmacs. | |
662 | |
663 | |
664 | |
665 ;;; MH-Folder Commands | |
666 | |
667 ;; Alphabetical. | |
668 ;; See also mh-comp.el, mh-junk.el, mh-mime.el, mh-print.el, | |
669 ;; mh-search.el, and mh-seq.el. | |
670 | |
671 ;;;###mh-autoload | |
672 (defun mh-delete-msg (range) | |
673 "Delete RANGE\\<mh-folder-mode-map>. | |
674 | |
675 To mark a message for deletion, use this command. A \"D\" is | |
676 placed by the message in the scan window, and the next undeleted | |
677 message is displayed. If the previous command had been | |
678 \\[mh-previous-undeleted-msg], then the next message displayed is | |
679 the first undeleted message previous to the message just deleted. | |
680 Use \\[mh-next-undeleted-msg] to force subsequent | |
681 \\[mh-delete-msg] commands to move forward to the next undeleted | |
682 message after deleting the message under the cursor. | |
683 | |
684 The hook `mh-delete-msg-hook' is called after you mark a message | |
685 for deletion. For example, a past maintainer of MH-E used this | |
686 once when he kept statistics on his mail usage. | |
687 | |
688 Check the documentation of `mh-interactive-range' to see how | |
689 RANGE is read in interactive use." | |
690 (interactive (list (mh-interactive-range "Delete"))) | |
691 (mh-delete-msg-no-motion range) | |
692 (if (looking-at mh-scan-deleted-msg-regexp) | |
693 (mh-next-msg))) | |
694 | |
695 ;;;###mh-autoload | |
696 (defun mh-delete-msg-no-motion (range) | |
697 "Delete RANGE, don't move to next message. | |
698 | |
699 This command marks the RANGE for deletion but leaves the cursor | |
700 at the current message in case you wish to perform other | |
701 operations on the message. | |
702 | |
703 Check the documentation of `mh-interactive-range' to see how | |
704 RANGE is read in interactive use." | |
705 (interactive (list (mh-interactive-range "Delete"))) | |
706 (mh-iterate-on-range () range | |
707 (mh-delete-a-msg nil))) | |
708 | |
709 ;;;###mh-autoload | |
710 (defun mh-execute-commands () | |
711 "Process outstanding delete and refile requests\\<mh-folder-mode-map>. | |
712 | |
713 If you've marked messages to be deleted or refiled and you want | |
714 to go ahead and delete or refile the messages, use this command. | |
715 Many MH-E commands that may affect the numbering of the | |
716 messages (such as \\[mh-rescan-folder] or \\[mh-pack-folder]) | |
717 will ask if you want to process refiles or deletes first and then | |
718 either run this command for you or undo the pending refiles and | |
69712
3981e84d0b79
* mh-folder.el (mh-execute-commands, mh-rescan-folder):
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
719 deletes. |
68465 | 720 |
721 This function runs `mh-before-commands-processed-hook' before the | |
722 commands are processed and `mh-after-commands-processed-hook' | |
723 after the commands are processed." | |
724 (interactive) | |
725 (if mh-folder-view-stack (mh-widen t)) | |
726 (mh-process-commands mh-current-folder) | |
727 (mh-set-scan-mode) | |
728 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency | |
729 (mh-make-folder-mode-line) | |
730 t) ; return t for write-file-functions | |
731 | |
732 ;;;###mh-autoload | |
733 (defun mh-first-msg () | |
734 "Display first message." | |
735 (interactive) | |
736 (goto-char (point-min)) | |
737 (while (and (not (eobp)) (not (looking-at mh-scan-valid-regexp))) | |
738 (forward-line 1))) | |
739 | |
740 ;;;###mh-autoload | |
741 (defun mh-goto-msg (number &optional no-error-if-no-message dont-show) | |
742 "Go to a message\\<mh-folder-mode-map>. | |
743 | |
744 You can enter the message NUMBER either before or after typing | |
745 \\[mh-goto-msg]. In the latter case, Emacs prompts you. | |
746 | |
747 In a program, optional non-nil second argument NO-ERROR-IF-NO-MESSAGE | |
748 means return nil instead of signaling an error if message does not | |
749 exist\; in this case, the cursor is positioned near where the message | |
750 would have been. Non-nil third argument DONT-SHOW means not to show | |
751 the message." | |
752 (interactive "NGo to message: ") | |
753 (setq number (prefix-numeric-value number)) | |
754 (let ((point (point)) | |
755 (return-value t)) | |
756 (goto-char (point-min)) | |
757 (unless (re-search-forward (format (mh-scan-msg-search-regexp) number) | |
758 nil t) | |
759 (goto-char point) | |
760 (unless no-error-if-no-message | |
761 (error "No message %d" number)) | |
762 (setq return-value nil)) | |
763 (beginning-of-line) | |
764 (or dont-show (not return-value) (mh-maybe-show number)) | |
765 return-value)) | |
766 | |
767 ;;;###mh-autoload | |
768 (defun mh-inc-folder (&optional file folder) | |
769 "Incorporate new mail into a folder. | |
770 | |
771 You can incorporate mail from any file into the current folder by | |
772 specifying a prefix argument; you'll be prompted for the name of | |
773 the FILE to use as well as the destination FOLDER | |
774 | |
775 The hook `mh-inc-folder-hook' is run after incorporating new | |
776 mail. | |
777 | |
778 Do not call this function from outside MH-E; use \\[mh-rmail] | |
779 instead." | |
780 (interactive (list (if current-prefix-arg | |
781 (expand-file-name | |
782 (read-file-name "inc mail from file: " | |
783 mh-user-path))) | |
784 (if current-prefix-arg | |
785 (mh-prompt-for-folder "inc mail into" mh-inbox t)))) | |
786 (if (not folder) | |
787 (setq folder mh-inbox)) | |
788 (let ((threading-needed-flag nil)) | |
789 (let ((config (current-window-configuration))) | |
790 (when (and mh-show-buffer (get-buffer mh-show-buffer)) | |
791 (delete-windows-on mh-show-buffer)) | |
792 (cond ((not (get-buffer folder)) | |
793 (mh-make-folder folder) | |
794 (setq threading-needed-flag mh-show-threads-flag) | |
795 (setq mh-previous-window-config config)) | |
796 ((not (eq (current-buffer) (get-buffer folder))) | |
797 (switch-to-buffer folder) | |
798 (setq mh-previous-window-config config)))) | |
799 (mh-get-new-mail file) | |
800 (when (and threading-needed-flag | |
801 (save-excursion | |
802 (goto-char (point-min)) | |
803 (or (null mh-large-folder) | |
804 (not (equal (forward-line (1+ mh-large-folder)) 0)) | |
805 (and (message "Not threading since the number of messages exceeds `mh-large-folder'") | |
806 nil)))) | |
807 (mh-toggle-threads)) | |
808 (beginning-of-line) | |
809 (if (and mh-showing-mode (looking-at mh-scan-valid-regexp)) (mh-show)) | |
810 (run-hooks 'mh-inc-folder-hook))) | |
811 | |
812 ;;;###mh-autoload | |
813 (defun mh-last-msg () | |
814 "Display last message." | |
815 (interactive) | |
816 (goto-char (point-max)) | |
817 (while (and (not (bobp)) (not (looking-at mh-scan-valid-regexp))) | |
818 (forward-line -1)) | |
819 (mh-recenter nil)) | |
820 | |
821 ;;;###mh-autoload | |
822 (defun mh-modify (&optional message) | |
823 "Edit message. | |
824 | |
825 There are times when you need to edit a message. For example, you | |
826 may need to fix a broken Content-Type header field. You can do | |
827 this with this command. It displays the raw message in an | |
828 editable buffer. When you are done editing, save and kill the | |
829 buffer as you would any other. | |
830 | |
831 From a program, edit MESSAGE; nil means edit current message." | |
832 (interactive) | |
833 (let* ((message (or message (mh-get-msg-num t))) | |
834 (msg-filename (mh-msg-filename message)) | |
835 edit-buffer) | |
836 (when (not (file-exists-p msg-filename)) | |
837 (error "Message %d does not exist" message)) | |
838 | |
839 ;; Invalidate the show buffer if it is showing the same message that is | |
840 ;; to be edited. | |
841 (when (and (buffer-live-p (get-buffer mh-show-buffer)) | |
842 (equal (save-excursion (set-buffer mh-show-buffer) | |
843 buffer-file-name) | |
844 msg-filename)) | |
845 (mh-invalidate-show-buffer)) | |
846 | |
847 ;; Edit message | |
848 (find-file msg-filename) | |
849 (setq edit-buffer (current-buffer)) | |
850 | |
851 ;; Set buffer properties | |
852 (mh-letter-mode) | |
853 (use-local-map text-mode-map) | |
854 | |
855 ;; Just show the edit buffer... | |
856 (delete-other-windows) | |
857 (switch-to-buffer edit-buffer))) | |
858 | |
859 ;;;###mh-autoload | |
860 (defun mh-next-button (&optional backward-flag) | |
861 "Go to the next button. | |
862 | |
863 If the end of the buffer is reached then the search wraps over to | |
864 the start of the buffer. | |
865 | |
866 If an optional prefix argument BACKWARD-FLAG is given, the cursor | |
867 will move to the previous button." | |
868 (interactive (list current-prefix-arg)) | |
869 (unless mh-showing-mode | |
870 (mh-show)) | |
871 (mh-in-show-buffer (mh-show-buffer) | |
872 (mh-goto-next-button backward-flag))) | |
873 | |
874 ;;;###mh-autoload | |
875 (defun mh-next-undeleted-msg (&optional count wait-after-complaining-flag) | |
876 "Display next message. | |
877 | |
878 This command can be given a prefix argument COUNT to specify how | |
879 many unread messages to skip. | |
880 | |
881 In a program, pause for a second after printing message if we are | |
882 at the last undeleted message and optional argument | |
883 WAIT-AFTER-COMPLAINING-FLAG is non-nil." | |
884 (interactive "p") | |
885 (setq mh-next-direction 'forward) | |
886 (forward-line 1) | |
887 (cond ((re-search-forward mh-scan-good-msg-regexp nil t count) | |
888 (beginning-of-line) | |
889 (mh-maybe-show)) | |
890 (t (forward-line -1) | |
891 (message "No more undeleted messages") | |
892 (if wait-after-complaining-flag (sit-for 1))))) | |
893 | |
894 ;;;###mh-autoload | |
895 (defun mh-next-unread-msg (&optional count) | |
896 "Display next unread message. | |
897 | |
898 This command can be given a prefix argument COUNT to specify how | |
899 many unread messages to skip." | |
900 (interactive "p") | |
901 (unless (> count 0) | |
902 (error "The function `mh-next-unread-msg' expects positive argument")) | |
903 (setq count (1- count)) | |
904 (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list)))) | |
905 (cur-msg (mh-get-msg-num nil))) | |
906 (cond ((and (not cur-msg) (not (bobp)) | |
907 ;; If we are at the end of the buffer back up one line and go | |
908 ;; to unread message after that. | |
909 (progn | |
910 (forward-line -1) | |
911 (setq cur-msg (mh-get-msg-num nil))) | |
912 nil)) | |
913 ((or (null unread-sequence) (not cur-msg)) | |
914 ;; No unread message or there aren't any messages in buffer... | |
915 (message "No more unread messages")) | |
916 ((progn | |
917 ;; Skip messages | |
918 (while (and unread-sequence (>= cur-msg (car unread-sequence))) | |
919 (setq unread-sequence (cdr unread-sequence))) | |
920 (while (> count 0) | |
921 (setq unread-sequence (cdr unread-sequence)) | |
922 (setq count (1- count))) | |
923 (not (car unread-sequence))) | |
924 (message "No more unread messages")) | |
925 (t (loop for msg in unread-sequence | |
926 when (mh-goto-msg msg t) return nil | |
927 finally (message "No more unread messages")))))) | |
928 | |
929 ;;;###mh-autoload | |
930 (defun mh-page-msg (&optional lines) | |
931 "Display next page in message. | |
932 | |
933 You can give this command a prefix argument that specifies the | |
934 number of LINES to scroll. This command will also show the next | |
935 undeleted message if it is used at the bottom of a message." | |
936 (interactive "P") | |
937 (if mh-showing-mode | |
938 (if mh-page-to-next-msg-flag | |
939 (if (equal mh-next-direction 'backward) | |
940 (mh-previous-undeleted-msg) | |
941 (mh-next-undeleted-msg)) | |
942 (if (mh-in-show-buffer (mh-show-buffer) | |
943 (pos-visible-in-window-p (point-max))) | |
944 (progn | |
945 (message | |
946 "End of message (Type %s to read %s undeleted message)" | |
947 (single-key-description last-input-event) | |
948 (if (equal mh-next-direction 'backward) | |
949 "previous" | |
950 "next")) | |
951 (setq mh-page-to-next-msg-flag t)) | |
952 (scroll-other-window lines))) | |
953 (mh-show))) | |
954 | |
955 ;;;###mh-autoload | |
956 (defun mh-prev-button () | |
957 "Go to the previous button. | |
958 | |
959 If the beginning of the buffer is reached then the search wraps | |
960 over to the end of the buffer." | |
961 (interactive) | |
962 (mh-next-button t)) | |
963 | |
964 ;;;###mh-autoload | |
965 (defun mh-previous-page (&optional lines) | |
966 "Display next page in message. | |
967 | |
968 You can give this command a prefix argument that specifies the | |
969 number of LINES to scroll." | |
970 (interactive "P") | |
971 (mh-in-show-buffer (mh-show-buffer) | |
972 (scroll-down lines))) | |
973 | |
974 ;;;###mh-autoload | |
975 (defun mh-previous-undeleted-msg (&optional count wait-after-complaining-flag) | |
976 "Display previous message. | |
977 | |
978 This command can be given a prefix argument COUNT to specify how | |
979 many unread messages to skip. | |
980 | |
981 In a program, pause for a second after printing message if we are | |
982 at the last undeleted message and optional argument | |
983 WAIT-AFTER-COMPLAINING-FLAG is non-nil." | |
984 (interactive "p") | |
985 (setq mh-next-direction 'backward) | |
986 (beginning-of-line) | |
987 (cond ((re-search-backward mh-scan-good-msg-regexp nil t count) | |
988 (mh-maybe-show)) | |
989 (t (message "No previous undeleted message") | |
990 (if wait-after-complaining-flag (sit-for 1))))) | |
991 | |
992 ;;;###mh-autoload | |
993 (defun mh-previous-unread-msg (&optional count) | |
994 "Display previous unread message. | |
995 | |
996 This command can be given a prefix argument COUNT to specify how | |
997 many unread messages to skip." | |
998 (interactive "p") | |
999 (unless (> count 0) | |
1000 (error "The function `mh-previous-unread-msg' expects positive argument")) | |
1001 (setq count (1- count)) | |
1002 (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list))) | |
1003 (cur-msg (mh-get-msg-num nil))) | |
1004 (cond ((and (not cur-msg) (not (bobp)) | |
1005 ;; If we are at the end of the buffer back up one line and go | |
1006 ;; to unread message after that. | |
1007 (progn | |
1008 (forward-line -1) | |
1009 (setq cur-msg (mh-get-msg-num nil))) | |
1010 nil)) | |
1011 ((or (null unread-sequence) (not cur-msg)) | |
1012 ;; No unread message or there aren't any messages in buffer... | |
1013 (message "No more unread messages")) | |
1014 ((progn | |
1015 ;; Skip count messages... | |
1016 (while (and unread-sequence (>= (car unread-sequence) cur-msg)) | |
1017 (setq unread-sequence (cdr unread-sequence))) | |
1018 (while (> count 0) | |
1019 (setq unread-sequence (cdr unread-sequence)) | |
1020 (setq count (1- count))) | |
1021 (not (car unread-sequence))) | |
1022 (message "No more unread messages")) | |
1023 (t (loop for msg in unread-sequence | |
1024 when (mh-goto-msg msg t) return nil | |
1025 finally (message "No more unread messages")))))) | |
1026 | |
1027 ;;;###mh-autoload | |
1028 (defun mh-quit () | |
1029 "Quit the current MH-E folder. | |
1030 | |
1031 When you want to quit using MH-E and go back to editing, you can use | |
1032 this command. This buries the buffers of the current MH-E folder and | |
1033 restores the buffers that were present when you first ran | |
1034 \\[mh-rmail]. It also removes any MH-E working buffers whose name | |
1035 begins with \" *mh-\" or \"*MH-E \". You can later restore your MH-E | |
1036 session by selecting the \"+inbox\" buffer or by running \\[mh-rmail] | |
1037 again. | |
1038 | |
1039 The two hooks `mh-before-quit-hook' and `mh-quit-hook' are called by | |
1040 this function. The former one is called before the quit occurs, so you | |
1041 might use it to perform any MH-E operations; you could perform some | |
1042 query and abort the quit or call `mh-execute-commands', for example. | |
1043 The latter is not run in an MH-E context, so you might use it to | |
1044 modify the window setup." | |
1045 (interactive) | |
1046 (run-hooks 'mh-before-quit-hook) | |
1047 (let ((show-buffer (get-buffer mh-show-buffer))) | |
1048 (when show-buffer | |
1049 (kill-buffer show-buffer))) | |
1050 (mh-update-sequences) | |
1051 (mh-destroy-postponed-handles) | |
1052 (bury-buffer (current-buffer)) | |
1053 | |
1054 ;; Delete all MH-E temporary and working buffers. | |
1055 (dolist (buffer (buffer-list)) | |
1056 (when (or (string-match "^ \\*mh-" (buffer-name buffer)) | |
1057 (string-match "^\\*MH-E " (buffer-name buffer))) | |
1058 (kill-buffer buffer))) | |
1059 | |
1060 (if mh-previous-window-config | |
1061 (set-window-configuration mh-previous-window-config)) | |
1062 (run-hooks 'mh-quit-hook)) | |
1063 | |
1064 ;;;###mh-autoload | |
1065 (defun mh-refile-msg (range folder &optional dont-update-last-destination-flag) | |
1066 "Refile (output) RANGE into FOLDER. | |
1067 | |
1068 You are prompted for the folder name. Note that this command can also | |
1069 be used to create folders. If you specify a folder that does not | |
1070 exist, you will be prompted to create it. | |
1071 | |
1072 The hook `mh-refile-msg-hook' is called after a message is marked to | |
1073 be refiled. | |
1074 | |
1075 Check the documentation of `mh-interactive-range' to see how RANGE is | |
1076 read in interactive use. | |
1077 | |
1078 In a program, the variables `mh-last-destination' and | |
1079 `mh-last-destination-folder' are not updated if | |
1080 DONT-UPDATE-LAST-DESTINATION-FLAG is non-nil." | |
1081 (interactive (list (mh-interactive-range "Refile") | |
1082 (intern (mh-prompt-for-refile-folder)))) | |
1083 (unless dont-update-last-destination-flag | |
1084 (setq mh-last-destination (cons 'refile folder) | |
1085 mh-last-destination-folder mh-last-destination)) | |
1086 (mh-iterate-on-range () range | |
1087 (mh-refile-a-msg nil folder)) | |
1088 (when (looking-at mh-scan-refiled-msg-regexp) (mh-next-msg))) | |
1089 | |
1090 ;;;###mh-autoload | |
1091 (defun mh-refile-or-write-again (range &optional interactive-flag) | |
1092 "Repeat last output command. | |
1093 | |
1094 If you are refiling several messages into the same folder, you | |
1095 can use this command to repeat the last | |
1096 refile (\\[mh-refile-msg]) or write (\\[mh-write-msg-to-file]). | |
1097 You can use a range. | |
1098 | |
1099 Check the documentation of `mh-interactive-range' to see how RANGE is | |
1100 read in interactive use. | |
1101 | |
1102 In a program, a non-nil INTERACTIVE-FLAG means that the function was | |
1103 called interactively." | |
1104 (interactive (list (mh-interactive-range "Redo") t)) | |
1105 (if (null mh-last-destination) | |
1106 (error "No previous refile or write")) | |
1107 (cond ((eq (car mh-last-destination) 'refile) | |
1108 (mh-refile-msg range (cdr mh-last-destination)) | |
1109 (message "Destination folder: %s" (cdr mh-last-destination))) | |
1110 (t | |
1111 (mh-iterate-on-range msg range | |
1112 (apply 'mh-write-msg-to-file msg (cdr mh-last-destination))) | |
1113 (mh-next-msg interactive-flag)))) | |
1114 | |
1115 ;;;###mh-autoload | |
1116 (defun mh-rescan-folder (&optional range dont-exec-pending) | |
1117 "Rescan folder\\<mh-folder-mode-map>. | |
1118 | |
1119 This command is useful to grab all messages in your \"+inbox\" after | |
1120 processing your new mail for the first time. If you don't want to | |
1121 rescan the entire folder, this command will accept a RANGE. Check the | |
1122 documentation of `mh-interactive-range' to see how RANGE is read in | |
1123 interactive use. | |
1124 | |
1125 This command will ask if you want to process refiles or deletes first | |
1126 and then either run \\[mh-execute-commands] for you or undo the | |
69712
3981e84d0b79
* mh-folder.el (mh-execute-commands, mh-rescan-folder):
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
1127 pending refiles and deletes. |
68465 | 1128 |
1129 In a program, the processing of outstanding commands is not performed | |
1130 if DONT-EXEC-PENDING is non-nil." | |
1131 (interactive (list (if current-prefix-arg | |
1132 (mh-read-range "Rescan" mh-current-folder t nil t | |
1133 mh-interpret-number-as-range-flag) | |
1134 nil))) | |
1135 (setq mh-next-direction 'forward) | |
1136 (let ((threaded-flag (memq 'unthread mh-view-ops)) | |
1137 (msg-num (mh-get-msg-num nil))) | |
1138 (mh-scan-folder mh-current-folder (or range "all") dont-exec-pending) | |
1139 ;; If there isn't a cur sequence, mh-scan-folder goes to the first message. | |
1140 ;; Try to stay where we were. | |
1141 (if (null (car (mh-seq-to-msgs 'cur))) | |
1142 (mh-goto-msg msg-num t t)) | |
1143 (cond (threaded-flag (mh-toggle-threads)) | |
1144 (mh-index-data (mh-index-insert-folder-headers))))) | |
1145 | |
1146 (defun mh-show-mouse (event) | |
1147 "Move point to mouse EVENT and show message." | |
1148 (interactive "e") | |
1149 (mouse-set-point event) | |
1150 (mh-show)) | |
1151 | |
1152 ;;;###mh-autoload | |
1153 (defun mh-toggle-showing () | |
1154 "Toggle between MH-Folder and MH-Folder Show modes. | |
1155 | |
1156 This command switches between MH-Folder mode and MH-Folder Show | |
1157 mode. MH-Folder mode turns off the associated show buffer so that | |
1158 you can perform operations on the messages quickly without | |
1159 reading them. This is an excellent way to prune out your junk | |
1160 mail or to refile a group of messages to another folder for later | |
1161 examination." | |
1162 (interactive) | |
1163 (if mh-showing-mode | |
1164 (mh-set-scan-mode) | |
1165 (mh-show))) | |
1166 | |
1167 ;;;###mh-autoload | |
1168 (defun mh-undo (range) | |
1169 "Undo pending deletes or refiles in RANGE. | |
1170 | |
1171 If you've deleted a message or refiled it, but changed your mind, | |
1172 you can cancel the action before you've executed it. Use this | |
1173 command to undo a refile on or deletion of a single message. You | |
1174 can also undo refiles and deletes for messages that are found in | |
1175 a given RANGE. | |
1176 | |
1177 Check the documentation of `mh-interactive-range' to see how | |
1178 RANGE is read in interactive use." | |
1179 (interactive (list (mh-interactive-range "Undo"))) | |
1180 (cond ((numberp range) | |
1181 (let ((original-position (point))) | |
1182 (beginning-of-line) | |
1183 (while (not (or (looking-at mh-scan-deleted-msg-regexp) | |
1184 (looking-at mh-scan-refiled-msg-regexp) | |
1185 (and (eq mh-next-direction 'forward) (bobp)) | |
1186 (and (eq mh-next-direction 'backward) | |
1187 (save-excursion (forward-line) (eobp))))) | |
1188 (forward-line (if (eq mh-next-direction 'forward) -1 1))) | |
1189 (if (or (looking-at mh-scan-deleted-msg-regexp) | |
1190 (looking-at mh-scan-refiled-msg-regexp)) | |
1191 (progn | |
1192 (mh-undo-msg (mh-get-msg-num t)) | |
1193 (mh-maybe-show)) | |
1194 (goto-char original-position) | |
1195 (error "Nothing to undo")))) | |
1196 (t (mh-iterate-on-range () range | |
1197 (mh-undo-msg nil)))) | |
1198 (if (not (mh-outstanding-commands-p)) | |
1199 (mh-set-folder-modified-p nil))) | |
1200 | |
1201 ;;;###mh-autoload | |
1202 (defun mh-visit-folder (folder &optional range index-data) | |
1203 "Visit FOLDER. | |
1204 | |
1205 When you want to read the messages that you have refiled into folders, | |
1206 use this command to visit the folder. You are prompted for the folder | |
1207 name. | |
1208 | |
1209 The folder buffer will show just unseen messages if there are any; | |
1210 otherwise, it will show all the messages in the buffer as long there | |
1211 are fewer than `mh-large-folder' messages. If there are more, then you | |
1212 are prompted for a range of messages to scan. | |
1213 | |
1214 You can provide a prefix argument in order to specify a RANGE of | |
1215 messages to show when you visit the folder. In this case, regions are | |
1216 not used to specify the range and `mh-large-folder' is ignored. Check | |
1217 the documentation of `mh-interactive-range' to see how RANGE is read | |
1218 in interactive use. | |
1219 | |
1220 Note that this command can also be used to create folders. If you | |
1221 specify a folder that does not exist, you will be prompted to create | |
1222 it. | |
1223 | |
1224 Do not call this function from outside MH-E; use \\[mh-rmail] instead. | |
1225 | |
1226 If, in a program, RANGE is nil (the default), then all messages in | |
1227 FOLDER are displayed. If an index buffer is being created then | |
1228 INDEX-DATA is used to initialize the index buffer specific data | |
1229 structures." | |
1230 (interactive (let ((folder-name (mh-prompt-for-folder "Visit" mh-inbox t))) | |
1231 (list folder-name | |
1232 (mh-read-range "Scan" folder-name t nil | |
1233 current-prefix-arg | |
1234 mh-interpret-number-as-range-flag)))) | |
1235 (let ((config (current-window-configuration)) | |
1236 (current-buffer (current-buffer)) | |
1237 (threaded-view-flag mh-show-threads-flag)) | |
1238 (delete-other-windows) | |
1239 (save-excursion | |
1240 (when (get-buffer folder) | |
1241 (set-buffer folder) | |
1242 (setq threaded-view-flag (memq 'unthread mh-view-ops)))) | |
1243 (when index-data | |
1244 (mh-make-folder folder) | |
1245 (setq mh-index-data (car index-data) | |
1246 mh-index-msg-checksum-map (make-hash-table :test #'equal) | |
1247 mh-index-checksum-origin-map (make-hash-table :test #'equal)) | |
1248 (mh-index-update-maps folder (cadr index-data)) | |
1249 (mh-index-create-sequences)) | |
1250 (mh-scan-folder folder (or range "all")) | |
1251 (cond ((and threaded-view-flag | |
1252 (save-excursion | |
1253 (goto-char (point-min)) | |
1254 (or (null mh-large-folder) | |
1255 (not (equal (forward-line (1+ mh-large-folder)) 0)) | |
1256 (and (message "Not threading since the number of messages exceeds `mh-large-folder'") | |
1257 nil)))) | |
1258 (mh-toggle-threads)) | |
1259 (mh-index-data | |
1260 (mh-index-insert-folder-headers))) | |
1261 (unless (eq current-buffer (current-buffer)) | |
1262 (setq mh-previous-window-config config))) | |
1263 nil) | |
1264 | |
1265 ;;;###mh-autoload | |
1266 (defun mh-write-msg-to-file (message file no-header) | |
1267 "Append MESSAGE to end of FILE\\<mh-folder-mode-map>. | |
1268 | |
1269 You are prompted for the filename. If the file already exists, | |
1270 the message is appended to it. You can also write the message to | |
1271 the file without the header by specifying a prefix argument | |
1272 NO-HEADER. Subsequent writes to the same file can be made with | |
1273 the command \\[mh-refile-or-write-again]." | |
1274 (interactive | |
1275 (list (mh-get-msg-num t) | |
1276 (let ((default-dir (if (eq 'write (car mh-last-destination-write)) | |
1277 (file-name-directory | |
1278 (car (cdr mh-last-destination-write))) | |
1279 default-directory))) | |
1280 (read-file-name (format "Save message%s in file: " | |
1281 (if current-prefix-arg " body" "")) | |
1282 default-dir | |
1283 (if (eq 'write (car mh-last-destination-write)) | |
1284 (car (cdr mh-last-destination-write)) | |
1285 (expand-file-name "mail.out" default-dir)))) | |
1286 current-prefix-arg)) | |
1287 (let ((msg-file-to-output (mh-msg-filename message)) | |
1288 (output-file (mh-expand-file-name file))) | |
1289 (setq mh-last-destination (list 'write file (if no-header 'no-header)) | |
1290 mh-last-destination-write mh-last-destination) | |
1291 (save-excursion | |
1292 (set-buffer (get-buffer-create mh-temp-buffer)) | |
1293 (erase-buffer) | |
1294 (insert-file-contents msg-file-to-output) | |
1295 (goto-char (point-min)) | |
1296 (if no-header (search-forward "\n\n")) | |
1297 (append-to-file (point) (point-max) output-file)))) | |
1298 | |
1299 ;;;###mh-autoload | |
1300 (defun mh-update-sequences () | |
1301 "Flush MH-E's state out to MH. | |
1302 | |
1303 This function updates the sequence specified by your | |
1304 \"Unseen-Sequence:\" profile component, \"cur\", and the sequence | |
1305 listed by the `mh-tick-seq' option which is \"tick\" by default. | |
1306 The message at the cursor is used for \"cur\"." | |
1307 (interactive) | |
1308 ;; mh-update-sequences is the opposite of mh-read-folder-sequences, | |
1309 ;; which updates MH-E's state from MH. | |
1310 (let ((folder-set (mh-update-unseen)) | |
1311 (new-cur (mh-get-msg-num nil))) | |
1312 (if new-cur | |
1313 (let ((seq-entry (mh-find-seq 'cur))) | |
1314 (mh-remove-cur-notation) | |
1315 (setcdr seq-entry | |
1316 (list new-cur)) ;delete-seq-locally, add-msgs-to-seq | |
1317 (mh-define-sequence 'cur (list new-cur)) | |
1318 (beginning-of-line) | |
1319 (if (looking-at mh-scan-good-msg-regexp) | |
1320 (mh-notate-cur))) | |
1321 (or folder-set | |
1322 (save-excursion | |
1323 ;; psg - mh-current-folder is nil if mh-summary-height < 4 ! | |
1324 ;; So I added this sanity check. | |
1325 (if (stringp mh-current-folder) | |
1326 (mh-exec-cmd-quiet t "folder" mh-current-folder "-fast") | |
1327 (mh-exec-cmd-quiet t "folder" "-fast"))))))) | |
1328 | |
1329 | |
1330 | |
1331 ;;; Support Routines | |
1332 | |
1333 (defun mh-get-new-mail (maildrop-name) | |
1334 "Read new mail from MAILDROP-NAME into the current buffer. | |
1335 Return in the current buffer." | |
1336 (let ((point-before-inc (point)) | |
1337 (folder mh-current-folder) | |
1338 (new-mail-flag nil)) | |
1339 (with-mh-folder-updating (t) | |
1340 (if maildrop-name | |
1341 (message "inc %s -file %s..." folder maildrop-name) | |
1342 (message "inc %s..." folder)) | |
1343 (setq mh-next-direction 'forward) | |
1344 (goto-char (point-max)) | |
1345 (mh-remove-cur-notation) | |
1346 (let ((start-of-inc (point))) | |
1347 (if maildrop-name | |
1348 ;; I think MH 5 used "-ms-file" instead of "-file", | |
1349 ;; which would make inc'ing from maildrops fail. | |
1350 (mh-exec-cmd-output mh-inc-prog nil folder | |
1351 (mh-scan-format) | |
1352 "-file" (expand-file-name maildrop-name) | |
1353 "-width" (window-width) | |
1354 "-truncate") | |
1355 (mh-exec-cmd-output mh-inc-prog nil | |
1356 (mh-scan-format) | |
1357 "-width" (window-width))) | |
1358 (if maildrop-name | |
1359 (message "inc %s -file %s...done" folder maildrop-name) | |
1360 (message "inc %s...done" folder)) | |
1361 (goto-char start-of-inc) | |
1362 (cond ((save-excursion | |
1363 (re-search-forward "^inc: no mail" nil t)) | |
1364 (message "No new mail%s%s" (if maildrop-name " in " "") | |
1365 (if maildrop-name maildrop-name ""))) | |
1366 ((and (when mh-folder-view-stack | |
1367 (let ((saved-text (buffer-substring-no-properties | |
1368 start-of-inc (point-max)))) | |
1369 (delete-region start-of-inc (point-max)) | |
1370 (unwind-protect (mh-widen t) | |
1371 (mh-remove-cur-notation) | |
1372 (goto-char (point-max)) | |
1373 (setq start-of-inc (point)) | |
1374 (insert saved-text) | |
1375 (goto-char start-of-inc)))) | |
1376 nil)) | |
1377 ((re-search-forward "^inc:" nil t) ; Error messages | |
1378 (error "Error incorporating mail")) | |
1379 ((and | |
1380 (equal mh-scan-format-file t) | |
1381 mh-adaptive-cmd-note-flag | |
1382 ;; Have we reached an edge condition? | |
1383 (save-excursion | |
1384 (re-search-forward mh-scan-msg-overflow-regexp nil 0 1)) | |
1385 (setq start-of-inc (mh-generate-new-cmd-note folder)) | |
1386 nil)) | |
1387 (t | |
1388 (setq new-mail-flag t))) | |
1389 (keep-lines mh-scan-valid-regexp) ; Flush random scan lines | |
1390 (let* ((sequences (mh-read-folder-sequences folder t)) | |
1391 (new-cur (assoc 'cur sequences)) | |
1392 (new-unseen (assoc mh-unseen-seq sequences))) | |
1393 (unless (assoc 'cur mh-seq-list) | |
1394 (push (list 'cur) mh-seq-list)) | |
1395 (unless (assoc mh-unseen-seq mh-seq-list) | |
1396 (push (list mh-unseen-seq) mh-seq-list)) | |
1397 (setcdr (assoc 'cur mh-seq-list) (cdr new-cur)) | |
1398 (setcdr (assoc mh-unseen-seq mh-seq-list) (cdr new-unseen))) | |
1399 (when (equal (point-max) start-of-inc) | |
1400 (mh-notate-cur)) | |
1401 (if new-mail-flag | |
1402 (progn | |
1403 (mh-make-folder-mode-line) | |
1404 (when (mh-speed-flists-active-p) | |
1405 (mh-speed-flists t mh-current-folder)) | |
1406 (when (memq 'unthread mh-view-ops) | |
1407 (mh-thread-inc folder start-of-inc)) | |
1408 (mh-goto-cur-msg)) | |
1409 (goto-char point-before-inc)) | |
1410 (mh-notate-user-sequences (cons start-of-inc (point-max))))))) | |
1411 | |
1412 (defun mh-generate-new-cmd-note (folder) | |
1413 "Fix the `mh-cmd-note' value for this FOLDER. | |
1414 | |
1415 After doing an `mh-get-new-mail' operation in this FOLDER, at least | |
1416 one line that looks like a truncated message number was found. | |
1417 | |
1418 Remove the text added by the last `mh-inc' command. It should be the | |
1419 messages cur-last. Call `mh-set-cmd-note', adjusting the notation | |
1420 column with the width of the largest message number in FOLDER. | |
1421 | |
1422 Reformat the message number width on each line in the buffer and trim | |
1423 the line length to fit in the window. | |
1424 | |
1425 Rescan the FOLDER in the range cur-last in order to display the | |
1426 messages that were removed earlier. They should all fit in the scan | |
1427 line now with no message truncation." | |
1428 (save-excursion | |
1429 (let ((maxcol (1- (window-width))) | |
1430 (old-cmd-note mh-cmd-note) | |
1431 mh-cmd-note-fmt | |
1432 msgnum) | |
1433 ;; Nuke all of the lines just added by the last inc | |
1434 (delete-char (- (point-max) (point))) | |
1435 ;; Update the current buffer to reflect the new mh-cmd-note | |
1436 ;; value needed to display messages. | |
1437 (mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width folder))) | |
1438 (setq mh-cmd-note-fmt (concat "%" (format "%d" mh-cmd-note) "d")) | |
1439 ;; Cleanup the messages that are in the buffer right now | |
1440 (goto-char (point-min)) | |
1441 (cond ((memq 'unthread mh-view-ops) | |
1442 (mh-thread-add-spaces (- mh-cmd-note old-cmd-note))) | |
1443 (t (while (re-search-forward (mh-scan-msg-number-regexp) nil 0 1) | |
1444 ;; reformat the number to fix in mh-cmd-note columns | |
1445 (setq msgnum (string-to-number | |
1446 (buffer-substring | |
1447 (match-beginning 1) (match-end 1)))) | |
1448 (replace-match (format mh-cmd-note-fmt msgnum)) | |
1449 ;; trim the line to fix in the window | |
1450 (end-of-line) | |
1451 (let ((eol (point))) | |
1452 (move-to-column maxcol) | |
1453 (if (<= (point) eol) | |
1454 (delete-char (- eol (point)))))))) | |
1455 ;; now re-read the lost messages | |
1456 (goto-char (point-max)) | |
1457 (prog1 (point) | |
1458 (mh-regenerate-headers "cur-last" t))))) | |
1459 | |
1460 ;;;###mh-autoload | |
1461 (defun mh-goto-cur-msg (&optional minimal-changes-flag) | |
1462 "Position the cursor at the current message. | |
1463 When optional argument MINIMAL-CHANGES-FLAG is non-nil, the | |
1464 function doesn't recenter the folder buffer." | |
1465 (let ((cur-msg (car (mh-seq-to-msgs 'cur)))) | |
1466 (cond ((and cur-msg | |
1467 (mh-goto-msg cur-msg t t)) | |
1468 (unless minimal-changes-flag | |
1469 (mh-notate-cur) | |
1470 (mh-recenter 0) | |
1471 (mh-maybe-show cur-msg))) | |
1472 (t | |
1473 (setq overlay-arrow-position nil) | |
1474 (message "No current message"))))) | |
1475 | |
1476 ;;;###mh-autoload | |
1477 (defun mh-recenter (arg) | |
1478 "Like recenter but with three improvements: | |
1479 | |
1480 - At the end of the buffer it tries to show fewer empty lines. | |
1481 | |
1482 - operates only if the current buffer is in the selected window. | |
1483 (Commands like `save-some-buffers' can make this false.) | |
1484 | |
1485 - nil ARG means recenter as if prefix argument had been given." | |
1486 (cond ((not (eq (get-buffer-window (current-buffer)) (selected-window))) | |
1487 nil) | |
1488 ((= (point-max) (save-excursion | |
1489 (forward-line (- (/ (window-height) 2) 2)) | |
1490 (point))) | |
1491 (let ((lines-from-end 2)) | |
1492 (save-excursion | |
1493 (while (> (point-max) (progn (forward-line) (point))) | |
1494 (incf lines-from-end))) | |
1495 (recenter (- lines-from-end)))) | |
1496 ;; '(4) is the same as C-u prefix argument. | |
1497 (t (recenter (or arg '(4)))))) | |
1498 | |
1499 (defun mh-update-unseen () | |
1500 "Synchronize the unseen sequence with MH. | |
78479
40ee7ed1bfea
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78231
diff
changeset
|
1501 Return non-nil if the MH folder was set. |
68465 | 1502 The hook `mh-unseen-updated-hook' is called after the unseen sequence |
1503 is updated." | |
1504 (if mh-seen-list | |
1505 (let* ((unseen-seq (mh-find-seq mh-unseen-seq)) | |
1506 (unseen-msgs (mh-seq-msgs unseen-seq))) | |
1507 (if unseen-msgs | |
1508 (progn | |
1509 (mh-undefine-sequence mh-unseen-seq mh-seen-list) | |
1510 (run-hooks 'mh-unseen-updated-hook) | |
1511 (while mh-seen-list | |
1512 (setq unseen-msgs (delq (car mh-seen-list) unseen-msgs)) | |
1513 (setq mh-seen-list (cdr mh-seen-list))) | |
1514 (setcdr unseen-seq unseen-msgs) | |
1515 t) ;since we set the folder | |
1516 (setq mh-seen-list nil))))) | |
1517 | |
1518 ;;;###mh-autoload | |
1519 (defun mh-outstanding-commands-p () | |
1520 "Return non-nil if there are outstanding deletes or refiles." | |
1521 (save-excursion | |
1522 (when (eq major-mode 'mh-show-mode) | |
1523 (set-buffer mh-show-folder-buffer)) | |
1524 (or mh-delete-list mh-refile-list))) | |
1525 | |
1526 ;;;###mh-autoload | |
1527 (defun mh-set-folder-modified-p (flag) | |
1528 "Mark current folder as modified or unmodified according to FLAG." | |
1529 (set-buffer-modified-p flag)) | |
1530 | |
1531 (defun mh-process-commands (folder) | |
1532 "Process outstanding commands for FOLDER. | |
1533 | |
1534 This function runs `mh-before-commands-processed-hook' before the | |
1535 commands are processed and `mh-after-commands-processed-hook' | |
1536 after the commands are processed." | |
1537 (message "Processing deletes and refiles for %s..." folder) | |
1538 (set-buffer folder) | |
1539 (with-mh-folder-updating (nil) | |
1540 ;; Run the before hook -- the refile and delete lists are still valid | |
1541 (run-hooks 'mh-before-commands-processed-hook) | |
1542 | |
1543 ;; Update the unseen sequence if it exists | |
1544 (mh-update-unseen) | |
1545 | |
1546 (let ((redraw-needed-flag mh-index-data) | |
1547 (folders-changed (list mh-current-folder)) | |
1548 (seq-map (and mh-refile-list mh-refile-preserves-sequences-flag | |
1549 (mh-create-sequence-map mh-seq-list))) | |
1550 (dest-map (and mh-refile-list mh-refile-preserves-sequences-flag | |
1551 (make-hash-table)))) | |
1552 ;; Remove invalid scan lines if we are in an index folder and then remove | |
1553 ;; the real messages | |
1554 (when mh-index-data | |
1555 (mh-index-delete-folder-headers) | |
1556 (setq folders-changed | |
1557 (append folders-changed (mh-index-execute-commands)))) | |
1558 | |
1559 ;; Then refile messages | |
1560 (mh-mapc #'(lambda (folder-msg-list) | |
1561 (let* ((dest-folder (symbol-name (car folder-msg-list))) | |
1562 (last (car (mh-translate-range dest-folder "last"))) | |
1563 (msgs (cdr folder-msg-list))) | |
1564 (push dest-folder folders-changed) | |
1565 (setq redraw-needed-flag t) | |
1566 (apply #'mh-exec-cmd | |
1567 "refile" "-src" folder dest-folder | |
1568 (mh-coalesce-msg-list msgs)) | |
1569 (mh-delete-scan-msgs msgs) | |
1570 ;; Preserve sequences in destination folder... | |
1571 (when mh-refile-preserves-sequences-flag | |
1572 (clrhash dest-map) | |
1573 (loop for i from (1+ (or last 0)) | |
1574 for msg in (sort (copy-sequence msgs) #'<) | |
1575 do (loop for seq-name in (gethash msg seq-map) | |
1576 do (push i (gethash seq-name dest-map)))) | |
1577 (maphash | |
1578 #'(lambda (seq msgs) | |
1579 ;; Can't be run in the background, since the | |
1580 ;; current folder is changed by mark this could | |
1581 ;; lead to a race condition with the next refile. | |
1582 (apply #'mh-exec-cmd "mark" | |
1583 "-sequence" (symbol-name seq) dest-folder | |
1584 "-add" (mapcar #'(lambda (x) (format "%s" x)) | |
1585 (mh-coalesce-msg-list msgs)))) | |
1586 dest-map)))) | |
1587 mh-refile-list) | |
1588 (setq mh-refile-list ()) | |
1589 | |
1590 ;; Now delete messages | |
1591 (cond (mh-delete-list | |
1592 (setq redraw-needed-flag t) | |
1593 (apply 'mh-exec-cmd "rmm" folder | |
1594 (mh-coalesce-msg-list mh-delete-list)) | |
1595 (mh-delete-scan-msgs mh-delete-list) | |
1596 (setq mh-delete-list nil))) | |
1597 | |
1598 ;; Don't need to remove sequences since delete and refile do so. | |
1599 ;; Mark cur message | |
1600 (if (> (buffer-size) 0) | |
1601 (mh-define-sequence 'cur (list (or (mh-get-msg-num nil) "last")))) | |
1602 | |
1603 ;; Redraw folder buffer if needed | |
1604 (when (and redraw-needed-flag) | |
1605 (when (mh-speed-flists-active-p) | |
1606 (apply #'mh-speed-flists t folders-changed)) | |
1607 (cond ((memq 'unthread mh-view-ops) (mh-thread-inc folder (point-max))) | |
1608 (mh-index-data (mh-index-insert-folder-headers)))) | |
1609 | |
1610 (and (buffer-file-name (get-buffer mh-show-buffer)) | |
1611 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer)))) | |
1612 ;; If "inc" were to put a new msg in this file, | |
1613 ;; we would not notice, so mark it invalid now. | |
1614 (mh-invalidate-show-buffer)) | |
1615 | |
1616 (setq mh-seq-list (mh-read-folder-sequences mh-current-folder nil)) | |
1617 (mh-remove-all-notation) | |
1618 (mh-notate-user-sequences) | |
1619 | |
1620 ;; Run the after hook -- now folders-changed is valid, | |
1621 ;; but not the lists of specific messages. | |
1622 (let ((mh-folders-changed folders-changed)) | |
1623 (run-hooks 'mh-after-commands-processed-hook))) | |
1624 | |
1625 (message "Processing deletes and refiles for %s...done" folder))) | |
1626 | |
1627 (defun mh-delete-scan-msgs (msgs) | |
1628 "Delete the scan listing lines for MSGS." | |
1629 (save-excursion | |
1630 (while msgs | |
1631 (when (mh-goto-msg (car msgs) t t) | |
1632 (when (memq 'unthread mh-view-ops) | |
1633 (mh-thread-forget-message (car msgs))) | |
1634 (mh-delete-line 1)) | |
1635 (setq msgs (cdr msgs))))) | |
1636 | |
1637 (defun mh-set-scan-mode () | |
1638 "Display the scan listing buffer, but do not show a message." | |
1639 (if (get-buffer mh-show-buffer) | |
1640 (delete-windows-on mh-show-buffer)) | |
1641 (mh-showing-mode 0) | |
1642 (force-mode-line-update) | |
1643 (if mh-recenter-summary-flag | |
1644 (mh-recenter nil))) | |
1645 | |
1646 ;;;###mh-autoload | |
1647 (defun mh-make-folder-mode-line (&optional ignored) | |
1648 "Set the fields of the mode line for a folder buffer. | |
1649 The optional argument is now obsolete and IGNORED. It used to be | |
1650 used to pass in what is now stored in the buffer-local variable | |
1651 `mh-mode-line-annotation'." | |
1652 (save-excursion | |
1653 (save-window-excursion | |
1654 (mh-first-msg) | |
1655 (let ((new-first-msg-num (mh-get-msg-num nil))) | |
1656 (when (or (not (memq 'unthread mh-view-ops)) | |
1657 (null mh-first-msg-num) | |
1658 (null new-first-msg-num) | |
1659 (< new-first-msg-num mh-first-msg-num)) | |
1660 (setq mh-first-msg-num new-first-msg-num))) | |
1661 (mh-last-msg) | |
1662 (let ((new-last-msg-num (mh-get-msg-num nil))) | |
1663 (when (or (not (memq 'unthread mh-view-ops)) | |
1664 (null mh-last-msg-num) | |
1665 (null new-last-msg-num) | |
1666 (> new-last-msg-num mh-last-msg-num)) | |
1667 (setq mh-last-msg-num new-last-msg-num))) | |
1668 (setq mh-msg-count (if mh-first-msg-num | |
1669 (count-lines (point-min) (point-max)) | |
1670 0)) | |
1671 (setq mode-line-buffer-identification | |
1672 (list (format " {%%b%s} %s msg%s" | |
1673 (if mh-mode-line-annotation | |
1674 (format "/%s" mh-mode-line-annotation) | |
1675 "") | |
1676 (if (zerop mh-msg-count) | |
1677 "no" | |
1678 (format "%d" mh-msg-count)) | |
1679 (if (zerop mh-msg-count) | |
1680 "s" | |
1681 (cond ((> mh-msg-count 1) | |
1682 (format "s (%d-%d)" mh-first-msg-num | |
1683 mh-last-msg-num)) | |
1684 (mh-first-msg-num | |
1685 (format " (%d)" mh-first-msg-num)) | |
1686 ("")))))) | |
1687 (mh-logo-display)))) | |
1688 | |
1689 ;;;###mh-autoload | |
1690 (defun mh-scan-folder (folder range &optional dont-exec-pending) | |
1691 "Scan FOLDER over RANGE. | |
1692 | |
1693 After the scan is performed, switch to the buffer associated with | |
1694 FOLDER. | |
1695 | |
1696 Check the documentation of `mh-interactive-range' to see how RANGE is | |
1697 read in interactive use. | |
1698 | |
1699 The processing of outstanding commands is not performed if | |
1700 DONT-EXEC-PENDING is non-nil." | |
1701 (when (stringp range) | |
1702 (setq range (delete "" (split-string range "[ \t\n]")))) | |
1703 (cond ((null (get-buffer folder)) | |
1704 (mh-make-folder folder)) | |
1705 (t | |
1706 (unless dont-exec-pending | |
1707 (mh-process-or-undo-commands folder) | |
1708 (mh-reset-threads-and-narrowing)) | |
1709 (switch-to-buffer folder))) | |
1710 (mh-regenerate-headers range) | |
1711 (if (zerop (buffer-size)) | |
1712 (if (equal range "all") | |
1713 (message "Folder %s is empty" folder) | |
1714 (message "No messages in %s, range %s" folder range)) | |
1715 (mh-goto-cur-msg)) | |
1716 (when (mh-outstanding-commands-p) | |
1717 (mh-notate-deleted-and-refiled))) | |
1718 | |
1719 ;;;###mh-autoload | |
1720 (defun mh-process-or-undo-commands (folder) | |
1721 "If FOLDER has outstanding commands, then either process or discard them. | |
1722 Called by functions like `mh-sort-folder', so also invalidate | |
1723 show buffer." | |
1724 (set-buffer folder) | |
1725 (if (mh-outstanding-commands-p) | |
1726 (if (or mh-do-not-confirm-flag | |
1727 (y-or-n-p | |
1728 "Process outstanding deletes and refiles? ")) | |
1729 (mh-process-commands folder) | |
1730 (set-buffer folder) | |
1731 (mh-undo-folder))) | |
1732 (mh-update-unseen) | |
1733 (mh-invalidate-show-buffer)) | |
1734 | |
1735 ;;;###mh-autoload | |
1736 (defun mh-regenerate-headers (range &optional update) | |
1737 "Scan folder over RANGE. | |
1738 If UPDATE, append the scan lines, otherwise replace." | |
1739 (let ((folder mh-current-folder) | |
1740 (range (if (and range (atom range)) (list range) range)) | |
1741 scan-start) | |
1742 (message "Scanning %s..." folder) | |
1743 (mh-remove-all-notation) | |
1744 (with-mh-folder-updating (nil) | |
1745 (if update | |
1746 (goto-char (point-max)) | |
1747 (delete-region (point-min) (point-max)) | |
1748 (if mh-adaptive-cmd-note-flag | |
1749 (mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width | |
1750 folder))))) | |
1751 (setq scan-start (point)) | |
1752 (apply #'mh-exec-cmd-output | |
1753 mh-scan-prog nil | |
1754 (mh-scan-format) | |
1755 "-noclear" "-noheader" | |
1756 "-width" (window-width) | |
1757 folder range) | |
1758 (goto-char scan-start) | |
1759 (cond ((looking-at "scan: no messages in") | |
1760 (keep-lines mh-scan-valid-regexp)) ; Flush random scan lines | |
97409
4882b599444d
(mh-reply): Rename variant mu-mh to gnu-mh and be explicit about GNU
Bill Wohler <wohler@newt.com>
parents:
95843
diff
changeset
|
1761 ((looking-at (if (mh-variant-p 'gnu-mh) |
68465 | 1762 "scan: message set .* does not exist" |
1763 "scan: bad message list ")) | |
1764 (keep-lines mh-scan-valid-regexp)) | |
1765 ((looking-at "scan: ")) ; Keep error messages | |
1766 (t | |
1767 (keep-lines mh-scan-valid-regexp))) ; Flush random scan lines | |
1768 (setq mh-seq-list (mh-read-folder-sequences folder nil)) | |
1769 (mh-notate-user-sequences) | |
1770 (or update | |
1771 (setq mh-mode-line-annotation | |
1772 (if (equal range '("all")) | |
1773 nil | |
1774 mh-partial-folder-mode-line-annotation))) | |
1775 (mh-make-folder-mode-line)) | |
1776 (message "Scanning %s...done" folder))) | |
1777 | |
1778 ;;;###mh-autoload | |
1779 (defun mh-reset-threads-and-narrowing () | |
1780 "Reset all variables pertaining to threads and narrowing. | |
1781 Also removes all content from the folder buffer." | |
1782 (setq mh-view-ops ()) | |
1783 (setq mh-folder-view-stack ()) | |
1784 (setq mh-thread-scan-line-map-stack ()) | |
1785 (let ((buffer-read-only nil)) (erase-buffer))) | |
1786 | |
1787 (defun mh-make-folder (name) | |
1788 "Create a new mail folder called NAME. | |
1789 Make it the current folder." | |
1790 (switch-to-buffer name) | |
1791 (setq buffer-read-only nil) | |
1792 (erase-buffer) | |
1793 (if mh-adaptive-cmd-note-flag | |
1794 (mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width name)))) | |
1795 (setq buffer-read-only t) | |
1796 (mh-folder-mode) | |
1797 (mh-set-folder-modified-p nil) | |
1798 (setq buffer-file-name mh-folder-filename) | |
1799 (when (and (not mh-index-data) | |
1800 (file-exists-p (concat buffer-file-name mh-index-data-file))) | |
1801 (mh-index-read-data)) | |
1802 (mh-make-folder-mode-line)) | |
1803 | |
1804 ;;;###mh-autoload | |
1805 (defun mh-next-msg (&optional wait-after-complaining-flag) | |
1806 "Move backward or forward to the next undeleted message in the buffer. | |
1807 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and | |
1808 we are at the last message, then wait for a second after telling | |
1809 the user that there aren't any more unread messages." | |
1810 (if (eq mh-next-direction 'forward) | |
1811 (mh-next-undeleted-msg 1 wait-after-complaining-flag) | |
1812 (mh-previous-undeleted-msg 1 wait-after-complaining-flag))) | |
1813 | |
1814 ;;;###mh-autoload | |
1815 (defun mh-prompt-for-refile-folder () | |
1816 "Prompt the user for a folder in which the message should be filed. | |
1817 The folder is returned as a string. | |
1818 | |
1819 The default folder name is generated by the option | |
1820 `mh-default-folder-for-message-function' if it is non-nil or | |
1821 `mh-folder-from-address'." | |
1822 (mh-prompt-for-folder | |
1823 "Destination" | |
1824 (let ((refile-file (ignore-errors (mh-msg-filename (mh-get-msg-num t))))) | |
1825 (if (null refile-file) "" | |
1826 (save-excursion | |
1827 (set-buffer (get-buffer-create mh-temp-buffer)) | |
1828 (erase-buffer) | |
1829 (insert-file-contents refile-file) | |
1830 (or (and mh-default-folder-for-message-function | |
1831 (let ((buffer-file-name refile-file)) | |
1832 (funcall mh-default-folder-for-message-function))) | |
1833 (mh-folder-from-address) | |
1834 (and (eq 'refile (car mh-last-destination-folder)) | |
1835 (symbol-name (cdr mh-last-destination-folder))) | |
1836 "")))) | |
1837 t)) | |
1838 | |
1839 ;;;###mh-autoload | |
1840 (defun mh-folder-from-address () | |
1841 "Derive folder name from sender. | |
1842 | |
1843 The name of the folder is derived as follows: | |
1844 | |
1845 a) The folder name associated with the first address found in | |
1846 the list `mh-default-folder-list' is used. Each element in | |
1847 this list contains a \"Check Recipient\" item. If this item is | |
1848 turned on, then the address is checked against the recipient | |
1849 instead of the sender. This is useful for mailing lists. | |
1850 | |
1851 b) An alias prefixed by `mh-default-folder-prefix' | |
1852 corresponding to the address is used. The prefix is used to | |
1853 prevent clutter in your mail directory. | |
1854 | |
1855 Return nil if a folder name was not derived, or if the variable | |
1856 `mh-default-folder-must-exist-flag' is t and the folder does not | |
1857 exist." | |
1858 ;; Loop for all entries in mh-default-folder-list | |
1859 (save-restriction | |
1860 (goto-char (point-min)) | |
1861 (re-search-forward "\n\n" nil 'limit) | |
1862 (narrow-to-region (point-min) (point)) | |
1863 (let ((to/cc (concat (or (message-fetch-field "to") "") ", " | |
1864 (or (message-fetch-field "cc") ""))) | |
1865 (from (or (message-fetch-field "from") "")) | |
1866 folder-name) | |
1867 (setq folder-name | |
1868 (loop for list in mh-default-folder-list | |
1869 when (string-match (nth 0 list) (if (nth 2 list) to/cc from)) | |
1870 return (nth 1 list) | |
1871 finally return nil)) | |
1872 | |
1873 ;; Make sure a result from `mh-default-folder-list' begins with "+" | |
1874 ;; since 'mh-expand-file-name below depends on it | |
1875 (when (and folder-name (not (eq (aref folder-name 0) ?+))) | |
1876 (setq folder-name (concat "+" folder-name))) | |
1877 | |
1878 ;; If not, is there an alias for the address? | |
1879 (when (not folder-name) | |
1880 (let* ((from-header (mh-extract-from-header-value)) | |
1881 (address (and from-header | |
1882 (nth 1 (mail-extract-address-components | |
1883 from-header)))) | |
1884 (alias (and address (mh-alias-address-to-alias address)))) | |
1885 (when alias | |
1886 (setq folder-name | |
1887 (and alias (concat "+" mh-default-folder-prefix alias)))))) | |
1888 | |
1889 ;; If mh-default-folder-must-exist-flag set, check that folder exists. | |
1890 (if (and folder-name | |
1891 (or (not mh-default-folder-must-exist-flag) | |
1892 (file-exists-p (mh-expand-file-name folder-name)))) | |
1893 folder-name)))) | |
1894 | |
1895 ;;;###mh-autoload | |
1896 (defun mh-delete-a-msg (message) | |
1897 "Delete MESSAGE. | |
1898 If MESSAGE is nil then the message at point is deleted. | |
1899 The hook `mh-delete-msg-hook' is called after you mark a message | |
1900 for deletion. For example, a past maintainer of MH-E used this | |
1901 once when he kept statistics on his mail usage." | |
1902 (save-excursion | |
1903 (if (numberp message) | |
1904 (mh-goto-msg message nil t) | |
1905 (beginning-of-line) | |
1906 (setq message (mh-get-msg-num t))) | |
1907 (if (looking-at mh-scan-refiled-msg-regexp) | |
1908 (error "Message %d is refiled; undo refile before deleting" message)) | |
1909 (if (looking-at mh-scan-deleted-msg-regexp) | |
1910 nil | |
1911 (mh-set-folder-modified-p t) | |
1912 (setq mh-delete-list (cons message mh-delete-list)) | |
1913 (mh-notate nil mh-note-deleted mh-cmd-note) | |
1914 (run-hooks 'mh-delete-msg-hook)))) | |
1915 | |
1916 ;;;###mh-autoload | |
1917 (defun mh-refile-a-msg (message folder) | |
1918 "Refile MESSAGE in FOLDER. | |
1919 If MESSAGE is nil then the message at point is refiled. | |
1920 Folder is a symbol, not a string. | |
1921 The hook `mh-refile-msg-hook' is called after a message is marked to | |
1922 be refiled." | |
1923 (save-excursion | |
1924 (if (numberp message) | |
1925 (mh-goto-msg message nil t) | |
1926 (beginning-of-line) | |
1927 (setq message (mh-get-msg-num t))) | |
1928 (cond ((looking-at mh-scan-deleted-msg-regexp) | |
1929 (error "Message %d is deleted; undo delete before moving" message)) | |
1930 ((looking-at mh-scan-refiled-msg-regexp) | |
1931 (if (y-or-n-p | |
1932 (format "Message %d already refiled; copy to %s as well? " | |
1933 message folder)) | |
1934 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link" | |
1935 "-src" mh-current-folder | |
1936 (symbol-name folder)) | |
1937 (message "Message not copied"))) | |
1938 (t | |
1939 (mh-set-folder-modified-p t) | |
1940 (cond ((null (assoc folder mh-refile-list)) | |
1941 (push (list folder message) mh-refile-list)) | |
1942 ((not (member message (cdr (assoc folder mh-refile-list)))) | |
1943 (push message (cdr (assoc folder mh-refile-list))))) | |
1944 (mh-notate nil mh-note-refiled mh-cmd-note) | |
1945 (run-hooks 'mh-refile-msg-hook))))) | |
1946 | |
1947 (defun mh-undo-msg (msg) | |
1948 "Undo the deletion or refile of one MSG. | |
1949 If MSG is nil then act on the message at point" | |
1950 (save-excursion | |
1951 (if (numberp msg) | |
1952 (mh-goto-msg msg t t) | |
1953 (beginning-of-line) | |
1954 (setq msg (mh-get-msg-num t))) | |
1955 (cond ((memq msg mh-delete-list) | |
1956 (setq mh-delete-list (delq msg mh-delete-list))) | |
1957 (t | |
1958 (dolist (folder-msg-list mh-refile-list) | |
1959 (setf (cdr folder-msg-list) (remove msg (cdr folder-msg-list)))) | |
1960 (setq mh-refile-list (loop for x in mh-refile-list | |
1961 unless (null (cdr x)) collect x)))) | |
1962 (mh-notate nil ? mh-cmd-note))) | |
1963 | |
1964 ;;;###mh-autoload | |
1965 (defun mh-msg-filename (msg &optional folder) | |
1966 "Return the file name of MSG in FOLDER (default current folder)." | |
1967 (expand-file-name (int-to-string msg) | |
1968 (if folder | |
1969 (mh-expand-file-name folder) | |
1970 mh-folder-filename))) | |
1971 | |
1972 (provide 'mh-folder) | |
1973 | |
1974 ;; Local Variables: | |
1975 ;; indent-tabs-mode: nil | |
1976 ;; sentence-end-double-space: nil | |
1977 ;; End: | |
1978 | |
68470 | 1979 ;; arch-tag: aa97b758-d4f6-4c86-bc5a-1950921da1e7 |
68465 | 1980 ;;; mh-folder.el ends here |