annotate lisp/mail/rmaildesc.el @ 88265:defd9948075b

(rmail-highlight-face): Doc. (rmail-font-lock-keywords): Add the stuff necessary to make rmail-highlight-headers obsolete. (rmail-toggle-header, rmail-show-message): Don't call rmail-highlight-headers anymore. (rmail-highlight-headers): Deleted.
author Alex Schroeder <alex@gnu.org>
date Sat, 21 Jan 2006 18:21:07 +0000
parents e03b9b63e187
children 8ca01eaf0be8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
1 ;;; rmaildesc.el --- Low level message descriptor library for Rmail.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
2
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
3 ;; Copyright (C) 2002, 2006 Free Software Foundation, Inc.
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
4
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
5 ;; Maintainer: FSF
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
6 ;; Keywords: mail
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
7
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
9
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
13 ;; any later version.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
14
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
19
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
24
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
25 ;;; Commentary:
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
26
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
27 ;;; This package provides low level functions for tracking messages in Rmail.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
28
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
29 ;;; Code:
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
30
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
31 (defvar rmail-desc-attributes nil
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
32 "A private variable providing temporary access to message attributes.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
33
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
34 (defvar rmail-desc-delete-callback nil
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
35 "A function pointer called after a message has been deleted.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
36 It expects one argument --- the message number.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
37
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
38 (defvar rmail-desc-vector nil
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
39 "A vector of message descriptors.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
40 A message descriptor contains data formatted as follows:
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
41
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
42 (START ATTRIBUTES KEYWORDS DATE LINE-COUNT SENDER SUBJECT)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
43
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
44 where
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
45
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
46 START is a marker at the beginning of the header
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
47
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
48 ATTRIBUTES is a string where each character encodes an
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
49 attribute. A hyphen (-) indicates that the attribute is not
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
50 set:
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
51
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
52 ANSWERED The message has been replied to (A).
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
53 DELETED The message has been marked for deletion (D).
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
54 EDITED The message has been edited (E).
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
55 FILED The message has been filed (F).
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
56 RESENT The message has been resent (R).
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
57 STORED The message has been saved to a file (S).
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
58 UNSEEN The message has not been read (-).
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
59
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
60 KEYWORDS is a list of User defined label strings.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
61
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
62 DATE is a list of strings describing the message date:
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
63
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
64 DAY-OF-WEEK Mon, Sun, etc.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
65 DAY-NUMBER 9, 13, 15, etc.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
66 MONTH Feb, Jun, etc.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
67 YEAR 2001, 2002, etc.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
68 TIME 12:03:25, etc.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
69
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
70 LINE-COUNT is the number of lines in the message.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
71
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
72 SENDER is the name of the User sending the message.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
73
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
74 SUBJECT is the subject header, cached to support fast summary line generation.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
75 ")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
76 (put 'rmail-desc-vector 'permanent-local t)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
77
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
78 ;;;; Constants supporting message vector processing.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
79
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
80 ;;; Message component indexes.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
81
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
82 (defconst rmail-desc-beg-index 0
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
83 "The message descriptor element index for the start of the message text.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
84
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
85 (defconst rmail-desc-attrs-index 1
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
86 "The message descriptor element index for the attributes string.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
87
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
88 (defconst rmail-desc-keywords-index 2
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
89 "The message descriptor element index for the User defined labels.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
90
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
91 (defconst rmail-desc-date-index 3
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
92 "The message descriptor element index for the message date information.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
93
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
94 (defconst rmail-desc-line-count-index 4
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
95 "The message descriptor element index for the message line count.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
96
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
97 (defconst rmail-desc-sender-index 5
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
98 "The message descriptor element index for the message line count.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
99
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
100 (defconst rmail-desc-subject-index 6
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
101 "The message descriptor element index for the message line count.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
102
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
103 ;;; Attribute indexes
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
104
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
105 (defconst rmail-desc-answered-index 0
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
106 "The index for the `answered' attribute.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
107
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
108 (defconst rmail-desc-deleted-index 1
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
109 "The index for the `deleted' attribute.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
110
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
111 (defconst rmail-desc-edited-index 2
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
112 "The index for the `edited' attribute.")
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
113
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
114 (defconst rmail-desc-filed-index 3
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
115 "The index for the `filed' attribute.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
116
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
117 (defconst rmail-desc-resent-index 4
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
118 "The index for the `resent' attribute.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
119
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
120 (defconst rmail-desc-stored-index 5
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
121 "The index for the `stored' attribute.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
122
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
123 (defconst rmail-desc-unseen-index 6
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
124 "The index for the `unseen' attribute.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
125
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
126 (defconst rmail-desc-attr-code-index 0
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
127 "The index for the attibute code.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
128
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
129 (defconst rmail-desc-attr-keyword-index 1
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
130 "The index for the attribute keyword.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
131
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
132 (defconst rmail-desc-attr-summary-offset-index 2
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
133 "The index for the attribute offset in a summary buffer.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
134
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
135 (defconst rmail-desc-attr-alist
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
136 (list (cons rmail-desc-answered-index (list ?A "answered" 1))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
137 (cons rmail-desc-deleted-index (list ?D "deleted" 0))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
138 (cons rmail-desc-edited-index (list ?E "edited" 3))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
139 (cons rmail-desc-filed-index (list ?F "filed" 2))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
140 (cons rmail-desc-resent-index (list ?R "resent" nil))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
141 (cons rmail-desc-stored-index (list ?S "stored" 4))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
142 (cons rmail-desc-unseen-index (list ? "unseen" 0)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
143 "An alist mapping an attribute to a keycode, keyword and summary offset.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
144
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
145 (defconst rmail-desc-attr-index-map
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
146 (list (cons "answered" rmail-desc-answered-index)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
147 (cons "deleted" rmail-desc-deleted-index)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
148 (cons "edited" rmail-desc-edited-index)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
149 (cons "filed" rmail-desc-filed-index)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
150 (cons "resent" rmail-desc-resent-index)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
151 (cons "stored" rmail-desc-stored-index)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
152 (cons "unseen" rmail-desc-unseen-index)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
153
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
154 ;;; Date indexes
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
155
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
156 (defconst rmail-desc-date-day-of-week-index 0
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
157 "The DAY-OF-WEEK index into the list of date information.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
158
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
159 (defconst rmail-desc-date-day-number-index 1
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
160 "The DAY-NUMBER index into the list of date information.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
161
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
162 (defconst rmail-desc-date-month-index 2
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
163 "The MONTH index into the list of date information.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
164
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
165 (defconst rmail-desc-date-year-index 3
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
166 "The YEAR index into the list of date information.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
167
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
168 (defconst rmail-desc-date-time-index 4
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
169 "The TIME index into the list of date information.")
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
170
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
171 (defsubst rmail-desc-get-descriptor (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
172 "Return a descriptor for message N.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
173 N is 1 based, i.e. the first message number is 1."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
174 (aref rmail-desc-vector (1- n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
175
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
176 (defsubst rmail-desc-get-start (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
177 "Return the position of the start of message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
178 (marker-position
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
179 (nth rmail-desc-beg-index (rmail-desc-get-descriptor n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
180
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
181 (defun rmail-desc-get-end (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
182 "Return the position of the end of message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
183 (if (= n (length rmail-desc-vector))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
184 (save-restriction
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
185 (widen)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
186 (point-max))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
187 (rmail-desc-get-start (1+ n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
188
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
189 (defun rmail-desc-add-descriptors (descriptor-list)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
190 "Append DESCRIPTOR-LIST to the Rmail message descriptor vector."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
191 (setq rmail-desc-vector
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
192 (vconcat rmail-desc-vector descriptor-list)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
193
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
194 (defun rmail-desc-add-keyword (keyword n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
195 "Add KEYWORD to the list of keywords for message N.
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
196 The current buffer must be narrowed to message N. Both
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
197 `rmail-desc-vector' and the message headers are updated."
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
198 (save-excursion
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
199 (save-restriction
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
200 (let ((keywords (rmail-desc-get-keywords n))
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
201 (display-state (rmail-desc-get-header-display-state n)))
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
202 (unless (member keyword keywords)
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
203 (setq keywords (cons keyword keywords))
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
204 (setcar (nthcdr rmail-desc-keywords-index (rmail-desc-get-descriptor n))
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
205 keywords)
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
206 (rmail-header-show-headers)
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
207 (rmail-header-add-header rmail-header-keyword-header
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
208 (mapconcat 'identity keywords ","))
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
209 (rmail-header-toggle-visibility display-state))))))
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
210
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
211 (defun rmail-desc-remove-keyword (keyword n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
212 "Remove KEYWORD from the list of keywords for message N.
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
213 The current buffer must be narrowed to message N. Both
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
214 `rmail-desc-vector' and the message headers are updated."
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
215 (save-excursion
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
216 (save-restriction
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
217 (let ((keywords (rmail-desc-get-keywords n))
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
218 (display-state (rmail-desc-get-header-display-state n)))
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
219 (when (member keyword keywords)
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
220 (setq keywords (delete keyword keywords))
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
221 (setcar (nthcdr rmail-desc-keywords-index (rmail-desc-get-descriptor n))
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
222 keywords)
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
223 (rmail-header-show-headers)
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
224 (rmail-header-add-header rmail-header-keyword-header
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
225 (mapconcat 'identity keywords ","))
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
226 (rmail-header-toggle-visibility display-state))))))
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
227
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
228 (defun rmail-desc-attr-p (attr-index n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
229 "Return the state of the the attribute denoted by ATTR-INDEX in
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
230 message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
231 (let ((attrs (nth rmail-desc-attrs-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
232 (rmail-desc-get-descriptor n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
233 (not (equal "-" (substring attrs attr-index (1+ attr-index))))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
234
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
235 (defun rmail-desc-clear-descriptors ()
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
236 "Clear the Rmail message vector of all messages."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
237 (setq rmail-desc-vector nil))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
238
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
239 (defun rmail-desc-deleted-p (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
240 "Return non-nil if message N is marked for deletion."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
241 (rmail-desc-attr-p rmail-desc-deleted-index n))
88149
1cb8cab175ad (rmail-message-deleted-p): Add as alias.
Richard M. Stallman <rms@gnu.org>
parents: 88124
diff changeset
242 (defalias 'rmail-message-deleted-p 'rmail-desc-deleted-p)
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
243
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
244 (defun rmail-desc-delete-maybe (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
245 "Determine if message N is marked for deletion. If so then delete it.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
246 Return t if the message is deleted, nil if not."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
247 (if (rmail-desc-deleted-p n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
248 (progn
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
249 (rmail-desc-delete n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
250 t)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
251
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
252 (defun rmail-desc-delete (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
253 "Remove message N from the Rmail buffer and from the descriptor vector."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
254 (save-excursion
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
255 (save-restriction
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
256 ;; Enable the buffer to be written, ignore intangibility and do
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
257 ;; not record these changes in the undo list.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
258 (let ((inhibit-read-only t)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
259 (inhibit-point-motion-hooks t)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
260 (buffer-undo-list t)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
261 start end)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
262 (widen)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
263
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
264 ;; Remove the message from the buffer and neutralize the
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
265 ;; marker pointing to the start of the message.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
266 (delete-region (rmail-desc-get-start n) (rmail-desc-get-end n))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
267 (move-marker (nth rmail-desc-beg-index (rmail-desc-get-descriptor n)) nil)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
268
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
269 ;; Remove the message descriptor from the Rmail message vector
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
270 ;; and execute the callback indicating the message has been
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
271 ;; deleted.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
272 (aset rmail-desc-vector (1- n) t)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
273 (funcall rmail-desc-delete-callback n)))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
274
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
275 (defun rmail-desc-get-attr-code (attr-index n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
276 "Return the attribute code for ATTR-INDEX in message N.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
277 If the attribute is not set, return nil."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
278 (if (rmail-desc-attr-p attr-index n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
279 (string (nth rmail-desc-attr-code-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
280 (cdr (assoc attr-index rmail-desc-attr-alist))))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
281
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
282 (defun rmail-desc-get-attr-index (attr)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
283 "Return the attribute index associated with attribute ATTR, a string."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
284 (cdr (assoc attr rmail-desc-attr-index-map)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
285
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
286 (defun rmail-desc-get-attributes (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
287 "Return the attribute vector for message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
288 (nth rmail-desc-attrs-index (rmail-desc-get-descriptor n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
289
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
290 (defsubst rmail-desc-get-count ()
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
291 "Return the number of messages described in the Rmail descriptor vector."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
292 (length rmail-desc-vector))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
293
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
294 (defun rmail-desc-get-date (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
295 "Return the date list generated when the messages were read in."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
296 (nth rmail-desc-date-index (rmail-desc-get-descriptor n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
297
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
298 (defun rmail-desc-get-day-number (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
299 "Return the day number (1..31) from the date associated with message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
300 (nth rmail-desc-date-day-number-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
301 (nth rmail-desc-date-index (rmail-desc-get-descriptor n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
302
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
303 (defun rmail-desc-get-day-of-week (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
304 "Return the day of week (Sun .. Sat) from the date associated with message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
305 (nth rmail-desc-date-day-of-week-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
306 (nth rmail-desc-date-index (rmail-desc-get-descriptor n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
307
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
308 (defun rmail-desc-get-default-attrs ()
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
309 "Return the default attributes for a new message."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
310 (format "%s" "------U"))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
311
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
312 (defun rmail-desc-get-header-display-state (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
313 "Return t if ignorable headers are being displayed, nil otherwise."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
314 (null (overlays-at (rmail-desc-get-start n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
315
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
316 (defun rmail-desc-get-keyword (attr-index)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
317 "Return the keyword string associated with ATTR-INDEX."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
318 (nth rmail-desc-attr-keyword-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
319 (cdr (assoc attr-index rmail-desc-attr-alist))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
320
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
321 (defun rmail-desc-get-keyword-list (n)
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
322 "Return the list of user-defined labels for message N."
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
323 (nth rmail-desc-keywords-index (rmail-desc-get-descriptor n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
324
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
325 (defun rmail-desc-get-keyword-maybe (attribute)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
326 "Return the keyword associated with ATTRIBUTE if it is set, nil otherwise.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
327 ATTRIBUTE is a cons cell associating an attribute index with a keyword string."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
328 (let ((index (car attribute)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
329 (if (not (equal "-" (substring rmail-desc-attributes index (1+ index))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
330 (nth rmail-desc-attr-keyword-index (cdr attribute)))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
331
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
332 (defun rmail-desc-get-keywords (n)
88213
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
333 "Return a list of keywords for message N.
8b5a826d67e4 Removed require statements.
Alex Schroeder <alex@gnu.org>
parents: 88149
diff changeset
334 This includes the attributes."
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
335 (setq rmail-desc-attributes (rmail-desc-get-attributes n))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
336 (append (delq nil (mapcar
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
337 'rmail-desc-get-keyword-maybe
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
338 rmail-desc-attr-alist))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
339 (rmail-desc-get-keyword-list n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
340
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
341 (defun rmail-desc-get-line-count (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
342 "Return the message body line count."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
343 (nth rmail-desc-line-count-index (rmail-desc-get-descriptor n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
344
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
345 (defun rmail-desc-get-month (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
346 "Return the month (Jan .. Dec) from the date associated with message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
347 (nth rmail-desc-date-month-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
348 (nth rmail-desc-date-index (rmail-desc-get-descriptor n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
349
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
350 (defun rmail-desc-get-sender (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
351 "Return the User registered as the mail sender."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
352 (nth rmail-desc-sender-index (rmail-desc-get-descriptor n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
353
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
354 (defun rmail-desc-get-subject (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
355 "Return the cached subject header."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
356 (nth rmail-desc-subject-index (rmail-desc-get-descriptor n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
357
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
358 (defun rmail-desc-get-summary-offset (attr-index)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
359 "Return the summary buffer offset associated with ATTR-INDEX.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
360 This is the relative position where the attribute code letter is
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
361 displayed in the Rmail summary buffer."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
362 (nth rmail-desc-attr-summary-offset-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
363 (cdr (assoc attr-index rmail-desc-attr-alist))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
364
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
365 (defun rmail-desc-get-time (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
366 "Return the time (hh:mm:ss) from the date associated with message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
367 (nth rmail-desc-date-time-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
368 (nth rmail-desc-date-index (rmail-desc-get-descriptor n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
369
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
370 (defun rmail-desc-get-year (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
371 "Return the year (1969 ... 2###) from the date associated with message N."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
372 (nth rmail-desc-date-year-index
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
373 (nth rmail-desc-date-index (rmail-desc-get-descriptor n))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
374
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
375 ;; This is a strange thing to use.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
376 ;; Why not write a simple loop instead?
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
377 (defun rmail-desc-make-index-list ()
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
378 "Return a list of integers from 1 to the total number of messages."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
379 (let ((result (make-vector (length rmail-desc-vector) nil))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
380 (index 0))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
381 (while (< index (length result))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
382 (aset result index (1+ index))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
383 (setq index (1+ index)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
384 (append result nil)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
385
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
386 (defun rmail-desc-prune-deleted-messages (callback)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
387 "Remove all messages marked for marked for deletion.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
388 Return the number of messages removed. Invoke CALLBACK immediately
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
389 after a message has been deleted.."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
390
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
391 ;; Set the callback.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
392 (setq rmail-desc-delete-callback callback)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
393
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
394 ;; Remove all messages marked for deletion from the Rmail buffer and
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
395 ;; their descriptors from the Rmail message vector.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
396 (let ((result (length (delq t (mapcar 'rmail-desc-delete-maybe
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
397 (rmail-desc-make-index-list))))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
398 (setq rmail-desc-vector
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
399 (vconcat (delq t (append rmail-desc-vector nil))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
400 result))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
401
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
402 (defun rmail-desc-set-attribute (attr-index state n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
403 "Set the attribute denoted by ATTR-INDEX in message N according to STATE.
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
404 If STATE is non-nil the attribute will be set to the single character code
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
405 associated with ATTR-INDEX in rmail-desc-attr-alist, otherwise the attribute is
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
406 set to the hyphen character (-)."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
407 (let ((attributes (nth rmail-desc-attrs-index (rmail-desc-get-descriptor n)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
408 code)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
409 (setq code (if state
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
410 (car (cdr (assoc attr-index rmail-desc-attr-alist)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
411 ?-))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
412 (aset attributes attr-index code)
88258
e03b9b63e187 (rmail-desc-set-attribute): Use
Alex Schroeder <alex@gnu.org>
parents: 88213
diff changeset
413 (rmail-header-add-header rmail-header-attribute-header attributes)))
88124
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
414
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
415 (defun rmail-desc-set-start (n pos)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
416 "Set the start position for message N to POS."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
417 (set-marker (nth rmail-desc-beg-index (rmail-desc-get-descriptor n)) pos))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
418
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
419 (defun rmail-desc-showing-message-p (n)
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
420 "Return t if the current buffer is displaying message N, nil otherwise."
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
421 (let ((beg (rmail-desc-get-start n))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
422 (end (rmail-desc-get-end n))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
423 (curpos (point)))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
424 (and (>= curpos beg) (< curpos end))))
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
425
30235d819e60 Mbox format support. Initial commit.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
426 (provide 'rmaildesc)