a2a54c4122637b7a834a2b75127e84f4b670da0e
[mmh] / man / pick.man
1 .\"
2 .\" %nmhwarning%
3 .\" $Id$
4 .\"
5 .\" include the -mh macro file
6 .so %etcdir%/tmac.h
7 .\"
8 .TH PICK %manext1% MH.6.8 [%nmhversion%]
9 .SH NAME
10 pick \- search for messages by content
11 .SH SYNOPSIS
12 .in +.5i
13 .ti -.5i
14 pick
15 \%[+folder] \%[msgs]
16 \%[\-and\ ...] \%[\-or\ ...] \%[\-not\ ...]
17 .br
18 \%[\-lbrace\ ...\ \-rbrace]
19 \%[\-\|\-component\ pattern]
20 .br
21 \%[\-cc\ pattern]
22 \%[\-date\ pattern]
23 \%[\-from\ pattern]
24 .br
25 \%[\-search\ pattern]
26 \%[\-subject\ pattern]
27 \%[\-to\ pattern]
28 .br
29 \%[\-after\ date]
30 \%[\-before\ date]
31 \%[\-datefield\ field]
32 .br
33 \%[\-sequence\ name\ ...]
34 \%[\-public] \%[\-nopublic]
35 \%[\-zero]
36 .br
37 \%[\-nozero]
38 \%[\-list] \%[\-nolist]
39 \%[\-version]
40 \%[\-help]
41 .ti .5i
42
43 typical usage:
44 .br
45 scan\0`pick\0\-from\0jones`
46 .br
47 pick\0\-to\0holloway\0\-sequence\0select
48 .br
49 show\0`pick\0\-before\0friday`
50 .in -.5i
51 .SH DESCRIPTION
52 \fIPick\fR searches within a folder for messages with the specified
53 contents, and then identifies those messages.  Two types of search
54 primitives are available: pattern matching and date constraint
55 operations.
56
57 A modified \fIgrep\fR(1) is used to perform the matching, so the
58 full regular expression (see \fIed\fR(1)) facility is available
59 within `pattern'.  With `\-search', `pattern' is used directly,
60 and with the others, the grep pattern constructed is:
61
62 .ti +.5i
63 \*(lqcomponent[ \\t]*:\&.*pattern\*(rq
64
65 This means that the pattern specified for a `\-search' will be found
66 everywhere in the message, including the header and the body, while
67 the other pattern matching requests are limited to the single specified
68 component.  The expression
69
70 .ti +.5i
71 `\-\|\-component\ pattern'
72
73 is a shorthand for specifying
74
75 .ti +.5i
76 `\-search \*(lqcomponent[ \\t]*:\&.*pattern\*(rq\ '
77
78 It is used to pick a component which is not one of \*(lqTo:\*(rq,
79 \*(lqcc:\*(rq, \*(lqDate:\*(rq, \*(lqFrom:\*(rq, or \*(lqSubject:\*(rq.
80 An example is `pick\0\-\|\-reply\-to\0pooh'.
81
82 Pattern matching is performed on a per\-line basis.  Within the header
83 of the message, each component is treated as one long line, but in the
84 body, each line is separate.  Lower\-case letters in the search pattern
85 will match either lower or upper case in the message, while upper case
86 will match only upper case.
87
88 Note that since the `\-date' switch is a pattern matching operation (as
89 described above), to find messages sent on a certain date the pattern
90 string must match the text of the \*(lqDate:\*(rq field of the message.
91
92 Independent of any pattern matching operations requested, the switches
93 `\-after date' or `\-before date' may also be used to introduce date/time
94 constraints on all of the messages.  By default, the \*(lqDate:\*(rq
95 field is consulted, but if another date yielding field (such as
96 \*(lqBB\-Posted:\*(rq or \*(lqDelivery\-Date:\*(rq) should be used, the
97 `\-datefield\ field' switch may be used.
98
99 With `\-before' and `\-after', \fIpick\fR will actually parse the date
100 fields in each of the messages specified in `msgs' and compare them
101 to the date/time specified.  If `\-after' is given, then only those
102 messages whose \*(lqDate:\*(rq field value is chronologically after the
103 date specified will be considered.  The `\-before' switch specifies the
104 complimentary action.
105
106 Both the `\-after' and `\-before' switches take legal 822\-style date
107 specifications as arguments.  \fIPick\fR will default certain missing
108 fields so that the entire date need not be specified.  These fields
109 are (in order of defaulting): timezone, time and timezone, date, date
110 and timezone.  All defaults are taken from the current date, time,
111 and timezone.
112
113 In addition to 822\-style dates, \fIpick\fR will also recognize any of
114 the days of the week (\*(lqsunday\*(rq, \*(lqmonday\*(rq, and so on),
115 and the special dates \*(lqtoday\*(rq, \*(lqyesterday\*(rq (24 hours
116 ago), and \*(lqtomorrow\*(rq (24 hours from now).  All days of the
117 week are judged to refer to a day in the past (e.g., telling \fIpick\fR
118 \*(lqsaturday\*(rq on a \*(lqtuesday\*(rq means \*(lqlast\ saturday\*(rq
119 not \*(lqthis\ saturday\*(rq).
120
121 Finally, in addition to these special specifications, \fIpick\fR will
122 also honor a specification of the form \*(lq\-dd\*(rq, which means
123 \*(lqdd days ago\*(rq.
124
125 \fIPick\fR supports complex boolean operations on the searching primitives
126 with the `\-and', `\-or', `\-not', and `\-lbrace\ ...\ \-rbrace' switches.
127 For example,
128
129 .ti +.5i
130 .ie t \{\
131 pick\0\-after\0yesterday\0\-and\0\-lbrace\0\-from\0freida\0\-or\0\-from\0fear\0\-rbrace
132 .\}
133 .el \{\
134 pick\0\-after\0yesterday\0\-and
135 .br
136 .ti +1i
137 \-lbrace\0\-from\0freida\0\-or\0\-from\0fear\0\-rbrace
138 .\}
139
140 identifies messages recently sent by \*(lqfrieda\*(rq or \*(lqfear\*(rq.
141
142 The matching primitives take precedence over the `\-not' switch, which
143 in turn takes precedence over `\-and' which in turn takes precedence
144 over `\-or'.  To override the default precedence, the `\-lbrace' and
145 `\-rbrace' switches are provided, which act just like opening and closing
146 parentheses in logical expressions.
147
148 If no search criteria are given, all the messages specified on the
149 command line are selected (this defaults to \*(lqall\*(rq).
150
151 Once the search has been performed, if the `\-list' switch is given, the
152 message numbers of the selected messages are written to the standard
153 output separated by newlines.  This is \fIextremely\fR useful for
154 quickly generating arguments for other \fInmh\fR programs by using the
155 \*(lqbackquoting\*(rq syntax of the shell.  For example, the command
156
157 .ti +.5i
158 scan\0`pick\0+todo\0\-after\0\*(lq31 Mar 83 0123 PST\*(rq`
159
160 says to \fIscan\fR those messages in the indicated folder which meet the
161 appropriate criterion.  Note that since \fIpick\fR\0's context changes
162 are written out prior to \fIscan\fR\0's invocation, you need not give
163 the folder argument to \fIscan\fR as well.
164
165 Regardless of the operation of the `\-list' switch, the `\-sequence name'
166 switch may be given once for each sequence the user wishes to define.
167 For each sequence named, that sequence will be defined to mean exactly
168 those messages selected by \fIpick\fR.  For example,
169
170 .ti +.5i
171 pick\0\-from\0frated\0\-seq\0fred
172
173 defines a new message sequence for the current folder called
174 \*(lqfred\*(rq which contains exactly those messages that were selected.
175
176 Note that whenever \fIpick\fR processes a `\-sequence\ name' switch, it
177 sets `\-nolist'.
178
179 By default, \fIpick\fR will zero the sequence before adding it.  This
180 action can be disabled with the `\-nozero' switch, which means that the
181 messages selected by \fIpick\fR will be added to the sequence, if it
182 already exists, and any messages already a part of that sequence will
183 remain so.
184
185 The `\-public' and `\-nopublic' switches are used by \fIpick\fR in the
186 same way \fImark\fR uses them.
187 .Fi
188 ^$HOME/\&.mh\(ruprofile~^The user profile
189 .Pr
190 ^Path:~^To determine the user's nmh directory
191 .Ps
192 ^Current\-Folder:~^To find the default current folder
193 .Sa
194 mark(1)
195 .De
196 `+folder' defaults to the current folder
197 .Ds
198 `msgs' defaults to all
199 .Ds
200 `\-datefield date'
201 .Ds
202 `\-zero'
203 .Ds
204 `\-list' is the default if no `\-sequence', `\-nolist' otherwise
205 .Co
206 If a folder is given, it will become the current folder.
207 .Hi
208 In previous versions of \fIMH\fR, the \fIpick\fR command would \fIshow\fR,
209 \fIscan\fR, or \fIrefile\fR the selected messages.  This was rather
210 \*(lqinverted logic\*(rq from the UNIX point of view, so \fIpick\fR was
211 changed to define sequences and output those sequences.  Hence, \fIpick\fR
212 can be used to generate the arguments for all other \fIMH\fR commands,
213 instead of giving \fIpick\fR endless switches for invoking those commands
214 itself.
215
216 Also, previous versions of \fIpick\fR balked if you didn't specify
217 a search string or a date/time constraint.  The current version does
218 not, and merely matches the messages you specify.  This lets you type
219 something like:
220
221 .ti +.5i
222 show\0`pick\0last:20\0\-seq\0fear`
223
224 instead of typing
225
226 .in +.5i
227 .nf
228 mark\0\-add\0\-nozero\0\-seq\0fear\0last:20
229 show\0fear
230 .fi
231 .in -.5i
232
233 Finally, timezones used to be ignored when comparing dates: they aren't
234 any more.
235 .Hh
236 Use \*(lqpick sequence \-list\*(rq to enumerate the messages in a sequence
237 (such as for use by a shell script).
238 .Bu
239 The argument to the `\-after' and `\-before' switches must be interpreted
240 as a single token by the shell that invokes \fIpick\fR.  Therefore, one
241 must usually place the argument to this switch inside double\-quotes.
242 Furthermore, any occurrence of `\-datefield' must occur prior to the
243 `\-after' or `\-before' switch it applies to.
244
245 If \fIpick\fR is used in a back\-quoted operation, such as
246
247 .ti +.5i
248 scan\0`pick\0\-from\0jones`
249
250 and \fIpick\fR selects no messages (e.g., no messages are from
251 \*(lqjones\*(rq), then the shell will still run the outer command (e.g.,
252 \*(lqscan\*(rq).  Since no messages were matched, \fIpick\fR produced
253 no output, and the argument given to the outer command as a result of
254 backquoting \fIpick\fR is empty.  In the case of \fInmh\fR programs,
255 the outer command now acts as if the default `msg' or `msgs' should be
256 used (e.g., \*(lqall\*(rq in the case of \fIscan\fR\0).  To prevent this
257 unexpected behavior, if `\-list' was given, and if its standard output is
258 not a tty, then \fIpick\fR outputs the illegal message number \*(lq0\*(rq
259 when it fails.  This lets the outer command fail gracefully as well.
260
261 .sp
262 The pattern syntax \*(lq[l-r]\*(rq is not supported; each letter to be
263 matched must be included within the square brackets.
264 .En