annotate lisp/mail/mh-seq.el @ 6450:1b17fc16d5c5

entered into RCS
author Richard M. Stallman <rms@gnu.org>
date Mon, 21 Mar 1994 07:47:05 +0000
parents a1b8926f7ece
children c9c652970786
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; mh-seq --- mh-e sequences support
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;; Time-stamp: <93/12/02 09:36:09 gildea>
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; Copyright 1993 Free Software Foundation, Inc.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; This file is part of mh-e.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; mh-e is free software; you can redistribute it and/or modify
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; any later version.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; mh-e is distributed in the hope that it will be useful,
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; along with mh-e; see the file COPYING. If not, write to
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;;; Commentary:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Internal support for mh-e package.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Code:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 (provide 'mh-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 (require 'mh-e)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 (defvar mh-last-seq-used nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 "Name of the sequence to which a message was last added.")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 (defun mh-delete-seq (seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 "Delete the SEQUENCE."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 (interactive (list (mh-read-seq-default "Delete" t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (mh-map-to-seq-msgs 'mh-notate-if-in-one-seq seq ? (1+ mh-cmd-note) seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (mh-undefine-sequence seq "all")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (mh-delete-seq-locally seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (defun mh-list-sequences (folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 "List the sequences defined in FOLDER."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (interactive (list (mh-prompt-for-folder "List sequences in"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 mh-current-folder t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (let ((temp-buffer " *mh-temp*")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (seq-list mh-seq-list))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (with-output-to-temp-buffer temp-buffer
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (set-buffer temp-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (message "Listing sequences ...")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (insert "Sequences in folder " folder ":\n")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (while seq-list
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (let ((name (mh-seq-name (car seq-list)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (sorted-seq-msgs
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (sort (copy-sequence (mh-seq-msgs (car seq-list))) '<))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (last-col (- (window-width) 4))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 name-spec)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (insert (setq name-spec (format "%20s:" name)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (while sorted-seq-msgs
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (if (> (current-column) last-col)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (progn
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (insert "\n")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (move-to-column (length name-spec))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (insert (format " %s" (car sorted-seq-msgs)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (setq sorted-seq-msgs (cdr sorted-seq-msgs)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (insert "\n"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (setq seq-list (cdr seq-list)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (message "Listing sequences...done")))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (defun mh-msg-is-in-seq (msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 "Display the sequences that contain MESSAGE (default: displayed message)."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (interactive (list (mh-get-msg-num t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (message "Message %d is in sequences: %s"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 msg
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (mapconcat 'concat
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (mh-list-to-string (mh-seq-containing-msg msg))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 " ")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (defun mh-narrow-to-seq (seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 "Restrict display of this folder to just messages in a sequence.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 Reads which sequence.\\<mh-folder-mode-map> Use \\[mh-widen] to undo this command."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (interactive (list (mh-read-seq "Narrow to" t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (let ((eob (point-max)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (with-mh-folder-updating (t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (cond ((mh-seq-to-msgs seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (mh-copy-seq-to-point seq eob)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (narrow-to-region eob (point-max))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (mh-make-folder-mode-line (symbol-name seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (mh-recenter nil)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (setq mh-narrowed-to-seq seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (t
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (error "No messages in sequence `%s'" (symbol-name seq)))))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (defun mh-put-msg-in-seq (msg-or-seq to)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 "Add MESSAGE(s) (default: displayed message) to SEQUENCE.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 If optional prefix argument provided, then prompt for the message sequence."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (interactive (list (if current-prefix-arg
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (mh-read-seq-default "Add messages from" t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (mh-get-msg-num t))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (mh-read-seq-default "Add to" nil)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (setq mh-last-seq-used to)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (mh-add-msgs-to-seq (if (numberp msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 msg-or-seq
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (mh-seq-to-msgs msg-or-seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 to))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (defun mh-widen ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 "Remove restrictions from current folder, thereby showing all messages."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (if mh-narrowed-to-seq
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (with-mh-folder-updating (t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (delete-region (point-min) (point-max))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (widen)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (mh-make-folder-mode-line)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (setq mh-narrowed-to-seq nil))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;;; Commands to manipulate sequences. Sequences are stored in an alist
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;;; of the form:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;;; ((seq-name msgs ...) (seq-name msgs ...) ...)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (defun mh-read-seq-default (prompt not-empty)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; Read and return sequence name with default narrowed or previous sequence.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (mh-read-seq prompt not-empty (or mh-narrowed-to-seq mh-last-seq-used)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (defun mh-read-seq (prompt not-empty &optional default)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; Read and return a sequence name. Prompt with PROMPT, raise an error
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; if the sequence is empty and the NOT-EMPTY flag is non-nil, and supply
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; an optional DEFAULT sequence.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; A reply of '%' defaults to the first sequence containing the current
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;; message.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (let* ((input (completing-read (format "%s %s %s" prompt "sequence:"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (if default
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (format "[%s] " default)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ""))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (mh-seq-names mh-seq-list)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (seq (cond ((equal input "%") (mh-msg-to-seq (mh-get-msg-num t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ((equal input "") default)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (t (intern input))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (msgs (mh-seq-to-msgs seq)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (if (and (null msgs) not-empty)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (error (format "No messages in sequence `%s'" seq)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (defun mh-msg-to-seq (msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ;; Given a MESSAGE number, return the first sequence in which it occurs.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (car (mh-seq-containing-msg msg)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (defun mh-seq-names (seq-list)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ;; Return an alist containing the names of the SEQUENCES.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (mapcar (function (lambda (entry) (list (symbol-name (mh-seq-name entry)))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 seq-list))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (defun mh-rename-seq (seq new-name)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 "Rename a SEQUENCE to have a new NAME."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (interactive (list (mh-read-seq "Old" t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (intern (read-string "New sequence name: "))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (let ((old-seq (mh-find-seq seq)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (or old-seq
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (error "Sequence %s does not exist" seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ;; create new seq first, since it might raise an error.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (mh-define-sequence new-name (mh-seq-msgs old-seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (mh-undefine-sequence seq (mh-seq-msgs old-seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (rplaca old-seq new-name)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (defun mh-map-to-seq-msgs (func seq &rest args)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;; Invoke the FUNCTION at each message in the SEQUENCE, passing the
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;; remaining ARGS as arguments.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (let ((msgs (mh-seq-to-msgs seq)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (while msgs
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (if (mh-goto-msg (car msgs) t t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (apply func (car msgs) args))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (setq msgs (cdr msgs))))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (defun mh-notate-seq (seq notation offset)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ;; Mark the scan listing of all messages in the SEQUENCE with the CHARACTER
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 ;; at the given OFFSET from the beginning of the listing line.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (mh-map-to-seq-msgs 'mh-notate seq notation offset))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (defun mh-add-to-sequence (seq msgs)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 ;; Add to a SEQUENCE each message the list of MSGS.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (if (not (mh-folder-name-p seq))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (if msgs
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (apply 'mh-exec-cmd "mark" mh-current-folder "-add"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 "-sequence" (symbol-name seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 msgs))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (defun mh-copy-seq-to-point (seq location)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 ;; Copy the scan listing of the messages in SEQUENCE to after the point
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 ;; LOCATION in the current buffer.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (mh-map-to-seq-msgs 'mh-copy-line-to-point seq location))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (defun mh-copy-line-to-point (msg location)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 ;; Copy the current line to the LOCATION in the current buffer.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (beginning-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (let ((beginning-of-line (point)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (forward-line 1)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (copy-region-as-kill beginning-of-line (point))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (goto-char location)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (yank)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (goto-char beginning-of-line)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222