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