remove unused defines in uip/pick.c
[mmh] / man / pick.man1
1 .\"
2 .\" %nmhwarning%
3 .\"
4 .TH PICK %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
5 .SH NAME
6 pick \- select messages by content
7 scan \- produce a one line per message scan listing
8 .SH SYNOPSIS
9 .HP 5
10 .na
11 .B pick
12 .RI [ +folder ]
13 .RI [ msgs ]
14 .RB [ \-and
15 \&...]
16 .RB [ \-or
17 \&...]
18 .RB [ \-not
19 \&...]
20 .RB [ \-lbrace
21 \&...
22 .BR \-rbrace ]
23 .RB [ \-\|\-component
24 .IR pattern ]
25 .RB [ \-cc
26 .IR pattern ]
27 .RB [ \-date
28 .IR pattern ]
29 .RB [ \-from
30 .IR pattern ]
31 .RB [ \-search
32 .IR pattern ]
33 .RB [ \-subject
34 .IR pattern ]
35 .RB [ \-to
36 .IR pattern ]
37 .RB [ \-after
38 .IR date ]
39 .RB [ \-before
40 .IR date ]
41 .RB [ \-datefield
42 .IR field ]
43 .RB [ \-format
44 .IR formatfile ]
45 .RB [ \-width
46 .IR columns ]
47 .RB [ \-thread
48 .RI [ +folder ] messages "|" files ]
49 .RB [ \-file
50 .IR mboxfilename ]
51 .RB [ \-sequence
52 .I name
53 \&...]
54 .RB [ \-public " | " \-nopublic ]
55 .RB [ \-zero " | " \-nozero ]
56 .RB [ \-list " | " \-nolist ]
57 .RB [ \-Version ]
58 .RB [ \-help ]
59 .PP
60 .HP 5
61 .B scan
62 is equivalent to
63 .B pick -format scan.default
64 .ad
65 .PP
66 typical usage:
67 .PP
68 .RS 5
69 .nf
70 scan\0\-from\0jones`
71 pick\0\-to\0holloway\0\-sequence\0select
72 show\0`pick\0\-before\0friday`
73 .fi
74 .RE
75 .ad
76 .SH DESCRIPTION
77 .B Pick
78 searches within a folder for messages with the specified
79 contents, and then identifies those messages.  Two types of search
80 primitives are available: pattern matching and date constraint
81 operations.
82 .PP
83 The default
84 .BR regex (7)
85 is used to perform the matching, so the
86 full regular expression facility is available
87 within
88 .IR pattern.
89 With
90 .BR \-search ,
91 .I pattern
92 is used directly, but only for the body of the Mail.
93 With the others,
94 .B pick
95 compares the header field name case insensitive
96 and the tries to match the field body with the
97 .IR pattern.
98 .PP
99 With
100 .BR --componend
101 you can specify the exact header field name you are looking for.
102 It is used to pick a component which is not one of `To:',
103 `Cc:', `Date:', `From:', or `Subject:'.
104 An example is
105 .RB ` "pick\0\-\|\-reply\-to\0pooh" '.
106 .PP
107 Pattern matching is performed on a per\-header-field basis. Within the header
108 of the message, each field is treated as one long line, but in the
109 body, each line is separate.  The
110 .IR pattern
111 will match any case.
112 .PP
113 Note that since the
114 .B \-date
115 switch is a pattern matching operation (as
116 described above), to find messages sent on a certain date the pattern
117 string must match the text of the `Date:' field of the message.
118 .PP
119 Independent of any pattern matching operations requested, the switches
120 .B \-after
121 .I date
122 or
123 .B \-before
124 .I date
125 may also be used to introduce date/time
126 constraints on all of the messages.  By default, the `Date:'
127 field is consulted, but if another date yielding field (such as
128 `BB\-Posted:' or `Delivery\-Date:') should be used, the
129 .B \-datefield
130 .I field
131 switch may be used.
132 .PP
133 With
134 .B \-before
135 and
136 .BR \-after ,
137 .B pick
138 will actually parse the date
139 fields in each of the messages specified in `msgs' and compare them
140 to the date/time specified.  If
141 .B \-after
142 is given, then only those
143 messages whose `Date:' field value is chronologically after the
144 date specified will be considered.  The
145 .B \-before
146 switch specifies the
147 complimentary action.
148 .PP
149 Both the
150 .B \-after
151 and
152 .B \-before
153 switches take legal 822\-style date
154 specifications as arguments.
155 .B Pick
156 will default certain missing
157 fields so that the entire date need not be specified.  These fields
158 are (in order of defaulting): timezone, time and timezone, date, date
159 and timezone.  All defaults are taken from the current date, time,
160 and timezone.
161 .PP
162 In addition to 822\-style dates,
163 .B pick
164 will also recognize any of
165 the days of the week (`sunday', `monday', and so on),
166 and the special dates `today', `yesterday' (24 hours
167 ago), and `tomorrow' (24 hours from now).  All days of the
168 week are judged to refer to a day in the past (e.g., telling \fIpick\fR
169 `saturday' on a `tuesday' means `last\ saturday'
170 not `this\ saturday').
171 Further more, dates in a simplified ISO 8601/RFC 3339 style (e.g.
172 `YYYY-MM-DD' or `YYYY-MM-DD hh:mm:ss') are accepted.
173 Finally, in addition to these special specifications,
174 .B pick
175 will
176 also honor a date specification of the form `\-\fIddd\fR', which means
177 `\fIddd\fR days ago'.
178 For example,
179 .PP
180 .RS 5
181 .nf
182 pick\0\-after\0\-30
183 .fi
184 .RE
185 .PP
186 identifies the messages of the last thirty days.
187 .PP
188 .B Pick
189 supports complex boolean operations on the searching primitives
190 with the
191 .BR \-and ,
192 .BR \-or ,
193 .BR \-not ,
194 and
195 .B \-lbrace
196 .B \&...
197 .B \-rbrace
198 switches.
199 For example,
200 .PP
201 .RS 5
202 .nf
203 pick\0\-after\0yesterday\0\-and
204      \-lbrace\0\-from\0freida\0\-or\0\-from\0fear\0\-rbrace
205 .fi
206 .RE
207 .PP
208 identifies messages recently sent by `frieda' or `fear'.
209 .PP
210 The matching primitives take precedence over the
211 .B \-not
212 switch, which in turn takes precedence over
213 .B \-and
214 which in turn takes precedence
215 over
216 .BR \-or .
217 To override the default precedence, the
218 .B \-lbrace
219 and
220 .B \-rbrace
221 switches are provided, which act just like opening and closing
222 parentheses in logical expressions.
223 .PP
224 If no search criteria are given, all the messages specified on the
225 command line are selected (this defaults to `a').
226 .PP
227 Once the search has been performed, if the
228 .B \-list
229 switch is given, the
230 message numbers of the selected messages are written to the standard
231 output separated by newlines.  This is
232 .B extremely
233 useful for
234 quickly generating arguments for other
235 .B mmh
236 programs by using the
237 `backquoting' syntax of the shell.  For example, the command
238 .PP
239 .RS 5
240 show\0`pick\0+todo\0\-after\0`31 Mar 83 0123 PST'`
241 .RE
242 .PP
243 says to
244 .B show
245 those messages in the indicated folder which meet the
246 appropriate criterion.  Note that since
247 .BR pick 's
248 context changes
249 are written out prior to
250 .BR show 's
251 invocation, you need not give
252 the folder argument to
253 .B show
254 as well.
255 .PP
256 The
257 .B \-sequence
258 .I name
259 switch may be given once for each sequence the user wishes to define.
260 For each sequence named, that sequence will be defined to mean exactly
261 those messages selected by
262 .BR pick .
263 For example,
264 .PP
265 .RS 5
266 pick\0\-from\0frated\0\-seq\0fred
267 .RE
268 .PP
269 defines a new message sequence for the current folder called
270 `fred' which contains exactly those messages that were selected.
271 .PP
272 By default,
273 .B pick
274 will zero the sequence before adding it.  This
275 action can be disabled with the
276 .B \-nozero
277 switch, which means that the
278 messages selected by
279 .B pick
280 will be added to the sequence, if it
281 already exists, and any messages already a part of that sequence will
282 remain so.
283 .PP
284 The
285 .B \-public
286 and
287 .B \-nopublic
288 switches are used by
289 .B pick
290 in the
291 same way
292 .B mark
293 uses them.
294
295 .B Scan
296 and
297 .B pick
298 produces a one\-line\-per\-message listing of the specified and selected
299 folder or messages.
300 The default format is for
301 .B pick
302 is to print the message number for each message.
303 The default
304 .B Scan
305 line contains the message number
306 (name), the date, the `From:' field and the `Subject' field.
307 The following example shows the default output of
308 .B scan
309 .PP
310 .RS 5
311 .nf
312 .ta \w'15+- 'u +\w'07/\|05x 'u +\w'Dcrocker  'u
313 15+     10/\|05 crocker nned
314 16\-    10/\|05 crocker message id format
315 18      10/\|06 brien   Re: Exit status from mkdir
316 19      10/\|07*brien   `scan' listing format in mmh
317 .fi
318 .RE
319 .PP
320 The `+' on message 15 indicates that it is the current message.
321 The `\-' on message 16 indicates that it has been replied to, as indicated
322 by a `Replied:' component (produced by the
323 .B \-annotate
324 switch
325 to the
326 .B repl
327 command).
328 The `*' on message 19 indicates that no `Date:' header was
329 present.  The time of last modification of the message is given instead.
330 .B Scan
331 actually reads each of the specified messages and parses them to extract
332 the desired fields.  During parsing, appropriate error messages will be
333 produced if there are format errors in any of the messages.
334 .PP
335 By default,
336 .B scan
337 will decode RFC-2047 (MIME) encoding in
338 these scan listings.
339 .B Scan
340 will only decode these fields if your
341 terminal can natively display the character set used in the encoding.
342 You should set the MM_CHARSET environment variable to your native
343 character set, if it is not US-ASCII.  See the mh-profile(5) man
344 page for details about this environment variable.
345 .PP
346 The
347 .B \-file
348 .I filename
349 switch allows the user to obtain a
350 .B scan
351 listing of a maildrop file as produced by
352 .BR packf .
353 This listing
354 includes every message in the file (you can't scan individual messages).
355 .PP
356 The switch
357 .B \-width
358 .I columns
359 may be used to specify the width of
360 the scan line.  The default is to use the width of the terminal.
361 .PP
362 The command:
363 .PP
364 .RS 5
365 (scan | pr ; show a \-showproc pr) | lpr
366 .RE
367 .PP
368 produces a scan listing of the current folder,
369 followed by a formatted listing of all messages in the folder, one
370 per page.  Omitting
371 .RB ` "\-showproc\ pr" '
372 will cause the messages to be
373 concatenated, separated by a one\-line header and two blank lines.
374 .PP
375 To override the output format used by
376 .BR scan ,
377 the
378 .B \-form
379 .I file
380 switch is used.  This permits individual fields of
381 the scan listing to be extracted with ease.
382 .I file
383 is either the name of a format file or a format string directly,
384 if prepended with an equal sign `='.
385 See
386 .BR mh\-format (5)
387 for the details.
388 .PP
389 In addition to the standard
390 .BR mh\-format (5)
391 escapes,
392 .B scan
393 also recognizes the following additional
394 .I component
395 escapes:
396 .PP
397 .RS 5
398 .nf
399 .ta \w'Dtimenow  'u +\w'Returns  'u
400 .I "Escape      Returns Description
401 dtimenow        date    the current date
402 folder  string  the name of the current folder
403 .fi
404 .RE
405 .PP
406 If no date header is present in the message, the
407 .I function
408 escapes
409 which operate on
410 .RB { date }
411 will return values for the date of last
412 modification of the message file itself.  This feature is handy for
413 scanning a draft folder, as message drafts usually aren't allowed
414 to have dates in them.
415 .PP
416 .B scan
417 will update the
418 .B mmh
419 context prior to starting the listing,
420 so interrupting a long
421 .B scan
422 listing preserves the new context.
423 .B nmh
424 purists hate this idea.
425
426 .SH FILES
427 .fc ^ ~
428 .nf
429 .ta \w'%etcdir%/ExtraBigFileName  'u
430 ^$HOME/.mmh/profile~^The user profile
431 .fi
432
433 .SH "PROFILE COMPONENTS"
434 .fc ^ ~
435 .nf
436 .ta 2.4i
437 .ta \w'ExtraBigProfileName  'u
438 ^Path:~^To determine the user's mail storage
439 ^Alternate\-Mailboxes:~^To determine the user's mailboxes
440 ^Current\-Folder:~^To find the default current folder
441 .fi
442
443 .SH "SEE ALSO"
444 mark(1)
445
446 .SH DEFAULTS
447 .nf
448 .RB ` +folder "' defaults to the current folder"
449 .RB ` msgs "' defaults to all messages"
450 .RB ` "\-datefield date" '
451 .RB ` \-zero '
452 .RB ` \-list "' is the default if no `\-sequence', `\-nolist' otherwise"
453 .RB ` "\-format pick\.default" "' if the program is called with scan `scan.default' is used
454 .fi
455
456 .SH CONTEXT
457 If a folder is given, it will become the current folder.
458
459 .SH HISTORY
460 In previous versions of
461 .BR MH ,
462 the
463 .B pick
464 command would
465 .BR show ,
466 .BR scan ,
467 or
468 .B refile
469 the selected messages.  This was rather
470 `inverted logic' from the UNIX point of view, so
471 .B pick
472 was changed to define sequences and output those sequences.  Hence,
473 .B pick
474 can be used to generate the arguments for all other
475 .B MH
476 commands, instead of giving
477 .B pick
478 endless switches for invoking those commands
479 itself.
480 .PP
481 Also, previous versions of
482 .B pick
483 balked if you didn't specify
484 a search string or a date/time constraint.  The current version does
485 not, and merely matches the messages you specify.  This lets you type
486 something like:
487 .PP
488 .RS 5
489 show\0`pick\0l:20\0\-seq\0fear`
490 .RE
491 .PP
492 instead of typing
493 .PP
494 .RS 5
495 .nf
496 mark\0\-add\0\-nozero\0\-seq\0fear\0l:20
497 show\0fear
498 .fi
499 .RE
500 .PP
501 Also, timezones used to be ignored when comparing dates: they aren't
502 any more.
503 .PP
504 In
505 .B MH
506 ,
507 .B nmh
508 and old
509 .B mmh
510 versions scan and pick where two different tools. So instand of typing
511 .PP
512 .RS 5
513 .nf
514 scan\0\-from\0philipp
515 .fi
516 .RE
517 .PP
518 you had typed
519 .PP
520 .RS 5
521 .nf
522 scan\0`pick\0\-from\0philipp`
523 .fi
524 .RE
525 .PP
526 With the default config the old style usage is still supported, so
527 you can write scripts for both mmh and nmh.
528 .SH "HELPFUL HINTS"
529 Use
530 .RB ` "pick sequence \-list" '
531 to enumerate the messages in a sequence
532 (such as for use by a shell script).
533
534 .SH BUGS
535 Any occurrence of
536 .B \-datefield
537 must occur prior to the
538 .B \-after
539 or
540 .B \-before
541 switch it applies to.
542 .PP
543 If
544 .B pick
545 is used in a back\-quoted operation, such as
546 .PP
547 .RS 5
548 scan\0`pick\0\-from\0jones`
549 .RE
550 .PP
551 and
552 .B pick
553 selects no messages (e.g., no messages are from
554 `jones'), then the shell will still run the outer command (e.g.,
555 .BR scan ).
556 Since no messages were matched,
557 .B pick
558 produced
559 no output, and the argument given to the outer command as a result of
560 backquoting
561 .B pick
562 is empty.  In the case of
563 .B mmh
564 programs,
565 the outer command now acts as if the default `msg' or `msgs' should be
566 used (e.g., `all' in the case of
567 .BR scan ).
568 To prevent this
569 unexpected behavior, if
570 .B \-list
571 was given, and if its standard output is not a tty, then
572 .B pick
573 outputs the illegal message number `0'
574 when it fails.  This lets the outer command fail gracefully as well.
575 .PP
576 To account for this case when combining
577 .B pick
578 with regular shell tools, filter out the message number `0'.
579 For example, do
580 .PP
581 .RS 5
582 pick\0...\0|\0fgrep\0-vx\0\&0\0|\0wc\0-l
583 .RE
584 .PP
585 to count the number of messages picked.
586 .PP
587 The pattern syntax `[l-r]' is not supported; each letter to be
588 matched must be included within the square brackets.