]> diplodocus.org Git - nmh/blob - man/pick.man
new.c: Order two return statements to match comment.
[nmh] / man / pick.man
1 .TH PICK %manext1% 2016-03-12 "%nmhversion%"
2 .
3 .\" %nmhwarning%
4 .
5 .SH NAME
6 pick \- search nmh messages
7 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B pick
11 .RB [ \-help ]
12 .RB [ \-version ]
13 .RI [ +folder ]
14 .RI [ msgs ]
15 .RB [ \-reverse
16 \&...]
17 .RB [ \-and
18 \&...]
19 .RB [ \-or
20 \&...]
21 .RB [ \-not
22 \&...]
23 .RB [ \-lbrace
24 \&...
25 .BR \-rbrace ]
26 .RB [ \-\|\-component
27 .IR pattern ]
28 .RB [ \-cc
29 .IR pattern ]
30 .RB [ \-date
31 .IR pattern ]
32 .RB [ \-from
33 .IR pattern ]
34 .RB [ \-search
35 .IR pattern ]
36 .RB [ \-subject
37 .IR pattern ]
38 .RB [ \-to
39 .IR pattern ]
40 .RB [ \-after
41 .IR date ]
42 .RB [ \-before
43 .IR date ]
44 .RB [ \-datefield
45 .IR field ]
46 .RB [ \-sequence
47 .I name
48 \&...]
49 .RB [ \-nosequence ]
50 .RB [ \-public " | " \-nopublic ]
51 .RB [ \-zero " | " \-nozero ]
52 .RB [ \-list " | " \-nolist ]
53 .RB [ \-debug ]
54 .PP
55 typical usage:
56 .PP
57 .RS 5
58 .nf
59 scan\0`pick\0\-from\0jones`
60 pick\0\-to\0holloway\0\-sequence\0select
61 show\0`pick\0\-before\0friday`
62 .fi
63 .RE
64 .ad
65 .SH DESCRIPTION
66 .B pick
67 searches within a folder for messages with the specified
68 contents, and then identifies those messages. Two types of search
69 primitives are available: pattern matching and date constraint
70 operations.
71 .PP
72 A modified
73 .IR grep (1)
74 is used to perform the matching, so the full regular expression (see
75 .IR ed (1))
76 facility is available within
77 .IR pattern .
78 With
79 .BR \-search ,
80 .I pattern
81 is used directly, and with the others, the grep pattern constructed is:
82 .PP
83 .RS 5
84 `component[ \\t]*:.*pattern'
85 .RE
86 .PP
87 This means that the pattern specified for a
88 .B \-search
89 will be found everywhere in the message, including the header and the body,
90 while 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 described above),
117 to find messages sent on a certain date the pattern string must match
118 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 constraints on all of the messages.
127 By default, the \*(lqDate:\*(rq field is consulted, but if another
128 date-yielding field (such as \*(lqBB\-Posted:\*(rq or
129 \*(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 fields in each of the messages specified in
140 `msgs' and compare them to the date/time specified. If
141 .B \-after
142 is given, then only those messages whose \*(lqDate:\*(rq field value is
143 chronologically after the date specified will be considered. The
144 .B \-before
145 switch specifies the complementary action.
146 .PP
147 Both the
148 .B \-after
149 and
150 .B \-before
151 switches take legal RFC 822-style date specifications as arguments.
152 .B pick
153 will default certain missing fields so that the entire date need not
154 be specified. These fields are (in order of defaulting): timezone,
155 time and timezone, date, date and timezone.
156 All defaults are taken from the current date, time, and timezone.
157 .PP
158 In addition to RFC 822-style dates,
159 .B pick
160 will also recognize any of the days of the week (\*(lqsunday\*(rq,
161 \*(lqmonday\*(rq, and so on), and the special dates \*(lqtoday\*(rq,
162 \*(lqyesterday\*(rq (24 hours ago), and \*(lqtomorrow\*(rq
163 (24 hours from now).
164 All days of the week are judged to refer to a day in the past
165 (e.g., telling \fIpick\fR \*(lqsaturday\*(rq on a \*(lqtuesday\*(rq
166 means \*(lqlast\ saturday\*(rq not \*(lqthis\ saturday\*(rq).
167 .PP
168 Finally, in addition to these special specifications,
169 .B pick
170 will also honor a specification of the form \*(lq\-dd\*(rq, which means
171 \*(lqdd days ago\*(rq.
172 .PP
173 Use the
174 .B \-reverse
175 switch to make
176 .B pick
177 find matching messages in reverse order, working from the highest message
178 number down to the lowest. This can be useful in searching for recent
179 messages in large folders, for example,
180 .PP
181 .RS 5
182 .nf
183 pick\0\-reverse\0\-from\0frated\0|\0xargs\0\-n1\0scan
184 .fi
185 .RE
186 .PP
187 .B pick
188 supports complex boolean operations on the searching primitives with the
189 .BR \-and ,
190 .BR \-or ,
191 .BR \-not ,
192 and
193 .B \-lbrace
194 .B \&...
195 .B \-rbrace
196 switches.
197 For example,
198 .PP
199 .RS 5
200 .nf
201 pick\0\-after\0yesterday\0\-and
202 \-lbrace\0\-from\0freida\0\-or\0\-from\0fear\0\-rbrace
203 .fi
204 .RE
205 .PP
206 identifies messages recently sent by \*(lqfrieda\*(rq or \*(lqfear\*(rq.
207 .PP
208 The matching primitives take precedence over the
209 .B \-not
210 switch, which in turn takes precedence over
211 .B \-and
212 which in turn takes precedence over
213 .BR \-or .
214 To override the default precedence, the
215 .B \-lbrace
216 and
217 .B \-rbrace
218 switches are provided, which act just like opening and closing
219 parentheses in logical expressions.
220 .PP
221 If no search criteria are given, all the messages specified on the
222 command line are selected (this defaults to \*(lqall\*(rq).
223 .PP
224 Once the search has been performed, if the
225 .B \-list
226 switch is given, the message numbers of the selected messages are
227 written to the standard output separated by newlines. This is
228 .I extremely
229 useful for quickly generating arguments for other
230 .B nmh
231 programs by using the \*(lqbackquoting\*(rq syntax of the shell.
232 For example, the command
233 .PP
234 .RS 5
235 scan\0`pick\0+todo\0\-after\0\*(lq31 Mar 83 0123 PST\*(rq`
236 .RE
237 .PP
238 says to
239 .B scan
240 those messages in the indicated folder which meet the appropriate
241 criterion. Note that since
242 .BR pick 's
243 context changes are written out prior to
244 .BR scan 's
245 invocation, you need not give the folder argument to
246 .B scan
247 as well.
248 .PP
249 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 The
266 .B \-nosequence
267 switch will disable all previously named sequences, allowing
268 those established by a profile component to be overridden.
269 .PP
270 By default,
271 .B pick
272 will zero a sequence before adding it. This action can be disabled with the
273 .B \-nozero
274 switch, which means that the messages selected by
275 .B pick
276 will be added to the sequence, if it already exists, and any messages
277 already a part of that sequence will remain so.
278 .PP
279 The
280 .B \-public
281 and
282 .B \-nopublic
283 switches are used by
284 .B pick
285 in the same way
286 .B mark
287 uses them.
288 .PP
289 The
290 .B \-debug
291 switch causes pick to output a representation of the search pattern.
292 .SS "Output when no messages are matched"
293 If
294 .B pick
295 is used in a backquoted operation, such as
296 .PP
297 .RS 5
298 scan\0`pick\0\-from\0jones`
299 .RE
300 .PP
301 and
302 .B pick
303 selects no messages (e.g., no messages are from \*(lqjones\*(rq),
304 then the shell will still run the outer command (e.g.,
305 .BR scan ).
306 Since no messages were matched,
307 .B pick
308 produced no output, and the argument given to the outer command as a
309 result of backquoting
310 .B pick
311 is empty. In the case of
312 .B nmh
313 programs, the outer command now acts as if the default `msg' or `msgs'
314 should be used (e.g., \*(lqall\*(rq in the case of
315 .BR scan ).
316 To prevent this unexpected behavior, if
317 .B \-list
318 was given, and if its standard output is not a tty, then
319 .B pick
320 outputs the illegal message number \*(lq0\*(rq when it fails.
321 This lets the outer command fail gracefully as well.
322 .SH FILES
323 .fc ^ ~
324 .nf
325 .ta \w'%nmhetcdir%/ExtraBigFileName 'u
326 ^$HOME/.mh_profile~^The user profile
327 .fi
328 .SH "PROFILE COMPONENTS"
329 .fc ^ ~
330 .nf
331 .ta 2.4i
332 .ta \w'ExtraBigProfileName 'u
333 ^Path:~^To determine the user's nmh directory
334 ^Current\-Folder:~^To find the default current folder
335 .fi
336 .SH "SEE ALSO"
337 .IR mark (1)
338 .SH DEFAULTS
339 .nf
340 .RB ` +folder "' defaults to the current folder"
341 .RB ` msgs "' defaults to all"
342 .RB ` "\-datefield date" '
343 .RB ` \-zero '
344 .RB ` \-list "' is the default if no `\-sequence', `\-nolist' otherwise"
345 .fi
346 .SH CONTEXT
347 If a folder is given, it will become the current folder.
348 .SH HISTORY
349 In previous versions of
350 .BR MH ,
351 the
352 .B pick
353 command would
354 .BR show ,
355 .BR scan ,
356 or
357 .B refile
358 the selected messages. This was rather
359 \*(lqinverted logic\*(rq from the Unix point of view, so
360 .B pick
361 was changed to define sequences and output those sequences. Hence,
362 .B pick
363 can be used to generate the arguments for all other
364 .B MH
365 commands, instead of giving
366 .B pick
367 endless switches for invoking those commands
368 itself.
369 .PP
370 Also, previous versions of
371 .B pick
372 balked if you didn't specify
373 a search string or a date/time constraint. The current version does
374 not, and merely matches the messages you specify. This lets you type
375 something like:
376 .PP
377 .RS 5
378 show\0`pick\0last:20\0\-seq\0fear`
379 .RE
380 .PP
381 instead of typing
382 .PP
383 .RS 5
384 .nf
385 mark\0\-add\0\-nozero\0\-seq\0fear\0last:20
386 show\0fear
387 .fi
388 .RE
389 .PP
390 Finally, timezones used to be ignored when comparing dates: they aren't
391 any more.
392 .SH "HELPFUL HINTS"
393 Use
394 .RB \*(lq "pick sequence \-list" \*(rq
395 to enumerate the messages in a sequence
396 (such as for use by a shell script).
397 .SH BUGS
398 Any occurrence of
399 .B \-datefield
400 must occur prior to the
401 .B \-after
402 or
403 .B \-before
404 switch it applies to.
405 .PP
406 The pattern syntax \*(lq[l-r]\*(rq is not supported; each letter to be
407 matched must be included within the square brackets.