diff options
-rw-r--r-- | NEWS.md | 11 | ||||
-rw-r--r-- | blaze822.c | 6 | ||||
-rw-r--r-- | man/mmsg.7 | 8 | ||||
-rw-r--r-- | seq.c | 13 | ||||
-rw-r--r-- | t/7000-mseq.t | 2 |
5 files changed, 33 insertions, 7 deletions
diff --git a/NEWS.md b/NEWS.md index 6db5c03..5e18d66 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/blaze822.c b/blaze822.c index d34a4ae..d3e17f0 100644 --- a/blaze822.c +++ b/blaze822.c @@ -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; diff --git a/man/mmsg.7 b/man/mmsg.7 index 775e503..b413960 100644 --- a/man/mmsg.7 +++ b/man/mmsg.7 @@ -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 diff --git a/seq.c b/seq.c index 59a9470..970e30b 100644 --- a/seq.c +++ b/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); diff --git a/t/7000-mseq.t b/t/7000-mseq.t index 12d0b98..4afa561 100644 --- a/t/7000-mseq.t +++ b/t/7000-mseq.t @@ -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' |