From 7bd97127b4e45dcef1159603834b04ef0dcadfd7 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 29 Apr 2017 07:58:49 -0400 Subject: vim-patch:7.4.2244 Problem: Adding pattern to ":oldfiles" is not a generic solution. Solution: Add the ":filter /pat/ cmd" command modifier. Only works for some commands right now. https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928 --- src/nvim/message.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index 696855e3aa..c83dfcd63f 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -31,6 +31,7 @@ #include "nvim/ops.h" #include "nvim/option.h" #include "nvim/normal.h" +#include "nvim/regexp.h" #include "nvim/screen.h" #include "nvim/strings.h" #include "nvim/ui.h" @@ -148,6 +149,12 @@ msg_attr_keep ( int retval; char_u *buf = NULL; + // Skip messages not match ":filter pattern". + // Don't filter when there is an error. + if (!emsg_on_display && message_filtered(s)) { + return true; + } + if (attr == 0) { set_vim_var_string(VV_STATUSMSG, (char *) s, -1); } @@ -1783,6 +1790,14 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, msg_check(); } +/// Return true when ":filter pattern" was used and "msg" does not match +/// "pattern". +bool message_filtered(char_u *msg) +{ + return cmdmod.filter_regmatch.regprog != NULL + && !vim_regexec(&cmdmod.filter_regmatch, msg, (colnr_T)0); +} + /* * Scroll the screen up one line for displaying the next message line. */ -- cgit From f219657453271f19519148d76536879bec044534 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 29 Apr 2017 21:29:44 -0400 Subject: vim-patch:7.4.2263 Problem: :filter does not work for many commands. Can only get matching messages. Solution: Make :filter work for :command, :map, :list, :number and :print. Make ":filter!" show non-matching lines. https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70 --- src/nvim/message.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/nvim/message.c') diff --git a/src/nvim/message.c b/src/nvim/message.c index c83dfcd63f..057ce75f79 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1794,8 +1794,12 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, /// "pattern". bool message_filtered(char_u *msg) { - return cmdmod.filter_regmatch.regprog != NULL - && !vim_regexec(&cmdmod.filter_regmatch, msg, (colnr_T)0); + if (cmdmod.filter_regmatch.regprog == NULL) { + return false; + } + + bool match = vim_regexec(&cmdmod.filter_regmatch, msg, (colnr_T)0); + return cmdmod.filter_force ? match : !match; } /* -- cgit