1ef41561783bff27abb80bb2178b092f410cc148
[mmh] / man / pick.man
1 .\"
2 .\" %nmhwarning%
3 .\" $Id$
4 .\"
5 .TH PICK %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
6 .SH NAME
7 pick \- search for messages by content
8 .SH SYNOPSIS
9 .HP 5
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 .PP
51 typical usage:
52 .PP
53 .RS 5
54 .nf
55 scan\0`pick\0\-from\0jones`
56 pick\0\-to\0holloway\0\-sequence\0select
57 show\0`pick\0\-before\0friday`
58 .fi
59 .RE
60
61 .SH DESCRIPTION
62 .B Pick
63 searches within a folder for messages with the specified
64 contents, and then identifies those messages.  Two types of search
65 primitives are available: pattern matching and date constraint
66 operations.
67 .PP
68 A modified
69 .BR grep (1)
70 is used to perform the matching, so the
71 full regular expression (see
72 .BR ed (1))
73 facility is available
74 within
75 .IR pattern .
76 With
77 .BR \-search ,
78 .I pattern
79 is used directly, and with the others, the grep pattern constructed is:
80 .PP
81 .RS 5
82 `component[ \\t]*:\&.*pattern'
83 .RE
84 .PP
85 This means that the pattern specified for a
86 .B \-search
87 will be found
88 everywhere in the message, including the header and the body, while
89 the other pattern matching requests are limited to the single specified
90 component.  The expression
91 .PP
92 .RS 5
93 `\-\|\-component\ pattern'
94 .RE
95 .PP
96 is a shorthand for specifying
97 .PP
98 .RS 5
99 `\-search \*(lqcomponent[ \\t]*:\&.*pattern\*(rq\ '
100 .RE
101 .PP
102 It is used to pick a component which is not one of \*(lqTo:\*(rq,
103 \*(lqcc:\*(rq, \*(lqDate:\*(rq, \*(lqFrom:\*(rq, or \*(lqSubject:\*(rq.
104 An example is
105 .RB \*(lq "pick\0\-\|\-reply\-to\0pooh" \*(rq.
106 .PP
107 Pattern matching is performed on a per\-line basis.  Within the header
108 of the message, each component is treated as one long line, but in the
109 body, each line is separate.  Lower\-case letters in the search pattern
110 will match either lower or upper case in the message, while upper case
111 will match only upper 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 \*(lqDate:\*(rq 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 \*(lqDate:\*(rq
127 field is consulted, but if another date yielding field (such as
128 \*(lqBB\-Posted:\*(rq or \*(lqDelivery\-Date:\*(rq) 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 \*(lqDate:\*(rq 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 (\*(lqsunday\*(rq, \*(lqmonday\*(rq, and so on),
166 and the special dates \*(lqtoday\*(rq, \*(lqyesterday\*(rq (24 hours
167 ago), and \*(lqtomorrow\*(rq (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 \*(lqsaturday\*(rq on a \*(lqtuesday\*(rq means \*(lqlast\ saturday\*(rq
170 not \*(lqthis\ saturday\*(rq).
171 .PP
172 Finally, in addition to these special specifications,
173 .B pick
174 will
175 also honor a specification of the form \*(lq\-dd\*(rq, which means
176 \*(lqdd days ago\*(rq.
177 .PP
178 .B Pick
179 supports complex boolean operations on the searching primitives
180 with the
181 .BR \-and ,
182 .BR \-or ,
183 .BR \-not ,
184 and
185 .B \-lbrace
186 .B \&...
187 .B \-rbrace
188 switches.
189 For example,
190 .PP
191 .RS 5
192 .nf
193 pick\0\-after\0yesterday\0\-and
194      \-lbrace\0\-from\0freida\0\-or\0\-from\0fear\0\-rbrace
195 .fi
196 .RE
197 .PP
198 identifies messages recently sent by \*(lqfrieda\*(rq or \*(lqfear\*(rq.
199 .PP
200 The matching primitives take precedence over the
201 .B \-not
202 switch, which in turn takes precedence over
203 .B \-and
204 which in turn takes precedence
205 over
206 .BR \-or .
207 To override the default precedence, the
208 .B \-lbrace
209 and
210 .B \-rbrace
211 switches are provided, which act just like opening and closing
212 parentheses in logical expressions.
213 .PP
214 If no search criteria are given, all the messages specified on the
215 command line are selected (this defaults to \*(lqall\*(rq).
216 .PP
217 Once the search has been performed, if the
218 .B \-list
219 switch is given, the
220 message numbers of the selected messages are written to the standard
221 output separated by newlines.  This is
222 .B extremely
223 useful for
224 quickly generating arguments for other
225 .B nmh
226 programs by using the
227 \*(lqbackquoting\*(rq syntax of the shell.  For example, the command
228 .PP
229 .RS 5
230 scan\0`pick\0+todo\0\-after\0\*(lq31 Mar 83 0123 PST\*(rq`
231 .RE
232 .PP
233 says to
234 .B scan
235 those messages in the indicated folder which meet the
236 appropriate criterion.  Note that since
237 .BR pick 's
238 context changes
239 are written out prior to
240 .BR scan 's
241 invocation, you need not give
242 the folder argument to
243 .B scan
244 as well.
245 .PP
246 Regardless of the operation of the
247 .B \-list
248 switch, the
249 .B \-sequence
250 .I name
251 switch may be given once for each sequence the user wishes to define.
252 For each sequence named, that sequence will be defined to mean exactly
253 those messages selected by
254 .BR pick .
255 For example,
256 .PP
257 .RS 5
258 pick\0\-from\0frated\0\-seq\0fred
259 .RE
260 .PP
261 defines a new message sequence for the current folder called
262 \*(lqfred\*(rq which contains exactly those messages that were selected.
263 .PP
264 Note that whenever
265 .B pick
266 processes a
267 .B \-sequence
268 .I name
269 switch, it
270 sets
271 .BR \-nolist .
272 .PP
273 By default,
274 .B pick
275 will zero the sequence before adding it.  This
276 action can be disabled with the
277 .B \-nozero
278 switch, which means that the
279 messages selected by
280 .B pick
281 will be added to the sequence, if it
282 already exists, and any messages already a part of that sequence will
283 remain so.
284 .PP
285 The
286 .B \-public
287 and
288 .B \-nopublic
289 switches are used by
290 .B pick
291 in the
292 same way
293 .B mark
294 uses them.
295
296 .SH FILES
297 .fc ^ ~
298 .nf
299 .ta \w'/usr/local/nmh/etc/ExtraBigFileName  'u
300 ^$HOME/\&.mh\(ruprofile~^The user profile
301 .fi
302
303 .SH "PROFILE COMPONENTS"
304 .fc ^ ~
305 .nf
306 .ta 2.4i
307 .ta \w'ExtraBigProfileName  'u
308 ^Path:~^To determine the user's nmh directory
309 ^Current\-Folder:~^To find the default current folder
310 .fi
311
312 .SH "SEE ALSO"
313 mark(1)
314
315 .SH DEFAULTS
316 .nf
317 .RB ` +folder "' defaults to the current folder"
318 .RB ` msgs "' defaults to all"
319 .RB ` "\-datefield date" '
320 .RB ` \-zero '
321 .RB ` \-list "' is the default if no `\-sequence', `\-nolist' otherwise"
322 .fi
323
324 .SH CONTEXT
325 If a folder is given, it will become the current folder.
326
327 .SH HISTORY
328 In previous versions of
329 .BR MH ,
330 the
331 .B pick
332 command would
333 .BR show ,
334 .BR scan ,
335 or
336 .B refile
337 the selected messages.  This was rather
338 \*(lqinverted logic\*(rq from the UNIX point of view, so
339 .B pick
340 was changed to define sequences and output those sequences.  Hence,
341 .B pick
342 can be used to generate the arguments for all other
343 .B MH
344 commands, instead of giving
345 .B pick
346 endless switches for invoking those commands
347 itself.
348 .PP
349 Also, previous versions of
350 .B pick
351 balked if you didn't specify
352 a search string or a date/time constraint.  The current version does
353 not, and merely matches the messages you specify.  This lets you type
354 something like:
355 .PP
356 .RS 5
357 show\0`pick\0last:20\0\-seq\0fear`
358 .RE
359 .PP
360 instead of typing
361 .PP
362 .RS 5
363 .nf
364 mark\0\-add\0\-nozero\0\-seq\0fear\0last:20
365 show\0fear
366 .fi
367 .RE
368 .PP
369 Finally, timezones used to be ignored when comparing dates: they aren't
370 any more.
371
372 .SH "HELPFUL HINTS"
373 Use
374 .RB \*(lq "pick sequence \-list" \*(rq
375 to enumerate the messages in a sequence
376 (such as for use by a shell script).
377
378 .SH BUGS
379 The argument to the
380 .B \-after
381 and
382 .B \-before
383 switches must be interpreted
384 as a single token by the shell that invokes
385 .BR pick .
386 Therefore, one
387 must usually place the argument to this switch inside double\-quotes.
388 Furthermore, any occurrence of
389 .B \-datefield
390 must occur prior to the
391 .B \-after
392 or
393 .B \-before
394 switch it applies to.
395 .PP
396 If
397 .B pick
398 is used in a back\-quoted operation, such as
399 .PP
400 .RS 5
401 scan\0`pick\0\-from\0jones`
402 .RE
403 .PP
404 and
405 .B pick
406 selects no messages (e.g., no messages are from
407 \*(lqjones\*(rq), then the shell will still run the outer command (e.g.,
408 .BR scan ).
409 Since no messages were matched,
410 .B pick
411 produced
412 no output, and the argument given to the outer command as a result of
413 backquoting
414 .B pick
415 is empty.  In the case of
416 .B nmh
417 programs,
418 the outer command now acts as if the default `msg' or `msgs' should be
419 used (e.g., \*(lqall\*(rq in the case of
420 .BR scan ).
421 To prevent this
422 unexpected behavior, if
423 .B \-list
424 was given, and if its standard output is not a tty, then
425 .B pick
426 outputs the illegal message number \*(lq0\*(rq
427 when it fails.  This lets the outer command fail gracefully as well.
428 .PP
429 The pattern syntax \*(lq[l-r]\*(rq is not supported; each letter to be
430 matched must be included within the square brackets.