Mercurial > emacs
annotate lisp/mh-e/mh-seq.el @ 95683:95f214d05929
*** empty log message ***
author | John Paul Wallington <jpw@pobox.com> |
---|---|
date | Sun, 08 Jun 2008 17:25:40 +0000 |
parents | 90c9ebd43589 |
children | fbeceb242efd |
rev | line source |
---|---|
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1 ;;; mh-seq.el --- MH-E sequences support |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
2 |
62847
aa8c2e12ee24
Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents:
62465
diff
changeset
|
3 ;; Copyright (C) 1993, 1995, |
79713 | 4 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
5 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
6 ;; Author: Bill Wohler <wohler@newt.com> |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
7 ;; Maintainer: Bill Wohler <wohler@newt.com> |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
8 ;; Keywords: mail |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
9 ;; See: mh-e.el |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
10 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
11 ;; This file is part of GNU Emacs. |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
12 |
94663
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
80068
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
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:
80068
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:
80068
diff
changeset
|
16 ;; (at your option) any later version. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
17 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
18 ;; GNU Emacs is distributed in the hope that it will be useful, |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
21 ;; GNU General Public License for more details. |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
22 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
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:
80068
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
25 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
26 ;;; Commentary: |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
27 |
68465 | 28 ;; Sequences are stored in the alist `mh-seq-list' in the form: |
29 ;; ((seq-name msgs ...) (seq-name msgs ...) ...) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
30 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
31 ;;; Change Log: |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
32 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
33 ;;; Code: |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
34 |
68465 | 35 (require 'mh-e) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
36 (mh-require-cl) |
68465 | 37 (require 'mh-scan) |
67681 | 38 |
68465 | 39 (require 'font-lock) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
40 |
68465 | 41 ;;; Variables |
67681 | 42 |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
43 (defvar mh-last-seq-used nil |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
44 "Name of seq to which a msg was last added.") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
45 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
46 (defvar mh-non-seq-mode-line-annotation nil |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
47 "Saved value of `mh-mode-line-annotation' when narrowed to a seq.") |
68465 | 48 (make-variable-buffer-local 'mh-non-seq-mode-line-annotation) |
49 | |
50 (defvar mh-internal-seqs '(answered cur deleted forwarded printed)) | |
51 | |
52 ;;; Macros | |
53 | |
80068
c2b53430fd48
(mh-make-seq, mh-seq-name): Use defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
79713
diff
changeset
|
54 (defsubst mh-make-seq (name msgs) |
68465 | 55 "Create sequence NAME with the given MSGS." |
80068
c2b53430fd48
(mh-make-seq, mh-seq-name): Use defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
79713
diff
changeset
|
56 (cons name msgs)) |
68465 | 57 |
80068
c2b53430fd48
(mh-make-seq, mh-seq-name): Use defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
79713
diff
changeset
|
58 (defsubst mh-seq-name (sequence) |
68465 | 59 "Extract sequence name from the given SEQUENCE." |
80068
c2b53430fd48
(mh-make-seq, mh-seq-name): Use defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
79713
diff
changeset
|
60 (car sequence)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
61 |
67681 | 62 |
63 | |
68465 | 64 ;;; MH-Folder Commands |
65 | |
66 ;; Alphabetical. | |
67 | |
68 ;;;###mh-autoload | |
69 (defun mh-catchup (range) | |
70 "Delete RANGE from the \"unseen\" sequence. | |
71 | |
72 Check the documentation of `mh-interactive-range' to see how | |
73 RANGE is read in interactive use." | |
74 (interactive (list (mh-interactive-range "Catchup" | |
75 (cons (point-min) (point-max))))) | |
76 (mh-delete-msg-from-seq range mh-unseen-seq)) | |
77 | |
78 ;;;###mh-autoload | |
79 (defun mh-delete-msg-from-seq (range sequence &optional internal-flag) | |
80 "Delete RANGE from SEQUENCE. | |
81 | |
82 Check the documentation of `mh-interactive-range' to see how | |
83 RANGE is read in interactive use. | |
67681 | 84 |
68465 | 85 In a program, non-nil INTERNAL-FLAG means do not inform MH of the |
86 change." | |
87 (interactive (list (mh-interactive-range "Delete") | |
88 (mh-read-seq-default "Delete from" t) | |
89 nil)) | |
90 (let ((entry (mh-find-seq sequence)) | |
91 (user-sequence-flag (not (mh-internal-seq sequence))) | |
92 (folders-changed (list mh-current-folder)) | |
93 (msg-list ())) | |
94 (when entry | |
95 (mh-iterate-on-range msg range | |
96 (push msg msg-list) | |
97 ;; Calling "mark" repeatedly takes too long. So we will pretend here | |
98 ;; that we are just modifying an internal sequence... | |
99 (when (memq msg (cdr entry)) | |
100 (mh-remove-sequence-notation msg (not user-sequence-flag))) | |
101 (mh-delete-a-msg-from-seq msg sequence t)) | |
102 ;; ... and here we will "mark" all the messages at one go. | |
103 (unless internal-flag (mh-undefine-sequence sequence msg-list)) | |
104 (when (and mh-index-data (not internal-flag)) | |
105 (setq folders-changed | |
106 (append folders-changed | |
107 (mh-index-delete-from-sequence sequence msg-list)))) | |
108 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p)) | |
109 (apply #'mh-speed-flists t folders-changed))))) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
110 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
111 ;;;###mh-autoload |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
112 (defun mh-delete-seq (sequence) |
66661
f7b261d0f8e8
* mh-customize.el (mh-refile-preserves-sequences-flag)
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
113 "Delete SEQUENCE. |
f7b261d0f8e8
* mh-customize.el (mh-refile-preserves-sequences-flag)
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
114 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
115 You are prompted for the sequence to delete. Note that this |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
116 deletes only the sequence, not the messages in the sequence. If |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
117 you want to delete the messages, use \"\\[universal-argument] |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
118 \\[mh-delete-msg]\"." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
119 (interactive (list (mh-read-seq-default "Delete" t))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
120 (let ((msg-list (mh-seq-to-msgs sequence)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
121 (internal-flag (mh-internal-seq sequence)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
122 (folders-changed (list mh-current-folder))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
123 (mh-iterate-on-range msg sequence |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
124 (mh-remove-sequence-notation msg internal-flag)) |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
125 (mh-undefine-sequence sequence '("all")) |
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
126 (mh-delete-seq-locally sequence) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
127 (when mh-index-data |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
128 (setq folders-changed |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
129 (append folders-changed |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
130 (mh-index-delete-from-sequence sequence msg-list)))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
131 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
132 (apply #'mh-speed-flists t folders-changed)))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
133 |
68105 | 134 ;; Shush compiler. |
70027
0e0916499a15
* mh-funcs.el (view-exit-action): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
68529
diff
changeset
|
135 (defvar view-exit-action) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
136 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
137 ;;;###mh-autoload |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
138 (defun mh-list-sequences () |
66661
f7b261d0f8e8
* mh-customize.el (mh-refile-preserves-sequences-flag)
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
139 "List all sequences in folder. |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67760
diff
changeset
|
140 |
66661
f7b261d0f8e8
* mh-customize.el (mh-refile-preserves-sequences-flag)
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
141 The list appears in a buffer named \"*MH-E Sequences*\"." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
142 (interactive) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
143 (let ((folder mh-current-folder) |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
144 (temp-buffer mh-sequences-buffer) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
145 (seq-list mh-seq-list) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
146 (max-len 0)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
147 (with-output-to-temp-buffer temp-buffer |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
148 (save-excursion |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
149 (set-buffer temp-buffer) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
150 (erase-buffer) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
151 (message "Listing sequences ...") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
152 (insert "Sequences in folder " folder ":\n") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
153 (let ((seq-list seq-list)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
154 (while seq-list |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
155 (setq max-len |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
156 (max (length (symbol-name (mh-seq-name (pop seq-list)))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
157 max-len))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
158 (setq max-len (+ 2 max-len))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
159 (while seq-list |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
160 (let ((name (mh-seq-name (car seq-list))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
161 (sorted-seq-msgs |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
162 (mh-coalesce-msg-list |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
163 (sort (copy-sequence (mh-seq-msgs (car seq-list))) '<))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
164 name-spec) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
165 (insert (setq name-spec (format (format "%%%ss:" max-len) name))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
166 (while sorted-seq-msgs |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
167 (let ((next-element (format " %s" (pop sorted-seq-msgs)))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
168 (when (>= (+ (current-column) (length next-element)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
169 (window-width)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
170 (insert "\n") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
171 (insert (format (format "%%%ss" (length name-spec)) ""))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
172 (insert next-element))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
173 (insert "\n")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
174 (setq seq-list (cdr seq-list))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
175 (goto-char (point-min)) |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
176 (mh-view-mode-enter) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
177 (setq view-exit-action 'kill-buffer) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
178 (message "Listing sequences...done"))))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
179 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
180 ;;;###mh-autoload |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
181 (defun mh-msg-is-in-seq (message) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
182 "Display the sequences in which the current message appears. |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67760
diff
changeset
|
183 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
184 Use a prefix argument to display the sequences in which another |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
185 MESSAGE appears." |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
186 (interactive "P") |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
187 (if (not message) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
188 (setq message (mh-get-msg-num t))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
189 (let* ((dest-folder (loop for seq in mh-refile-list |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
190 when (member message (cdr seq)) return (car seq) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
191 finally return nil)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
192 (deleted-flag (unless dest-folder (member message mh-delete-list)))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
193 (message "Message %d%s is in sequences: %s" |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
194 message |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
195 (cond (dest-folder (format " (to be refiled to %s)" dest-folder)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
196 (deleted-flag (format " (to be deleted)")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
197 (t "")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
198 (mapconcat 'concat |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
199 (mh-list-to-string (mh-seq-containing-msg message t)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
200 " ")))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
201 |
68465 | 202 ;; Shush compiler. |
70028
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
70027
diff
changeset
|
203 (defvar tool-bar-mode) ; XEmacs |
66086
1d0956c24eb7
* mh-seq.el (mh-non-seq-mode-line-annotation): Moved
Bill Wohler <wohler@newt.com>
parents:
64085
diff
changeset
|
204 |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
205 ;;;###mh-autoload |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
206 (defun mh-narrow-to-seq (sequence) |
66661
f7b261d0f8e8
* mh-customize.el (mh-refile-preserves-sequences-flag)
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
207 "Restrict display to messages in SEQUENCE. |
f7b261d0f8e8
* mh-customize.el (mh-refile-preserves-sequences-flag)
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
208 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
209 You are prompted for the name of the sequence. What this command |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
210 does is show only those messages that are in the selected |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
211 sequence in the MH-Folder buffer. In addition, it limits further |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
212 MH-E searches to just those messages. |
66661
f7b261d0f8e8
* mh-customize.el (mh-refile-preserves-sequences-flag)
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
213 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
214 When you want to widen the view to all your messages again, use |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
215 \\[mh-widen]." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
216 (interactive (list (mh-read-seq "Narrow to" t))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
217 (with-mh-folder-updating (t) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
218 (cond ((mh-seq-to-msgs sequence) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
219 (mh-remove-all-notation) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
220 (let ((eob (point-max)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
221 (msg-at-cursor (mh-get-msg-num nil))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
222 (push mh-thread-scan-line-map mh-thread-scan-line-map-stack) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
223 (setq mh-thread-scan-line-map (make-hash-table :test #'eql)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
224 (mh-copy-seq-to-eob sequence) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
225 (push (buffer-substring-no-properties (point-min) eob) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
226 mh-folder-view-stack) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
227 (delete-region (point-min) eob) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
228 (mh-notate-deleted-and-refiled) |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
229 (mh-notate-cur) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
230 (when msg-at-cursor (mh-goto-msg msg-at-cursor t t)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
231 (setq mh-non-seq-mode-line-annotation mh-mode-line-annotation) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
232 (setq mh-mode-line-annotation (symbol-name sequence)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
233 (mh-make-folder-mode-line) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
234 (mh-recenter nil) |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
235 (when (and (boundp 'tool-bar-mode) tool-bar-mode) |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
236 (set (make-local-variable 'tool-bar-map) |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
237 mh-folder-seq-tool-bar-map) |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
238 (when (buffer-live-p (get-buffer mh-show-buffer)) |
70145
00cb3fe5fed5
* mh-tool-bar.el (image-load-path): Define to shush compiler.
Bill Wohler <wohler@newt.com>
parents:
70028
diff
changeset
|
239 (with-current-buffer mh-show-buffer |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
240 (set (make-local-variable 'tool-bar-map) |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
241 mh-show-seq-tool-bar-map)))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
242 (push 'widen mh-view-ops))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
243 (t |
68013
bbc0e52abce5
* mh-alias.el (mh-alias-add-alias): Grand message and error string
Bill Wohler <wohler@newt.com>
parents:
68012
diff
changeset
|
244 (error "No messages in sequence %s" (symbol-name sequence)))))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
245 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
246 ;;;###mh-autoload |
68465 | 247 (defun mh-narrow-to-tick () |
248 "Limit to ticked messages. | |
249 | |
250 What this command does is show only those messages that are in | |
251 the \"tick\" sequence (which you can customize via the | |
252 `mh-tick-seq' option) in the MH-Folder buffer. In addition, it | |
253 limits further MH-E searches to just those messages. When you | |
254 want to widen the view to all your messages again, use | |
255 \\[mh-widen]." | |
256 (interactive) | |
257 (cond ((not mh-tick-seq) | |
258 (error "Enable ticking by customizing `mh-tick-seq'")) | |
259 ((null (mh-seq-msgs (mh-find-seq mh-tick-seq))) | |
260 (message "No messages in %s sequence" mh-tick-seq)) | |
261 (t (mh-narrow-to-seq mh-tick-seq)))) | |
262 | |
263 ;;;###mh-autoload | |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
264 (defun mh-put-msg-in-seq (range sequence) |
67313
2ae99b10dd40
* mh-comp.el (mh-forward): Went over all uses of the word "RANGE" in
Bill Wohler <wohler@newt.com>
parents:
66661
diff
changeset
|
265 "Add RANGE to SEQUENCE\\<mh-folder-mode-map>. |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
266 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
267 Give this command a RANGE and you can add all the messages in a |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
268 sequence to another sequence (for example, |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
269 \"\\[universal-argument] \\[mh-put-msg-in-seq] SourceSequence RET |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
270 DestSequence RET\"). Check the documentation of |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
271 `mh-interactive-range' to see how RANGE is read in interactive |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
272 use." |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
273 (interactive (list (mh-interactive-range "Add messages from") |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
274 (mh-read-seq-default "Add to" nil))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
275 (unless (mh-valid-seq-p sequence) |
68013
bbc0e52abce5
* mh-alias.el (mh-alias-add-alias): Grand message and error string
Bill Wohler <wohler@newt.com>
parents:
68012
diff
changeset
|
276 (error "Can't put message in invalid sequence %s" sequence)) |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
277 (let* ((internal-seq-flag (mh-internal-seq sequence)) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
278 (original-msgs (mh-seq-msgs (mh-find-seq sequence))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
279 (folders (list mh-current-folder)) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
280 (msg-list (mh-range-to-msg-list range))) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
281 (mh-add-msgs-to-seq msg-list sequence nil t) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
282 (mh-iterate-on-range m range |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
283 (unless (memq m original-msgs) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
284 (mh-add-sequence-notation m internal-seq-flag))) |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
285 (if (not internal-seq-flag) |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
286 (setq mh-last-seq-used sequence)) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
287 (when mh-index-data |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
288 (setq folders |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
289 (append folders (mh-index-add-to-sequence sequence msg-list)))) |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
290 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p)) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
291 (apply #'mh-speed-flists t folders)))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
292 |
68465 | 293 ;;;###mh-autoload |
294 (defun mh-toggle-tick (range) | |
295 "Toggle tick mark of RANGE. | |
296 | |
297 This command adds messages to the \"tick\" sequence (which you can customize | |
298 via the option `mh-tick-seq'). This sequence can be viewed later with the | |
299 \\[mh-index-ticked-messages] command. | |
300 | |
301 Check the documentation of `mh-interactive-range' to see how RANGE is read in | |
302 interactive use." | |
303 (interactive (list (mh-interactive-range "Tick"))) | |
304 (unless mh-tick-seq | |
305 (error "Enable ticking by customizing `mh-tick-seq'")) | |
306 (let* ((tick-seq (mh-find-seq mh-tick-seq)) | |
307 (tick-seq-msgs (mh-seq-msgs tick-seq)) | |
308 (ticked ()) | |
309 (unticked ())) | |
310 (mh-iterate-on-range msg range | |
311 (cond ((member msg tick-seq-msgs) | |
312 (push msg unticked) | |
313 (setcdr tick-seq (delq msg (cdr tick-seq))) | |
314 (when (null (cdr tick-seq)) (setq mh-last-seq-used nil)) | |
315 (mh-remove-sequence-notation msg (mh-colors-in-use-p))) | |
316 (t | |
317 (push msg ticked) | |
318 (setq mh-last-seq-used mh-tick-seq) | |
319 (let ((mh-seq-list (cons `(,mh-tick-seq ,msg) mh-seq-list))) | |
320 (mh-add-sequence-notation msg (mh-colors-in-use-p)))))) | |
321 (mh-add-msgs-to-seq ticked mh-tick-seq nil t) | |
322 (mh-undefine-sequence mh-tick-seq unticked) | |
323 (when mh-index-data | |
324 (mh-index-add-to-sequence mh-tick-seq ticked) | |
325 (mh-index-delete-from-sequence mh-tick-seq unticked)))) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
326 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
327 ;;;###mh-autoload |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
328 (defun mh-widen (&optional all-flag) |
66661
f7b261d0f8e8
* mh-customize.el (mh-refile-preserves-sequences-flag)
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
329 "Remove last restriction. |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67760
diff
changeset
|
330 |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67760
diff
changeset
|
331 Each limit or sequence restriction can be undone in turn with |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67760
diff
changeset
|
332 this command. Give this command a prefix argument ALL-FLAG to |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67760
diff
changeset
|
333 remove all limits and sequence restrictions." |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
334 (interactive "P") |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
335 (let ((msg (mh-get-msg-num nil))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
336 (when mh-folder-view-stack |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
337 (cond (all-flag |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
338 (while (cdr mh-view-ops) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
339 (setq mh-view-ops (cdr mh-view-ops))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
340 (when (eq (car mh-view-ops) 'widen) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
341 (setq mh-view-ops (cdr mh-view-ops)))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
342 ((mh-valid-view-change-operation-p 'widen) nil) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
343 ((memq 'widen mh-view-ops) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
344 (while (not (eq (car mh-view-ops) 'widen)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
345 (setq mh-view-ops (cdr mh-view-ops))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
346 (setq mh-view-ops (cdr mh-view-ops))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
347 (t (error "Widening is not applicable"))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
348 ;; If ALL-FLAG is non-nil then rewind stacks |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
349 (when all-flag |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
350 (while (cdr mh-thread-scan-line-map-stack) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
351 (setq mh-thread-scan-line-map-stack |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
352 (cdr mh-thread-scan-line-map-stack))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
353 (while (cdr mh-folder-view-stack) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
354 (setq mh-folder-view-stack (cdr mh-folder-view-stack)))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
355 (setq mh-thread-scan-line-map (pop mh-thread-scan-line-map-stack)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
356 (with-mh-folder-updating (t) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
357 (delete-region (point-min) (point-max)) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
358 (insert (pop mh-folder-view-stack)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
359 (mh-remove-all-notation) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
360 (setq mh-mode-line-annotation mh-non-seq-mode-line-annotation) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
361 (mh-make-folder-mode-line)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
362 (if msg |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
363 (mh-goto-msg msg t t)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
364 (mh-notate-deleted-and-refiled) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
365 (mh-notate-user-sequences) |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
366 (mh-notate-cur) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
367 (mh-recenter nil))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
368 (when (and (null mh-folder-view-stack) (boundp 'tool-bar-mode) tool-bar-mode) |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
369 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map) |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
370 (when (buffer-live-p (get-buffer mh-show-buffer)) |
70145
00cb3fe5fed5
* mh-tool-bar.el (image-load-path): Define to shush compiler.
Bill Wohler <wohler@newt.com>
parents:
70028
diff
changeset
|
371 (with-current-buffer mh-show-buffer |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
372 (set (make-local-variable 'tool-bar-map) mh-show-tool-bar-map))))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
373 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
374 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
375 |
68465 | 376 ;;; Support Routines |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
377 |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
378 (defvar mh-sequence-history ()) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
379 |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
380 ;;;###mh-autoload |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
381 (defun mh-read-seq-default (prompt not-empty) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
382 "Read and return sequence name with default narrowed or previous sequence. |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
383 PROMPT is the prompt to use when reading. If NOT-EMPTY is non-nil |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
384 then a non-empty sequence is read." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
385 (mh-read-seq prompt not-empty |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
386 (or mh-last-seq-used |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
387 (car (mh-seq-containing-msg (mh-get-msg-num nil) nil))))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
388 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
389 (defun mh-read-seq (prompt not-empty &optional default) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
390 "Read and return a sequence name. |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
391 Prompt with PROMPT, raise an error if the sequence is empty and |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
392 the NOT-EMPTY flag is non-nil, and supply an optional DEFAULT |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
393 sequence. A reply of '%' defaults to the first sequence |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
394 containing the current message." |
68012
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
395 (let* ((input (completing-read (format "%s sequence%s: " prompt |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
396 (if default |
68012
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
397 (format " (default %s)" default) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
398 "")) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
399 (mh-seq-names mh-seq-list) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
400 nil nil nil 'mh-sequence-history)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
401 (seq (cond ((equal input "%") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
402 (car (mh-seq-containing-msg (mh-get-msg-num t) nil))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
403 ((equal input "") default) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
404 (t (intern input)))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
405 (msgs (mh-seq-to-msgs seq))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
406 (if (and (null msgs) not-empty) |
68013
bbc0e52abce5
* mh-alias.el (mh-alias-add-alias): Grand message and error string
Bill Wohler <wohler@newt.com>
parents:
68012
diff
changeset
|
407 (error "No messages in sequence %s" seq)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
408 seq)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
409 |
68465 | 410 (defun mh-internal-seq (name) |
411 "Return non-nil if NAME is the name of an internal MH-E sequence." | |
412 (or (memq name mh-internal-seqs) | |
413 (eq name mh-unseen-seq) | |
414 (and (mh-colors-in-use-p) mh-tick-seq (eq name mh-tick-seq)) | |
415 (eq name mh-previous-seq) | |
416 (mh-folder-name-p name))) | |
417 | |
418 ;;;###mh-autoload | |
419 (defun mh-valid-seq-p (name) | |
420 "Return non-nil if NAME is a valid MH sequence name." | |
421 (and (symbolp name) | |
422 (string-match "^[a-zA-Z][a-zA-Z0-9]*$" (symbol-name name)))) | |
423 | |
424 ;;;###mh-autoload | |
425 (defun mh-find-seq (name) | |
426 "Return sequence NAME." | |
427 (assoc name mh-seq-list)) | |
428 | |
429 ;;;###mh-autoload | |
430 (defun mh-seq-to-msgs (seq) | |
431 "Return a list of the messages in SEQ." | |
432 (mh-seq-msgs (mh-find-seq seq))) | |
433 | |
434 (defun mh-seq-containing-msg (msg &optional include-internal-flag) | |
435 "Return a list of the sequences containing MSG. | |
436 If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences | |
437 in list." | |
438 (let ((l mh-seq-list) | |
439 (seqs ())) | |
440 (while l | |
441 (and (memq msg (mh-seq-msgs (car l))) | |
442 (or include-internal-flag | |
443 (not (mh-internal-seq (mh-seq-name (car l))))) | |
444 (setq seqs (cons (mh-seq-name (car l)) seqs))) | |
445 (setq l (cdr l))) | |
446 seqs)) | |
447 | |
448 ;;;###mh-autoload | |
449 (defun mh-define-sequence (seq msgs) | |
450 "Define the SEQ to contain the list of MSGS. | |
451 Do not mark pseudo-sequences or empty sequences. | |
452 Signals an error if SEQ is an invalid name." | |
453 (if (and msgs | |
454 (mh-valid-seq-p seq) | |
455 (not (mh-folder-name-p seq))) | |
456 (save-excursion | |
457 (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero" | |
458 "-sequence" (symbol-name seq) | |
459 (mh-coalesce-msg-list msgs))))) | |
460 | |
461 ;;;###mh-autoload | |
462 (defun mh-undefine-sequence (seq msgs) | |
463 "Remove from the SEQ the list of MSGS." | |
464 (when (and (mh-valid-seq-p seq) msgs) | |
465 (apply #'mh-exec-cmd "mark" mh-current-folder "-delete" | |
466 "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs)))) | |
467 | |
468 ;;;###mh-autoload | |
469 (defun mh-add-msgs-to-seq (msgs seq &optional internal-flag dont-annotate-flag) | |
470 "Add MSGS to SEQ. | |
471 | |
472 Remove duplicates and keep sequence sorted. If optional | |
473 INTERNAL-FLAG is non-nil, do not mark the message in the scan | |
474 listing or inform MH of the addition. | |
475 | |
476 If DONT-ANNOTATE-FLAG is non-nil then the annotations in the | |
477 folder buffer are not updated." | |
478 (let ((entry (mh-find-seq seq)) | |
479 (internal-seq-flag (mh-internal-seq seq))) | |
480 (if (and msgs (atom msgs)) (setq msgs (list msgs))) | |
481 (if (null entry) | |
482 (setq mh-seq-list | |
483 (cons (mh-make-seq seq (mh-canonicalize-sequence msgs)) | |
484 mh-seq-list)) | |
485 (if msgs (setcdr entry (mh-canonicalize-sequence | |
486 (append msgs (mh-seq-msgs entry)))))) | |
487 (unless internal-flag | |
488 (mh-add-to-sequence seq msgs) | |
489 (when (not dont-annotate-flag) | |
490 (mh-iterate-on-range msg msgs | |
491 (unless (memq msg (cdr entry)) | |
492 (mh-add-sequence-notation msg internal-seq-flag))))))) | |
493 | |
494 (defun mh-add-to-sequence (seq msgs) | |
495 "The sequence SEQ is augmented with the messages in MSGS." | |
496 ;; Add to a SEQUENCE each message the list of MSGS. | |
497 (if (and (mh-valid-seq-p seq) (not (mh-folder-name-p seq))) | |
498 (if msgs | |
499 (apply 'mh-exec-cmd "mark" mh-current-folder "-add" | |
500 "-sequence" (symbol-name seq) | |
501 (mh-coalesce-msg-list msgs))))) | |
502 | |
503 (defun mh-canonicalize-sequence (msgs) | |
504 "Sort MSGS in decreasing order and remove duplicates." | |
505 (let* ((sorted-msgs (sort (copy-sequence msgs) '>)) | |
506 (head sorted-msgs)) | |
507 (while (cdr head) | |
508 (if (= (car head) (cadr head)) | |
509 (setcdr head (cddr head)) | |
510 (setq head (cdr head)))) | |
511 sorted-msgs)) | |
512 | |
513 (defun mh-delete-a-msg-from-seq (msg sequence internal-flag) | |
514 "Delete MSG from SEQUENCE. | |
515 If INTERNAL-FLAG is non-nil, then do not inform MH of the | |
516 change." | |
517 (let ((entry (mh-find-seq sequence))) | |
518 (when (and entry (memq msg (mh-seq-msgs entry))) | |
519 (if (not internal-flag) | |
520 (mh-undefine-sequence sequence (list msg))) | |
521 (setcdr entry (delq msg (mh-seq-msgs entry)))))) | |
522 | |
523 (defun mh-delete-seq-locally (seq) | |
524 "Remove MH-E's record of SEQ." | |
525 (let ((entry (mh-find-seq seq))) | |
526 (setq mh-seq-list (delq entry mh-seq-list)))) | |
527 | |
528 (defun mh-copy-seq-to-eob (seq) | |
529 "Copy SEQ to the end of the buffer." | |
530 ;; It is quite involved to write something which will work at any place in | |
531 ;; the buffer, so we will write something which works only at the end of | |
532 ;; the buffer. If we ever need to insert sequences in the middle of the | |
533 ;; buffer, this will need to be fixed. | |
534 (save-excursion | |
535 (let* ((msgs (mh-seq-to-msgs seq)) | |
536 (coalesced-msgs (mh-coalesce-msg-list msgs))) | |
537 (goto-char (point-max)) | |
538 (save-restriction | |
539 (narrow-to-region (point) (point)) | |
540 (mh-regenerate-headers coalesced-msgs t) | |
541 (cond ((memq 'unthread mh-view-ops) | |
542 ;; Populate restricted scan-line map | |
543 (mh-remove-all-notation) | |
544 (mh-iterate-on-range msg (cons (point-min) (point-max)) | |
545 (setf (gethash msg mh-thread-scan-line-map) | |
546 (mh-thread-parse-scan-line))) | |
547 ;; Remove scan lines and read results from pre-computed tree | |
548 (delete-region (point-min) (point-max)) | |
549 (mh-thread-print-scan-lines | |
550 (mh-thread-generate mh-current-folder ())) | |
551 (mh-notate-user-sequences)) | |
552 (mh-index-data | |
553 (mh-index-insert-folder-headers))))))) | |
554 | |
555 ;;;###mh-autoload | |
556 (defun mh-valid-view-change-operation-p (op) | |
557 "Check if the view change operation can be performed. | |
558 OP is one of 'widen and 'unthread." | |
559 (cond ((eq (car mh-view-ops) op) | |
560 (pop mh-view-ops)) | |
561 (t nil))) | |
562 | |
67681 | 563 |
564 | |
68465 | 565 ;;; Ranges |
67681 | 566 |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
567 (defvar mh-range-seq-names) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
568 (defvar mh-range-history ()) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
569 (defvar mh-range-completion-map (copy-keymap minibuffer-local-completion-map)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
570 (define-key mh-range-completion-map " " 'self-insert-command) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
571 |
68465 | 572 ;;;###mh-autoload |
573 (defun mh-interactive-range (range-prompt &optional default) | |
574 "Return interactive specification for message, sequence, range or region. | |
575 By convention, the name of this argument is RANGE. | |
576 | |
577 If variable `transient-mark-mode' is non-nil and the mark is active, | |
578 then this function returns a cons-cell of the region. | |
579 | |
580 If optional prefix argument is provided, then prompt for message range | |
581 with RANGE-PROMPT. A list of messages in that range is returned. | |
582 | |
583 If a MH range is given, say something like last:20, then a list | |
584 containing the messages in that range is returned. | |
585 | |
586 If DEFAULT non-nil then it is returned. | |
587 | |
588 Otherwise, the message number at point is returned. | |
589 | |
590 This function is usually used with `mh-iterate-on-range' in order to | |
591 provide a uniform interface to MH-E functions." | |
592 (cond ((mh-mark-active-p t) (cons (region-beginning) (region-end))) | |
593 (current-prefix-arg (mh-read-range range-prompt nil nil t t)) | |
594 (default default) | |
595 (t (mh-get-msg-num t)))) | |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
596 |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
597 ;;;###mh-autoload |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
598 (defun mh-read-range (prompt &optional folder default |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
599 expand-flag ask-flag number-as-range-flag) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
600 "Read a message range with PROMPT. |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
601 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
602 If FOLDER is non-nil then a range is read from that folder, otherwise |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
603 use `mh-current-folder'. |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
604 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
605 If DEFAULT is a string then use that as default range to return. If |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
606 DEFAULT is nil then ask user with default answer a range based on the |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
607 sequences that seem relevant. Finally if DEFAULT is t, try to avoid |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
608 prompting the user. Unseen messages, if present, are returned. If the |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
609 folder has fewer than `mh-large-folder' messages then \"all\" messages |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
610 are returned. Finally as a last resort prompt the user. |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
611 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
612 If EXPAND-FLAG is non-nil then a list of message numbers corresponding |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
613 to the input is returned. If this list is empty then an error is |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
614 raised. If EXPAND-FLAG is nil just return the input string. In this |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
615 case we don't check if the range is empty. |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
616 |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
617 If ASK-FLAG is non-nil, then the user is always queried for a range of |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
618 messages. If ASK-FLAG is nil, then the function checks if the unseen |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
619 sequence is non-empty. If that is the case, `mh-unseen-seq', or the |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
620 list of messages in it depending on the value of EXPAND, is returned. |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
621 Otherwise if the folder has fewer than `mh-large-folder' messages then |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
622 the list of messages corresponding to \"all\" is returned. If neither |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
623 of the above holds then as a last resort the user is queried for a |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
624 range of messages. |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
625 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
626 If NUMBER-AS-RANGE-FLAG is non-nil, then if a number, N is read as |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
627 input, it is interpreted as the range \"last:N\". |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
628 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
629 This function replaces the existing function `mh-read-msg-range'. |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
630 Calls to: |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
631 |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
632 (mh-read-msg-range folder flag) |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
633 |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
634 should be replaced with: |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
635 |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
636 (mh-read-range \"Suitable prompt\" folder t nil flag |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
637 mh-interpret-number-as-range-flag)" |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
638 (setq default (or default mh-last-seq-used |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
639 (car (mh-seq-containing-msg (mh-get-msg-num nil) t))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
640 prompt (format "%s range" prompt)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
641 (let* ((folder (or folder mh-current-folder)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
642 (guess (eq default t)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
643 (counts (and guess (mh-folder-size folder))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
644 (unseen (and counts (> (cadr counts) 0))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
645 (large (and counts mh-large-folder (> (car counts) mh-large-folder))) |
68012
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
646 (default (cond ((and guess large) (format "last:%s" mh-large-folder)) |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
647 ((and guess (not large)) "all") |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
648 ((stringp default) default) |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
649 ((symbolp default) (symbol-name default)))) |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
650 (prompt (cond ((and guess large default) |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
651 (format "%s (folder has %s messages, default %s)" |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
652 prompt (car counts) default)) |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
653 ((and guess large) |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
654 (format "%s (folder has %s messages)" |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
655 prompt (car counts))) |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
656 (default |
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
657 (format "%s (default %s)" prompt default)))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
658 (minibuffer-local-completion-map mh-range-completion-map) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
659 (seq-list (if (eq folder mh-current-folder) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
660 mh-seq-list |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
661 (mh-read-folder-sequences folder nil))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
662 (mh-range-seq-names |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
663 (append '(("first") ("last") ("all") ("prev") ("next")) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
664 (mh-seq-names seq-list))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
665 (input (cond ((and (not ask-flag) unseen) (symbol-name mh-unseen-seq)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
666 ((and (not ask-flag) (not large)) "all") |
68012
256cc87e0619
* mh-comp.el (mh-reply): Use standard default notation in prompts
Bill Wohler <wohler@newt.com>
parents:
67988
diff
changeset
|
667 (t (completing-read (format "%s: " prompt) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
668 'mh-range-completion-function nil nil |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
669 nil 'mh-range-history default)))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
670 msg-list) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
671 (when (and number-as-range-flag |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
672 (string-match "^[ \t]*\\([0-9]+\\)[ \t]*$" input)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
673 (setq input (concat "last:" (match-string 1 input)))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
674 (cond ((not expand-flag) input) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
675 ((assoc (intern input) seq-list) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
676 (cdr (assoc (intern input) seq-list))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
677 ((setq msg-list (mh-translate-range folder input)) msg-list) |
68013
bbc0e52abce5
* mh-alias.el (mh-alias-add-alias): Grand message and error string
Bill Wohler <wohler@newt.com>
parents:
68012
diff
changeset
|
678 (t (error "No messages in range %s" input))))) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
679 |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
680 ;;;###mh-autoload |
68465 | 681 (defun mh-range-to-msg-list (range) |
682 "Return a list of messages for RANGE. | |
683 | |
684 Check the documentation of `mh-interactive-range' to see how | |
685 RANGE is read in interactive use." | |
686 (let (msg-list) | |
687 (mh-iterate-on-range msg range | |
688 (push msg msg-list)) | |
689 (nreverse msg-list))) | |
690 | |
691 ;;;###mh-autoload | |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
692 (defun mh-translate-range (folder expr) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
693 "In FOLDER, translate the string EXPR to a list of messages numbers." |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
694 (save-excursion |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
695 (let ((strings (delete "" (split-string expr "[ \t\n]"))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
696 (result ())) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
697 (ignore-errors |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
698 (apply #'mh-exec-cmd-quiet nil "mhpath" folder strings) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
699 (set-buffer mh-temp-buffer) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
700 (goto-char (point-min)) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
701 (while (re-search-forward "/\\([0-9]*\\)$" nil t) |
68212
0c77c0b9a620
* mh-comp.el (mh-show-buffer-message-number): Replace (car
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
702 (push (string-to-number (match-string 1)) result)) |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
703 (nreverse result))))) |
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
704 |
68465 | 705 (defun mh-range-completion-function (string predicate flag) |
706 "Programmable completion of message ranges. | |
707 STRING is the user input that is to be completed. PREDICATE if non-nil is a | |
708 function used to filter the possible choices and FLAG determines whether the | |
709 completion is over." | |
710 (let* ((candidates mh-range-seq-names) | |
711 (last-char (and (not (equal string "")) | |
712 (aref string (1- (length string))))) | |
713 (last-word (cond ((null last-char) "") | |
714 ((memq last-char '(? ?- ?:)) "") | |
715 (t (car (last (split-string string "[ -:]+")))))) | |
716 (prefix (substring string 0 (- (length string) (length last-word))))) | |
717 (cond ((eq flag nil) | |
718 (let ((res (try-completion last-word candidates predicate))) | |
719 (cond ((null res) nil) | |
720 ((eq res t) t) | |
721 (t (concat prefix res))))) | |
722 ((eq flag t) | |
723 (all-completions last-word candidates predicate)) | |
724 ((eq flag 'lambda) | |
725 (loop for x in candidates | |
726 when (equal x last-word) return t | |
727 finally return nil))))) | |
728 | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
729 (defun mh-seq-names (seq-list) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
730 "Return an alist containing the names of the SEQ-LIST." |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
731 (mapcar (lambda (entry) (list (symbol-name (mh-seq-name entry)))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
732 seq-list)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
733 |
68465 | 734 (defun mh-folder-size (folder) |
735 "Find size of FOLDER." | |
736 (if mh-flists-present-flag | |
737 (mh-folder-size-flist folder) | |
738 (mh-folder-size-folder folder))) | |
739 | |
740 (defun mh-folder-size-flist (folder) | |
741 "Find size of FOLDER using \"flist\"." | |
742 (with-temp-buffer | |
743 (call-process (expand-file-name "flist" mh-progs) nil t nil "-showzero" | |
744 "-norecurse" folder "-sequence" (symbol-name mh-unseen-seq)) | |
745 (goto-char (point-min)) | |
746 (multiple-value-bind (folder unseen total) | |
747 (mh-parse-flist-output-line | |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
748 (buffer-substring (point) (mh-line-end-position))) |
68465 | 749 (values total unseen folder)))) |
750 | |
751 (defun mh-folder-size-folder (folder) | |
752 "Find size of FOLDER using \"folder\"." | |
753 (with-temp-buffer | |
754 (let ((u (length (cdr (assoc mh-unseen-seq | |
755 (mh-read-folder-sequences folder nil)))))) | |
756 (call-process (expand-file-name "folder" mh-progs) nil t nil | |
757 "-norecurse" folder) | |
758 (goto-char (point-min)) | |
759 (if (re-search-forward " has \\([0-9]+\\) " nil t) | |
760 (values (string-to-number (match-string 1)) u folder) | |
761 (values 0 u folder))))) | |
762 | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
763 ;;;###mh-autoload |
68465 | 764 (defun mh-parse-flist-output-line (line &optional current-folder) |
765 "Parse LINE to generate folder name, unseen messages and total messages. | |
766 If CURRENT-FOLDER is non-nil then it contains the current folder | |
767 name and it is used to avoid problems in corner cases involving | |
768 folders whose names end with a '+' character." | |
769 (with-temp-buffer | |
770 (insert line) | |
771 (goto-char (point-max)) | |
772 (let (folder unseen total p) | |
773 (when (search-backward " out of " (point-min) t) | |
774 (setq total (string-to-number | |
775 (buffer-substring-no-properties | |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
776 (match-end 0) (mh-line-end-position)))) |
68465 | 777 (when (search-backward " in sequence " (point-min) t) |
778 (setq p (point)) | |
779 (when (search-backward " has " (point-min) t) | |
780 (setq unseen (string-to-number (buffer-substring-no-properties | |
781 (match-end 0) p))) | |
782 (while (eq (char-after) ? ) | |
783 (backward-char)) | |
784 (setq folder (buffer-substring-no-properties | |
785 (point-min) (1+ (point)))) | |
786 (when (and (equal (aref folder (1- (length folder))) ?+) | |
787 (equal current-folder folder)) | |
788 (setq folder (substring folder 0 (1- (length folder))))) | |
789 (values (format "+%s" folder) unseen total))))))) | |
790 | |
791 ;;;###mh-autoload | |
792 (defun mh-read-folder-sequences (folder save-refiles) | |
793 "Read and return the predefined sequences for a FOLDER. | |
794 If SAVE-REFILES is non-nil, then keep the sequences | |
795 that note messages to be refiled." | |
796 (let ((seqs ())) | |
797 (cond (save-refiles | |
798 (mh-mapc (function (lambda (seq) ; Save the refiling sequences | |
799 (if (mh-folder-name-p (mh-seq-name seq)) | |
800 (setq seqs (cons seq seqs))))) | |
801 mh-seq-list))) | |
802 (save-excursion | |
803 (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list")) | |
804 (progn | |
805 ;; look for name in line of form "cur: 4" or "myseq (private): 23" | |
806 (while (re-search-forward "^[^: ]+" nil t) | |
807 (setq seqs (cons (mh-make-seq (intern (buffer-substring | |
808 (match-beginning 0) | |
809 (match-end 0))) | |
810 (mh-read-msg-list)) | |
811 seqs))) | |
812 (delete-region (point-min) (point))))) ; avoid race with | |
813 ; mh-process-daemon | |
814 seqs)) | |
815 | |
816 (defun mh-read-msg-list () | |
817 "Return a list of message numbers from point to the end of the line. | |
818 Expands ranges into set of individual numbers." | |
819 (let ((msgs ()) | |
820 (end-of-line (save-excursion (end-of-line) (point))) | |
821 num) | |
822 (while (re-search-forward "[0-9]+" end-of-line t) | |
823 (setq num (string-to-number (buffer-substring (match-beginning 0) | |
824 (match-end 0)))) | |
825 (cond ((looking-at "-") ; Message range | |
826 (forward-char 1) | |
827 (re-search-forward "[0-9]+" end-of-line t) | |
828 (let ((num2 (string-to-number | |
829 (buffer-substring (match-beginning 0) | |
830 (match-end 0))))) | |
831 (if (< num2 num) | |
832 (error "Bad message range: %d-%d" num num2)) | |
833 (while (<= num num2) | |
834 (setq msgs (cons num msgs)) | |
835 (setq num (1+ num))))) | |
836 ((not (zerop num)) ;"pick" outputs "0" to mean no match | |
837 (setq msgs (cons num msgs))))) | |
838 msgs)) | |
839 | |
840 | |
841 | |
842 ;;; Notation | |
843 | |
844 ;;;###mh-autoload | |
845 (defun mh-notate (msg notation offset) | |
846 "Mark MSG with the character NOTATION at position OFFSET. | |
847 Null MSG means the message at cursor. | |
848 If NOTATION is nil then no change in the buffer occurs." | |
849 (save-excursion | |
850 (if (or (null msg) | |
851 (mh-goto-msg msg t t)) | |
852 (with-mh-folder-updating (t) | |
853 (beginning-of-line) | |
854 (forward-char offset) | |
855 (let* ((change-stack-flag | |
856 (and (equal offset | |
857 (+ mh-cmd-note mh-scan-field-destination-offset)) | |
858 (not (eq notation mh-note-seq)))) | |
859 (msg (and change-stack-flag (or msg (mh-get-msg-num nil)))) | |
860 (stack (and msg (gethash msg mh-sequence-notation-history))) | |
861 (notation (or notation (char-after)))) | |
862 (if stack | |
863 ;; The presence of the stack tells us that we don't need to | |
864 ;; notate the message, since the notation would be replaced | |
865 ;; by a sequence notation. So we will just put the notation | |
866 ;; at the bottom of the stack. If the sequence is deleted, | |
867 ;; the correct notation will be shown. | |
868 (setf (gethash msg mh-sequence-notation-history) | |
869 (reverse (cons notation (cdr (reverse stack))))) | |
870 ;; Since we don't have any sequence notations in the way, just | |
871 ;; notate the scan line. | |
872 (delete-char 1) | |
873 (insert notation)) | |
874 (when change-stack-flag | |
875 (mh-thread-update-scan-line-map msg notation offset))))))) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
876 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
877 ;;;###mh-autoload |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
878 (defun mh-notate-cur () |
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
879 "Mark the MH sequence cur. |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
880 In addition to notating the current message with `mh-note-cur' |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
881 the function uses `overlay-arrow-position' to put a marker in the |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
882 fringe." |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
883 (let ((cur (car (mh-seq-to-msgs 'cur)))) |
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
884 (when (and cur (mh-goto-msg cur t t)) |
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
885 (beginning-of-line) |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
886 (when (looking-at mh-scan-good-msg-regexp) |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
887 (mh-notate nil mh-note-cur mh-cmd-note)) |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
888 (setq mh-arrow-marker (set-marker mh-arrow-marker (point))) |
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
889 (setq overlay-arrow-position mh-arrow-marker)))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
890 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
891 ;;;###mh-autoload |
68465 | 892 (defun mh-remove-cur-notation () |
893 "Remove old cur notation." | |
894 (let ((cur-msg (car (mh-seq-to-msgs 'cur)))) | |
895 (save-excursion | |
896 (when (and cur-msg | |
897 (mh-goto-msg cur-msg t t) | |
898 (looking-at mh-scan-cur-msg-number-regexp)) | |
899 (mh-notate nil ? mh-cmd-note) | |
900 (setq overlay-arrow-position nil))))) | |
49578
b35587af8747
Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents:
49459
diff
changeset
|
901 |
68465 | 902 ;; FIXME? We may want to clear all notations and add one for current-message |
903 ;; and process user sequences. | |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
904 ;;;###mh-autoload |
68465 | 905 (defun mh-notate-deleted-and-refiled () |
906 "Notate messages marked for deletion or refiling. | |
907 Messages to be deleted are given by `mh-delete-list' while | |
908 messages to be refiled are present in `mh-refile-list'." | |
909 (let ((refiled-hash (make-hash-table)) | |
910 (deleted-hash (make-hash-table))) | |
911 (dolist (msg mh-delete-list) | |
912 (setf (gethash msg deleted-hash) t)) | |
913 (dolist (dest-msg-list mh-refile-list) | |
914 (dolist (msg (cdr dest-msg-list)) | |
915 (setf (gethash msg refiled-hash) t))) | |
916 (mh-iterate-on-messages-in-region msg (point-min) (point-max) | |
917 (cond ((gethash msg refiled-hash) | |
918 (mh-notate nil mh-note-refiled mh-cmd-note)) | |
919 ((gethash msg deleted-hash) | |
920 (mh-notate nil mh-note-deleted mh-cmd-note)))))) | |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
921 |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
922 ;;;###mh-autoload |
68465 | 923 (defun mh-notate-user-sequences (&optional range) |
924 "Mark user-defined sequences in RANGE. | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
925 |
68465 | 926 Check the documentation of `mh-interactive-range' to see how |
927 RANGE is read in interactive use; if nil all messages are | |
928 notated." | |
929 (unless range | |
930 (setq range (cons (point-min) (point-max)))) | |
931 (let ((seqs mh-seq-list) | |
932 (msg-hash (make-hash-table))) | |
933 (dolist (seq seqs) | |
934 (dolist (msg (mh-seq-msgs seq)) | |
935 (push (car seq) (gethash msg msg-hash)))) | |
936 (mh-iterate-on-range msg range | |
937 (loop for seq in (gethash msg msg-hash) | |
938 do (mh-add-sequence-notation msg (mh-internal-seq seq)))))) | |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
939 |
68465 | 940 (defun mh-add-sequence-notation (msg internal-seq-flag) |
941 "Add sequence notation to the MSG on the current line. | |
942 If INTERNAL-SEQ-FLAG is non-nil, then refontify the scan line if | |
943 font-lock is turned on." | |
944 (with-mh-folder-updating (t) | |
945 (save-excursion | |
946 (beginning-of-line) | |
947 (if internal-seq-flag | |
948 (progn | |
949 ;; Change the buffer so that if transient-mark-mode is active | |
950 ;; and there is an active region it will get deactivated as in | |
951 ;; the case of user sequences. | |
952 (mh-notate nil nil mh-cmd-note) | |
953 (when font-lock-mode | |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
954 (font-lock-fontify-region (point) (mh-line-end-position)))) |
68465 | 955 (forward-char (+ mh-cmd-note mh-scan-field-destination-offset)) |
956 (let ((stack (gethash msg mh-sequence-notation-history))) | |
957 (setf (gethash msg mh-sequence-notation-history) | |
958 (cons (char-after) stack))) | |
959 (mh-notate nil mh-note-seq | |
960 (+ mh-cmd-note mh-scan-field-destination-offset)))))) | |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
961 |
68465 | 962 (defun mh-remove-sequence-notation (msg internal-seq-flag &optional all) |
963 "Remove sequence notation from the MSG on the current line. | |
964 If INTERNAL-SEQ-FLAG is non-nil, then `font-lock' was used to | |
965 highlight the sequence. In that case, no notation needs to be removed. | |
966 Otherwise the effect of inserting `mh-note-seq' needs to be reversed. | |
967 If ALL is non-nil, then all sequence marks on the scan line are | |
968 removed." | |
969 (with-mh-folder-updating (t) | |
970 ;; This takes care of internal sequences... | |
971 (mh-notate nil nil mh-cmd-note) | |
972 (unless internal-seq-flag | |
973 ;; ... and this takes care of user sequences. | |
974 (let ((stack (gethash msg mh-sequence-notation-history))) | |
975 (while (and all (cdr stack)) | |
976 (setq stack (cdr stack))) | |
977 (when stack | |
978 (save-excursion | |
979 (beginning-of-line) | |
980 (forward-char (+ mh-cmd-note mh-scan-field-destination-offset)) | |
981 (delete-char 1) | |
982 (insert (car stack)))) | |
983 (setf (gethash msg mh-sequence-notation-history) (cdr stack)))))) | |
62847
aa8c2e12ee24
Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents:
62465
diff
changeset
|
984 |
56406
d36b00b98db0
Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents:
52401
diff
changeset
|
985 ;;;###mh-autoload |
68465 | 986 (defun mh-remove-all-notation () |
987 "Remove all notations on all scan lines that MH-E introduces." | |
988 (save-excursion | |
989 (setq overlay-arrow-position nil) | |
990 (goto-char (point-min)) | |
991 (mh-iterate-on-range msg (cons (point-min) (point-max)) | |
992 (mh-notate nil ? mh-cmd-note) | |
993 (mh-remove-sequence-notation msg nil t)) | |
994 (clrhash mh-sequence-notation-history))) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
995 |
67681 | 996 |
997 | |
68465 | 998 ;; XXX Unused, delete, or create bind key? |
999 (defun mh-rename-seq (sequence new-name) | |
1000 "Rename SEQUENCE to have NEW-NAME." | |
1001 (interactive (list (mh-read-seq "Old" t) | |
1002 (intern (read-string "New sequence name: ")))) | |
1003 (let ((old-seq (mh-find-seq sequence))) | |
1004 (or old-seq | |
1005 (error "Sequence %s does not exist" sequence)) | |
1006 ;; Create new sequence first, since it might raise an error. | |
1007 (mh-define-sequence new-name (mh-seq-msgs old-seq)) | |
1008 (mh-undefine-sequence sequence (mh-seq-msgs old-seq)) | |
1009 (rplaca old-seq new-name))) | |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1010 |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1011 (provide 'mh-seq) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1012 |
67681 | 1013 ;; Local Variables: |
1014 ;; indent-tabs-mode: nil | |
1015 ;; sentence-end-double-space: nil | |
1016 ;; End: | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1017 |
67681 | 1018 ;; arch-tag: 8e952711-01a2-485b-bf21-c9e3ad4de942 |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1019 ;;; mh-seq.el ends here |