summaryrefslogtreecommitdiff
path: root/src/message.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-04-14 17:16:22 +0200
committerBram Moolenaar <Bram@vim.org>2016-04-14 17:16:22 +0200
commit451f849fd6282a4facd4f0f58af62837443fb5a6 (patch)
treedcadb8161d6fc31d17394ce778067fd4625e2ddd /src/message.c
parent0f518a8f4d4be4cac10389680f6bd5e3781f94b0 (diff)
downloadvim-git-451f849fd6282a4facd4f0f58af62837443fb5a6.tar.gz
patch 7.4.1735v7.4.1735
Problem: It is not possible to only see part of the message history. It is not possible to clear messages. Solution: Add a count to ":messages" and a clear argument. (Yasuhiro Matsumoto)
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/message.c b/src/message.c
index 099c3aa75..b24013e41 100644
--- a/src/message.c
+++ b/src/message.c
@@ -770,6 +770,22 @@ ex_messages(exarg_T *eap UNUSED)
{
struct msg_hist *p;
char_u *s;
+ int c = 0;
+
+ if (STRCMP(eap->arg, "clear") == 0)
+ {
+ int keep = eap->addr_count == 0 ? 0 : eap->line2;
+
+ while (msg_hist_len > keep)
+ (void)delete_first_msg();
+ return;
+ }
+
+ if (*eap->arg != NUL)
+ {
+ EMSG(_(e_invarg));
+ return;
+ }
msg_hist_off = TRUE;
@@ -779,7 +795,23 @@ ex_messages(exarg_T *eap UNUSED)
_("Messages maintainer: Bram Moolenaar <Bram@vim.org>"),
hl_attr(HLF_T));
- for (p = first_msg_hist; p != NULL && !got_int; p = p->next)
+ p = first_msg_hist;
+
+ if (eap->addr_count != 0)
+ {
+ /* Count total messages */
+ for (; p != NULL && !got_int; p = p->next)
+ c++;
+
+ c -= eap->line2;
+
+ /* Skip without number of messages specified */
+ for (p = first_msg_hist; p != NULL && !got_int && c > 0;
+ p = p->next, c--);
+ }
+
+ /* Display what was not skipped. */
+ for (; p != NULL && !got_int; p = p->next)
if (p->msg != NULL)
msg_attr(p->msg, p->attr);