Factor trim format function out
[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 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B pick
11 .RI [ +folder ]
12 .RI [ msgs ]
13 .RB [ \-and
14 \&...]
15 .RB [ \-or
16 \&...]
17 .RB [ \-not
18 \&...]
19 .RB [ \-lbrace
20 \&...
21 .BR \-rbrace ]
22 .RB [ \-\|\-component
23 .IR pattern ]
24 .RB [ \-cc
25 .IR pattern ]
26 .RB [ \-date
27 .IR pattern ]
28 .RB [ \-from
29 .IR pattern ]
30 .RB [ \-search
31 .IR pattern ]
32 .RB [ \-subject
33 .IR pattern ]
34 .RB [ \-to
35 .IR pattern ]
36 .RB [ \-after
37 .IR date ]
38 .RB [ \-before
39 .IR date ]
40 .RB [ \-datefield
41 .IR field ]
42 .RB [ \-sequence
43 .I name
44 \&...]
45 .RB [ \-public " | " \-nopublic ]
46 .RB [ \-zero " | " \-nozero ]
47 .RB [ \-list " | " \-nolist ]
48 .RB [ \-Version ]
49 .RB [ \-help ]
50 .ad
51 .PP
52 typical usage:
53 .PP
54 .RS 5
55 .nf
56 scan\0`pick\0\-from\0jones`
57 pick\0\-to\0holloway\0\-sequence\0select
58 show\0`pick\0\-before\0friday`
59 .fi
60 .RE
61 .ad
62 .SH DESCRIPTION
63 .B Pick
64 searches within a folder for messages with the specified
65 contents, and then identifies those messages.  Two types of search
66 primitives are available: pattern matching and date constraint
67 operations.
68 .PP
69 A modified
70 .BR grep (1)
71 is used to perform the matching, so the
72 full regular expression (see
73 .BR ed (1))
74 facility is available
75 within
76 .IR pattern .
77 With
78 .BR \-search ,
79 .I pattern
80 is used directly, and with the others, the grep pattern constructed is:
81 .PP
82 .RS 5
83 `component[ \\t]*:\&.*pattern'
84 .RE
85 .PP
86 This means that the pattern specified for a
87 .B \-search
88 will be found
89 everywhere in the message, including the header and the body, while
90 the other pattern matching requests are limited to the single specified
91 component.  The expression
92 .PP
93 .RS 5
94 `\-\|\-component\ pattern'
95 .RE
96 .PP
97 is a shorthand for specifying
98 .PP
99 .RS 5
100 `\-search `component[ \\t]*:\&.*pattern'\ '
101 .RE
102 .PP
103 It is used to pick a component which is not one of `To:',
104 `Cc:', `Date:', `From:', or `Subject:'.
105 An example is
106 .RB ` "pick\0\-\|\-reply\-to\0pooh" '.
107 .PP
108 Pattern matching is performed on a per\-line basis.  Within the header
109 of the message, each component is treated as one long line, but in the
110 body, each line is separate.  Lower\-case letters in the search pattern
111 will match either lower or upper case in the message, while upper case
112 will match only upper case.
113 .PP
114 Note that since the
115 .B \-date
116 switch is a pattern matching operation (as
117 described above), to find messages sent on a certain date the pattern
118 string must match the text of the `Date:' field of the message.
119 .PP
120 Independent of any pattern matching operations requested, the switches
121 .B \-after
122 .I date
123 or
124 .B \-before
125 .I date
126 may also be used to introduce date/time
127 constraints on all of the messages.  By default, the `Date:'
128 field is consulted, but if another date yielding field (such as
129 `BB\-Posted:' or `Delivery\-Date:') should be used, the
130 .B \-datefield
131 .I field
132 switch may be used.
133 .PP
134 With
135 .B \-before
136 and
137 .BR \-after ,
138 .B pick
139 will actually parse the date
140 fields in each of the messages specified in `msgs' and compare them
141 to the date/time specified.  If
142 .B \-after
143 is given, then only those
144 messages whose `Date:' field value is chronologically after the
145 date specified will be considered.  The
146 .B \-before
147 switch specifies the
148 complimentary action.
149 .PP
150 Both the
151 .B \-after
152 and
153 .B \-before
154 switches take legal 822\-style date
155 specifications as arguments.
156 .B Pick
157 will default certain missing
158 fields so that the entire date need not be specified.  These fields
159 are (in order of defaulting): timezone, time and timezone, date, date
160 and timezone.  All defaults are taken from the current date, time,
161 and timezone.
162 .PP
163 In addition to 822\-style dates,
164 .B pick
165 will also recognize any of
166 the days of the week (`sunday', `monday', and so on),
167 and the special dates `today', `yesterday' (24 hours
168 ago), and `tomorrow' (24 hours from now).  All days of the
169 week are judged to refer to a day in the past (e.g., telling \fIpick\fR
170 `saturday' on a `tuesday' means `last\ saturday'
171 not `this\ saturday').
172 Finally, in addition to these special specifications,
173 .B pick
174 will
175 also honor a date specification of the form `\-\fIddd\fR', which means
176 `\fIddd\fR days ago'.
177 For example,
178 .PP
179 .RS 5
180 .nf
181 pick\0\-after\0\-30
182 .fi
183 .RE
184 .PP
185 identifies the messages of the last thirty days.
186 .PP
187 .B Pick
188 supports complex boolean operations on the searching primitives
189 with the
190 .BR \-and ,
191 .BR \-or ,
192 .BR \-not ,
193 and
194 .B \-lbrace
195 .B \&...
196 .B \-rbrace
197 switches.
198 For example,
199 .PP
200 .RS 5
201 .nf
202 pick\0\-after\0yesterday\0\-and
203      \-lbrace\0\-from\0freida\0\-or\0\-from\0fear\0\-rbrace
204 .fi
205 .RE
206 .PP
207 identifies messages recently sent by `frieda' or `fear'.
208 .PP
209 The matching primitives take precedence over the
210 .B \-not
211 switch, which in turn takes precedence over
212 .B \-and
213 which in turn takes precedence
214 over
215 .BR \-or .
216 To override the default precedence, the
217 .B \-lbrace
218 and
219 .B \-rbrace
220 switches are provided, which act just like opening and closing
221 parentheses in logical expressions.
222 .PP
223 If no search criteria are given, all the messages specified on the
224 command line are selected (this defaults to `all').
225 .PP
226 Once the search has been performed, if the
227 .B \-list
228 switch is given, the
229 message numbers of the selected messages are written to the standard
230 output separated by newlines.  This is
231 .B extremely
232 useful for
233 quickly generating arguments for other
234 .B mmh
235 programs by using the
236 `backquoting' syntax of the shell.  For example, the command
237 .PP
238 .RS 5
239 scan\0`pick\0+todo\0\-after\0`31 Mar 83 0123 PST'`
240 .RE
241 .PP
242 says to
243 .B scan
244 those messages in the indicated folder which meet the
245 appropriate criterion.  Note that since
246 .BR pick 's
247 context changes
248 are written out prior to
249 .BR scan 's
250 invocation, you need not give
251 the folder argument to
252 .B scan
253 as well.
254 .PP
255 The
256 .B \-sequence
257 .I name
258 switch may be given once for each sequence the user wishes to define.
259 For each sequence named, that sequence will be defined to mean exactly
260 those messages selected by
261 .BR pick .
262 For example,
263 .PP
264 .RS 5
265 pick\0\-from\0frated\0\-seq\0fred
266 .RE
267 .PP
268 defines a new message sequence for the current folder called
269 `fred' which contains exactly those messages that were selected.
270 .PP
271 By default,
272 .B pick
273 will zero the sequence before adding it.  This
274 action can be disabled with the
275 .B \-nozero
276 switch, which means that the
277 messages selected by
278 .B pick
279 will be added to the sequence, if it
280 already exists, and any messages already a part of that sequence will
281 remain so.
282 .PP
283 The
284 .B \-public
285 and
286 .B \-nopublic
287 switches are used by
288 .B pick
289 in the
290 same way
291 .B mark
292 uses them.
293
294 .SH FILES
295 .fc ^ ~
296 .nf
297 .ta \w'%etcdir%/ExtraBigFileName  'u
298 ^$HOME/.mmh/profile~^The user profile
299 .fi
300
301 .SH "PROFILE COMPONENTS"
302 .fc ^ ~
303 .nf
304 .ta 2.4i
305 .ta \w'ExtraBigProfileName  'u
306 ^Path:~^To determine the user's mail storage
307 ^Current\-Folder:~^To find the default current folder
308 .fi
309
310 .SH "SEE ALSO"
311 mark(1)
312
313 .SH DEFAULTS
314 .nf
315 .RB ` +folder "' defaults to the current folder"
316 .RB ` msgs "' defaults to all"
317 .RB ` "\-datefield date" '
318 .RB ` \-zero '
319 .RB ` \-list "' is the default if no `\-sequence', `\-nolist' otherwise"
320 .fi
321
322 .SH CONTEXT
323 If a folder is given, it will become the current folder.
324
325 .SH HISTORY
326 In previous versions of
327 .BR MH ,
328 the
329 .B pick
330 command would
331 .BR show ,
332 .BR scan ,
333 or
334 .B refile
335 the selected messages.  This was rather
336 `inverted logic' from the UNIX point of view, so
337 .B pick
338 was changed to define sequences and output those sequences.  Hence,
339 .B pick
340 can be used to generate the arguments for all other
341 .B MH
342 commands, instead of giving
343 .B pick
344 endless switches for invoking those commands
345 itself.
346 .PP
347 Also, previous versions of
348 .B pick
349 balked if you didn't specify
350 a search string or a date/time constraint.  The current version does
351 not, and merely matches the messages you specify.  This lets you type
352 something like:
353 .PP
354 .RS 5
355 show\0`pick\0l:20\0\-seq\0fear`
356 .RE
357 .PP
358 instead of typing
359 .PP
360 .RS 5
361 .nf
362 mark\0\-add\0\-nozero\0\-seq\0fear\0l:20
363 show\0fear
364 .fi
365 .RE
366 .PP
367 Finally, timezones used to be ignored when comparing dates: they aren't
368 any more.
369
370 .SH "HELPFUL HINTS"
371 Use
372 .RB ` "pick sequence \-list" '
373 to enumerate the messages in a sequence
374 (such as for use by a shell script).
375
376 .SH BUGS
377 Any occurrence of
378 .B \-datefield
379 must occur prior to the
380 .B \-after
381 or
382 .B \-before
383 switch it applies to.
384 .PP
385 If
386 .B pick
387 is used in a back\-quoted operation, such as
388 .PP
389 .RS 5
390 scan\0`pick\0\-from\0jones`
391 .RE
392 .PP
393 and
394 .B pick
395 selects no messages (e.g., no messages are from
396 `jones'), then the shell will still run the outer command (e.g.,
397 .BR scan ).
398 Since no messages were matched,
399 .B pick
400 produced
401 no output, and the argument given to the outer command as a result of
402 backquoting
403 .B pick
404 is empty.  In the case of
405 .B mmh
406 programs,
407 the outer command now acts as if the default `msg' or `msgs' should be
408 used (e.g., `all' in the case of
409 .BR scan ).
410 To prevent this
411 unexpected behavior, if
412 .B \-list
413 was given, and if its standard output is not a tty, then
414 .B pick
415 outputs the illegal message number `0'
416 when it fails.  This lets the outer command fail gracefully as well.
417 .PP
418 The pattern syntax `[l-r]' is not supported; each letter to be
419 matched must be included within the square brackets.