seq: - now refers to the message on stdin, use .- for previous message

pull/180/head
Leah Neukirchen 4 years ago
parent 54283ebeee
commit e7442fcc72

@ -1,3 +1,12 @@
## 1.0
* Caution! Backwards incompatible changes:
* As a message name, `-` now refers to the message on the standard input,
and not the the previous message anymore. Use `.-` to refer to
the previous message in a short way.
The tools will print a warning if you use `-` and the standard input
comes from a TTY.
## 0.7 (2020-05-15)
* All tools now follow symlinks to mails.
@ -28,7 +37,7 @@
* New tool msearch to wrap several mail indexers.
* New zsh completion _mblaze.
* mnext/mprev were removed (you can call `mless +`/`mless -`).
* mnext/mprev were removed (you can call `mless +`/`mless .-`).
* The GnuPG tools in contrib/ now use gpg2.
* mshow exits with error if it could not extract all attachments
* mrep: add -noquote to disable quoting the message replied to

@ -592,7 +592,11 @@ blaze822_file(char *file)
char *buf = 0;
ssize_t rd = 0, n;
int fd = open(file, O_RDONLY);
int fd;
if (strcmp(file, "/dev/stdin") == 0)
fd = dup(0);
else
fd = open(file, O_RDONLY);
if (fd < 0)
return 0;

@ -1,4 +1,4 @@
.Dd July 22, 2016
.Dd July 3, 2020
.Dt MMSG 7
.Os
.Sh NAME
@ -77,7 +77,9 @@ with more indentation
.Pc .
.Pp
The following special shortcuts may be used:
.Bl -tag -width 3n
.Bl -tag -width 4n
.It Sq Li \&-
refers to the message read directly from the standard input.
.It Sq Li \&.
refers to the current message.
Additionally, the syntax
@ -91,7 +93,7 @@ refers to the next message
like
.Sq Li \&.+1
.Pc
.It Sq Li \&-
.It Sq Li \&.-
refers to the previous message
.Po
like

13
seq.c

@ -151,6 +151,9 @@ blaze822_seq_cur(void)
int
blaze822_seq_setcur(char *s)
{
if (strcmp(s, "/dev/stdin") == 0)
return 0;
char *override = getenv("MAILDOT");
if (override)
return 0;
@ -180,7 +183,7 @@ parse_relnum(char *a, long cur, long start, long last, long *out)
if (strcmp(a, "+") == 0)
a = ".+1";
else if (strcmp(a, "-") == 0)
else if (strcmp(a, ".-") == 0)
a = ".-1";
else if (strcmp(a, ".") == 0)
a = ".+0";
@ -538,6 +541,14 @@ blaze822_loop(int argc, char *argv[], void (*cb)(char *))
for (i = 0; i < argc; i++) {
if (strchr(argv[i], '/')) { // a file name
j += iterdir(argv[i], cb);
} else if (strcmp(argv[i], "-") == 0) {
if (isatty(0)) {
fprintf(stderr, "mblaze: warning: - now means "
"read mail text from standard input, "
"use .- to refer to previous mail\n");
}
cb("/dev/stdin");
j++;
} else {
if (!map_opened) {
map = blaze822_seq_open(0);

@ -25,7 +25,7 @@ export MAILCUR=cur MAILSEQ=seq
check 'set current' 'mseq -C 1 && mseq . | grep "inbox/cur/1:2,"'
check 'set next' 'mseq -C + && mseq . | grep "inbox/cur/2:2,"'
check 'set prev' 'mseq -C - && mseq . | grep "inbox/cur/1:2,"'
check 'set prev' 'mseq -C .- && mseq . | grep "inbox/cur/1:2,"'
check 'last' 'mseq "$" | grep "inbox/cur/10:2,"'
check_test 'whole thread' -eq 4 'mseq 6= | wc -l'
check_test 'subthread' -eq 2 'mseq 7_ | wc -l'

Loading…
Cancel
Save