]> diplodocus.org Git - nmh/blob - man/mh-sequence.man
fgets() reserves space for the NUL itself.
[nmh] / man / mh-sequence.man
1 .TH MH-SEQUENCE %manext5% "June 11, 2013" "%nmhversion%"
2 .\"
3 .\" %nmhwarning%
4 .\"
5 .SH NAME
6 mh-sequence \- sequence specification for nmh message system
7 .SH DESCRIPTION
8 A sequence (or sequence set) is a symbolic name representing a
9 message or collection of messages.
10 .B nmh
11 has several internally
12 defined sequences, as well as allowing users to define their own
13 sequences.
14 .SS "Message Specification and Pre\-Defined Message Sequences"
15 Most
16 .B nmh
17 commands accept a `msg' or `msgs' specification, where
18 `msg' indicates one message and `msgs' indicates one or more messages.
19 To designate a message, you may use either its number (e.g., 1, 10, 234)
20 or one of these \*(lqreserved\*(rq message names:
21 .PP
22 .RS 5
23 .PD 0
24 .TP
25 .B first
26 the first message in the folder
27 .TP
28 .B last
29 the last message in the folder
30 .TP
31 .B cur
32 the most recently accessed message
33 .TP
34 .B prev
35 the message numerically preceding \*(lqcur\*(rq
36 .TP
37 .B next
38 the message numerically following \*(lqcur\*(rq
39 .RE
40 .PD
41 .PP
42 In commands that take a `msg' argument, the default is \*(lqcur\*(rq.
43 As a shorthand, \*(lq\&.\*(rq is equivalent to \*(lqcur\*(rq.
44 .PP
45 For example: In a folder containing five messages numbered 5, 10, 94, 177
46 and 325, \*(lqfirst\*(rq is 5 and \*(lqlast\*(rq is 325. If \*(lqcur\*(rq
47 is 94, then \*(lqprev\*(rq is 10 and \*(lqnext\*(rq is 177.
48 .PP
49 The word `msgs' indicates that one or more messages may be specified.
50 Such a specification consists of one message designation or of several
51 message designations, as separate arguments. A message designation consists
52 either of a message name as defined above, or a message range.
53 .PP
54 A message range is specified as \*(lqname1\-name2\*(rq or
55 \*(lqname:n\*(rq, where `name', `name1' and `name2' are message names,
56 and `n' is an integer.
57 .PP
58 The specification \*(lqname1\-name2\*(rq designates all currently existing
59 messages from `name1' to `name2' inclusive. The \*(lqreserved\*(rq
60 message name \*(lqall\*(rq is a shorthand for the message range
61 \*(lqfirst\-last\*(rq.
62 .PP
63 The specification \*(lqname:n\*(rq designates up to `n' messages.
64 These messages start with `name' if `name' is a message number or one of
65 the reserved names \*(lqfirst\*(rq \*(lqcur\*(rq, or \*(lqnext\*(rq, The
66 messages end with `name' if `name' is \*(lqprev\*(rq or \*(lqlast\*(rq.
67 The interpretation of `n' may be overridden by preceding `n' with a
68 plus or minus sign; `+n' always means up to `n' messages starting with
69 `name', and `\-n' always means up to `n' messages ending with `name'.
70 .PP
71 Substituting `=' for `:' (i.e., \*(lqname=n\*(rq) will reduce the
72 selection from a range of up to `n' messages, to a selection of
73 just the `n'th message. So for example, while \*(lqname:-3\*(rq
74 selects the 3 messages ending with `name', \*(lqname=-3\*(rq selects
75 just the 2nd previous message. It is an error if the requested
76 message does not exist (i.e., there aren't enough messages in the
77 folder).
78 .PP
79 In commands which accept a `msgs' argument, the default is either
80 \*(lqcur\*(rq or \*(lqall\*(rq, depending on which makes more sense
81 for each command (see the individual man pages for details). Repeated
82 specifications of the same message have the same effect as a single
83 specification of the message.
84 .PP
85 There is also a special \*(lqreserved\*(rq message name \*(lqnew\*(rq
86 which is used by the
87 .B mhpath
88 command.
89 .SS "User\-Defined Message Sequences"
90 In addition to the \*(lqreserved\*(rq (pre-defined) message names given
91 above,
92 .B nmh
93 supports user-defined sequence names. User-defined
94 sequences allow the
95 .B nmh
96 user a tremendous amount of power in dealing
97 with groups of messages in the same folder by allowing the user to bind
98 a group of messages to a meaningful symbolic name.
99 .PP
100 The name used to denote a message sequence must consist of an alphabetic
101 character followed by zero or more alphanumeric characters, and can not
102 be one of the \*(lqreserved\*(rq message names above. After defining a
103 sequence, it can be used wherever an
104 .B nmh
105 command expects a `msg' or
106 `msgs' argument.
107 .PP
108 Some forms of message ranges are allowed with user-defined sequences.
109 The specification \*(lqname:n\*(rq may be used, and it designates up
110 to the first `n' messages (or last `n' messages for `\-n') which are
111 elements of the user-defined sequence `name'.
112 .PP
113 The specifications \*(lqname:next\*(rq and \*(lqname:prev\*(rq may also
114 be used, and they designate the next or previous message (relative to the
115 current message) which is an element of the user-defined sequence `name'.
116 The specifications \*(lqname:first\*(rq and \*(lqname:last\*(rq are
117 equivalent to \*(lqname:1\*(rq and \*(lqname:\-1\*(rq, respectively. The
118 specification \*(lqname:cur\*(rq is not allowed (use just \*(lqcur\*(rq
119 instead). The syntax of these message range specifications is subject
120 to change in the future.
121 .PP
122 Single messages (as opposed to ranges) may also be selected by
123 substituting `=' for `:', as in \*(lqname=n\*(rq. This will reduce
124 the selection from being a range of up to `n' messages, to being a
125 selection of just the `n'th message. So while \*(lqseq:5\*(rq
126 selects the first 5 messages of seqence `seq', \*(lqseq=5\*(rq
127 selects just the 5th message of the sequence. It is
128 an error if the requested message does not exist (i.e., there aren't
129 at least `n' messages in the sequence).
130 .PP
131 User-defined sequence names are specific to each folder. They are
132 defined using the
133 .B pick
134 and
135 .B mark
136 commands.
137 .PP
138 .SS "Public and Private User-Defined Sequences"
139 There are two varieties of user-defined sequences:
140 public and private. Public sequences of a folder are accessible to any
141 .B nmh
142 user that can read that folder. They are kept in each folder
143 in the file determined by the \*(lqmh\-sequences\*(rq profile entry
144 (default is
145 .IR \&.mh\(rusequences ).
146 Private sequences are accessible
147 only to the
148 .B nmh
149 user that defined those sequences and are kept in
150 the user's
151 .B nmh
152 context file.
153 .PP
154 In general, the commands that create sequences (such as
155 .B pick
156 and
157 .BR mark )
158 will create public sequences if the folder for which
159 the sequences are being defined is writable by the
160 .B nmh
161 user.
162 For most commands, this can be overridden by using the switches
163 .B \-public
164 and
165 .BR \-private .
166 But if the folder is read\-only, or if
167 the \*(lqmh\-sequences\*(rq profile entry is defined but empty, then
168 \fIprivate\fR sequences will be created instead.
169 .SS "Sequence Negation"
170 .B Nmh
171 provides the ability to select all messages not elements of a
172 user-defined sequence. To do this, the user should define the entry
173 \*(lqSequence\-Negation\*(rq in the
174 .B nmh
175 profile file; its value
176 may be any string. This string is then used to preface an existing
177 user-defined sequence name. This specification then refers to those
178 messages not elements of the specified sequence name. For example, if
179 the profile entry is:
180 .PP
181 .RS 5
182 Sequence\-Negation: not
183 .RE
184 .PP
185 then anytime an
186 .B nmh
187 command is given \*(lqnotfoo\*(rq as a `msg' or
188 `msgs' argument, it would substitute all messages that are not elements
189 of the sequence \*(lqfoo\*(rq.
190 .PP
191 Obviously, the user should beware of defining sequences with names that
192 begin with the value of the \*(lqSequence\-Negation\*(rq profile entry.
193 .SS "The Previous Sequence"
194 .B Nmh
195 provides the ability to remember the `msgs' or `msg' argument
196 last given to an
197 .B nmh
198 command. The entry \*(lqPrevious\-Sequence\*(rq
199 should be defined in the
200 .B nmh
201 profile; its value should be a sequence
202 name or multiple sequence names, as separate arguments. If this entry
203 is defined, when when an
204 .B nmh
205 command finishes, it will define the
206 sequence(s) named in the value of this entry to be those messages that
207 were specified to the command. Hence, a profile entry of
208 .PP
209 .RS 5
210 Previous\-Sequence: pseq
211 .RE
212 .PP
213 directs any
214 .B nmh
215 command that accepts a `msg' or `msgs' argument to
216 define the sequence \*(lqpseq\*(rq as those messages when it finishes.
217 .PP
218 .BR Note :
219 there can be a performance penalty in using the
220 \*(lqPrevious\-Sequence\*(rq facility. If it is used,
221 .B all
222 .B nmh
223 programs have to write the sequence information to the
224 .I \&.mh\(rusequences
225 file for the folder each time they run. If the
226 \*(lqPrevious\-Sequence\*(rq profile entry is not included, only
227 .B pick
228 and
229 .B mark
230 will write to the
231 .B \&.mh\(rusequences
232 file.
233 .SS "The Unseen Sequence"
234 Finally, many users like to indicate which messages have not been
235 previously seen by them. The commands
236 .BR inc ,
237 .BR rcvstore ,
238 .BR show ,
239 .BR mhshow ,
240 and
241 .B flist
242 honor the profile entry
243 \*(lqUnseen\-Sequence\*(rq to support this activity. This entry
244 in the
245 .I \&.mh\(ruprofile
246 should be defined as one or more sequence
247 names, as separate arguments. If there is a value for
248 \*(lqUnseen\-Sequence\*(rq in the profile, then whenever new messages
249 are placed in a folder (using
250 .B inc
251 or
252 .BR rcvstore ),
253 the new messages will also be added to all the sequences named in this
254 profile entry. For example, a profile entry of
255 .PP
256 .RS 5
257 Unseen\-Sequence: unseen
258 .RE
259 .PP
260 directs
261 .B inc
262 to add new messages to the sequence \*(lqunseen\*(rq.
263 Unlike the behavior of the \*(lqPrevious\-Sequence\*(rq entry in the
264 profile, however, the sequence(s) will
265 .B not
266 be zeroed by
267 .BR inc .
268 .PP
269 Similarly, whenever
270 .BR show ,
271 .BR mhshow ,
272 .BR next ,
273 or
274 .B prev
275 displays a message, that message will be removed from
276 any sequences named by the \*(lqUnseen\-Sequence\*(rq entry in the
277 profile.
278 .SS Sequence File Format
279 The sequence file format is based on the RFC\-5322 message format. Each line
280 of the sequence file corresponds to one sequence. The line starts with the
281 sequence name followed by a `:', then followed by a space-separated list of message numbers
282 that correspond to messages that are part of the named sequence. A contiguous
283 range of messages can be represented as \*(lqlownum\-highnum\*(rq.
284 .PP
285 .B Sample sequence file
286 .PP
287 .RS 5
288 .nf
289 work: 3 6 8 22-33 46
290 unseen: 47 49-51 54
291 cur: 46
292 .fi
293 .RE
294 .PP
295 .B Nmh
296 commands that modify the sequence file will silently remove sequences for
297 nonexistent messages when the sequence file is updated. The exception to
298 this is the \*(lqcur\*(rq sequence, which is allowed to point to a
299 nonexistent message.
300 .SS Sequence File Locking
301 The \*(lqdatalocking\*(rq profile entry controls the type of locking used
302 when reading and writing sequence files. The locking mechanisms supported
303 are detailed in
304 .IR mh\-profile (5).
305 This protects sequence file integrity when multiple
306 .B nmh
307 commands are run simultaneously.
308 .B Nmh
309 commands that modify the sequence file use transactional locks; the lock
310 is held from the time the sequence file is read until it it written out.
311 This ensures that modifications to the sequence file will not be lost
312 if multiple commands are run simultaneously. Long\-running
313 .B nmh
314 commands, such as
315 .B inc
316 and
317 .BR pick ,
318 will release the sequence lock during the bulk of their runtime and reread
319 the sequence file after their processing is complete to reduce lock
320 contention time.
321 .PP
322 .B Note:
323 Currently transactional locks are
324 .B only
325 supported for public sequences; private sequences will not get corrupted, but
326 the possibility exists that two
327 .B nmh
328 commands run simultaneously that add messages to a private sequence could result in
329 one command's messages not appearing on the requested sequence.
330 .SH FILES
331 .PD 0
332 .TP 20
333 $HOME/\&.mh\-profile
334 The user's profile.
335 .TP 20
336 <mh\-dir>/context
337 The user's context.
338 .TP 20
339 <folder>/\&.mh\-sequences
340 File for public sequences.
341 .PD
342 .SH "PROFILE COMPONENTS"
343 .PD 0
344 .TP 20
345 mh-sequences:
346 Name of file to store public sequences.
347 .TP 20
348 Sequence\-Negation:
349 To designate messages not in a sequence.
350 .TP 20
351 Previous\-Sequence:
352 The last message specification given.
353 .TP 20
354 Unseen\-Sequence:
355 Those messages not yet seen by the user.
356 .PD
357 .SH "SEE ALSO"
358 .IR flist (1),
359 .IR mark (1),
360 .IR pick (1),
361 .IR mh-profile (5)
362 .SH DEFAULTS
363 None