.B pick
.RI [ +folder ]
.RI [ msgs ]
+.RB [ \-reverse
+\&...]
.RB [ \-and
\&...]
.RB [ \-or
also honor a specification of the form \*(lq\-dd\*(rq, which means
\*(lqdd days ago\*(rq.
.PP
+Use the
+.BR \-reverse
+switch to make
+.B pick
+find matching messages in reverse order, working from the highest message
+number down to the lowest. This can be useful in for searching recent
+messages in large folders, for example,
+.PP
+.RS 5
+.nf
+pick\0\-reverse\0\-from\0frated\0|\0xargs\0\-n1\0scan
+.fi
+.RE
+.PP
.B Pick
supports complex boolean operations on the searching primitives
with the
10
11'
+# Test -reverse.
+run_test 'pick -reverse -not -subject message.8 last:5' '11
+10
+9
+7'
+
# Test -lbrace, -rbrace.
run_test 'pick -subject message.12 -and -subject message.3 -or -from Test4' '4'
run_test 'pick -subject message.12 -and -lbrace -subject message.3 -rbrace' \
#include <h/utils.h>
#define PICK_SWITCHES \
+ X("reverse", 0, REVSW) \
X("and", 0, ANDSW) \
X("or", 0, ORSW) \
X("not", 0, NOTSW) \
struct msgs *mp, *mp2;
register FILE *fp;
int debug = 0;
+ int reverse = 0;
if (nmh_init(argv[0], 1)) { return 1; }
listsw = 0; /* HACK */
done (0);
+ case REVSW:
+ reverse = 1;
+ continue;
+
case CCSW:
case DATESW:
case FROMSW:
* match. If there is NOT a match, then add it to a list to
* remove from the final sequence (it will make sense later)
*/
- for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
+ for (msgnum = reverse ? mp->hghsel : mp->lowsel;
+ reverse ? msgnum >= mp->lowsel : msgnum <= mp->hghsel;
+ msgnum += reverse ? -1 : 1) {
if (is_selected (mp, msgnum)) {
if ((fp = fopen (cp = m_name (msgnum), "r")) == NULL)
admonish (cp, "unable to read message");