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