]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0908: not possible to configure :messages v9.1.0908
authorChristian Brabandt <cb@256bit.org>
Fri, 6 Dec 2024 16:26:25 +0000 (17:26 +0100)
committerChristian Brabandt <cb@256bit.org>
Fri, 6 Dec 2024 16:26:25 +0000 (17:26 +0100)
Problem:  not possible to configure :messages
Solution: add the 'messagesopt' option (Shougo Matsushita)

closes: #16068

Co-authored-by: h_east <h.east.727@gmail.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
18 files changed:
runtime/doc/message.txt
runtime/doc/options.txt
runtime/doc/tags
runtime/doc/version9.txt
runtime/optwin.vim
src/message.c
src/option.c
src/option.h
src/optiondefs.h
src/optionstr.c
src/proto/message.pro
src/proto/option.pro
src/proto/optionstr.pro
src/testdir/gen_opt_test.vim
src/testdir/test_cmdline.vim
src/testdir/test_messages.vim
src/testdir/test_options.vim
src/version.c

index 69d8bc7c6ffde436dc74395b42f67ec8b729f6a2..3fcbd95706de01f709862336f839bb99a0f48ee0 100644 (file)
@@ -1,4 +1,4 @@
-*message.txt*   For Vim version 9.1.  Last change: 2024 Nov 14
+*message.txt*   For Vim version 9.1.  Last change: 2024 Dec 06
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -29,7 +29,7 @@ depends on the 'shortmess' option.
                                Clear messages, keeping only the {count} most
                                recent ones.
 
-The number of remembered messages is determined by the 'msghistory' option.
+The number of remembered messages is determined by the 'messagesopt' option.
 
                                                                *g<*
 The "g<" command can be used to see the last page of previous command output.
@@ -837,6 +837,7 @@ If you accidentally hit <Enter> or <Space> and you want to see the displayed
 text then use |g<|.  This only works when 'more' is set.
 
 To reduce the number of hit-enter prompts:
+- Set 'messagesopt'.
 - Set 'cmdheight' to 2 or higher.
 - Add flags to 'shortmess'.
 - Reset 'showcmd' and/or 'ruler'.
index 273ea64dec6477416fc18d753699fc2584d3bc97..a31d0415440e39b8993434fcf9282f808b6f85aa 100644 (file)
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.1.  Last change: 2024 Dec 03
+*options.txt*  For Vim version 9.1.  Last change: 2024 Dec 06
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -4439,7 +4439,7 @@ A jump table for the options with a short description can be found at |Q_op|.
                        global
        A history of ":" commands, and a history of previous search patterns
        is remembered.  This option decides how many entries may be stored in
-       each of these histories (see |cmdline-editing| and 'msghistory' for
+       each of these histories (see |cmdline-editing| and 'messagesopt' for
        the number of messages to remember).
        The maximum value is 10000.
        NOTE: This option is set to the Vi default value when 'compatible' is
@@ -5634,6 +5634,26 @@ A jump table for the options with a short description can be found at |Q_op|.
        generated from a list of items, e.g., the Buffers menu.  Changing this
        option has no direct effect, the menu must be refreshed first.
 
+                                               *'messagesopt'* *'mopt'*
+'messagesopt' 'mopt'   string  (default "hit-enter,history:500")
+                       global
+
+       Option settings when outputting messages.  It can consist of the
+       following items.  Items must be separated by a comma.
+
+       hit-enter       Use |hit-enter| prompt when the message is longer than
+                       'cmdheight' size.
+
+       wait:{n}        Ignored when "hit-enter" is present.  Instead of using
+                       |hit-enter| prompt, will simply wait for {n}
+                       milliseconds so the user has a chance to read the
+                       message, use 0 to disable sleep (but then the user may
+                       miss an important message).
+
+       history:{n}     Determines how many entries are remembered in the
+                       |:messages| history.  The maximum value is 10000.
+                       Setting it to zero clears the message history.
+
                                                *'mkspellmem'* *'msm'*
 'mkspellmem' 'msm'     string  (default "460000,2000,500")
                        global
@@ -5917,13 +5937,6 @@ A jump table for the options with a short description can be found at |Q_op|.
        time in msec between two mouse clicks for the second click to be
        recognized as a multi click.
 
-                                               *'msghistory'* *'mhi'*
-'msghistory' 'mhi'     number  (default 500)
-                       global
-       Determines how many entries are remembered in the |:messages| history.
-       The maximum value is 10000.
-       Setting it to zero clears the message history.
-
 
                                                    *'mzquantum'* *'mzq'*
 'mzquantum' 'mzq'      number  (default 100)
index ad870060df91eefbff31b7b3bf0f827ebb567cc3..f0ca51b5dc8e764c78677164694957a3dd3acde2 100644 (file)
@@ -499,9 +499,9 @@ $quote      eval.txt        /*$quote*
 'menc' options.txt     /*'menc'*
 'menuitems'    options.txt     /*'menuitems'*
 'mesg' vi_diff.txt     /*'mesg'*
+'messagesopt'  options.txt     /*'messagesopt'*
 'mfd'  options.txt     /*'mfd'*
 'mh'   options.txt     /*'mh'*
-'mhi'  options.txt     /*'mhi'*
 'mis'  options.txt     /*'mis'*
 'mkspellmem'   options.txt     /*'mkspellmem'*
 'ml'   options.txt     /*'ml'*
@@ -517,6 +517,7 @@ $quote      eval.txt        /*$quote*
 'modelines'    options.txt     /*'modelines'*
 'modifiable'   options.txt     /*'modifiable'*
 'modified'     options.txt     /*'modified'*
+'mopt' options.txt     /*'mopt'*
 'more' options.txt     /*'more'*
 'mouse'        options.txt     /*'mouse'*
 'mousef'       options.txt     /*'mousef'*
@@ -532,7 +533,6 @@ $quote      eval.txt        /*$quote*
 'mousetime'    options.txt     /*'mousetime'*
 'mp'   options.txt     /*'mp'*
 'mps'  options.txt     /*'mps'*
-'msghistory'   options.txt     /*'msghistory'*
 'msm'  options.txt     /*'msm'*
 'mzq'  options.txt     /*'mzq'*
 'mzquantum'    options.txt     /*'mzquantum'*
index f5f77b3e99fb9719d60e2697f24e6e41e499b261..312a1c23e7ac5df671691598c61c8e36b117ea7a 100644 (file)
@@ -1,4 +1,4 @@
-*version9.txt*  For Vim version 9.1.  Last change: 2024 Dec 05
+*version9.txt*  For Vim version 9.1.  Last change: 2024 Dec 06
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -41667,7 +41667,7 @@ Options: ~
                        popup
 'findfunc'             Vim function to obtain the results for a |:find|
                        command
-'msghistory'           Max number of messages to remember
+'messagesopt'          configure |:messages| and |hit-enter| prompt
 'winfixbuf'            Keep buffer focused in a window
 'tabclose'             Which tab page to focus after closing a tab page
 't_xo'                 Terminal uses XON/XOFF handshaking (e.g. vt420)
index c8170da71d0737473fc5f5739913fef41424a9f2..c3f917cc35bd57071de8b4b89deb776308d1054b 100644 (file)
@@ -749,8 +749,8 @@ call <SID>AddOption("terse", gettext("add 's' flag in 'shortmess' (don't show se
 call <SID>BinOptionG("terse", &terse)
 call <SID>AddOption("shortmess", gettext("list of flags to make messages shorter"))
 call <SID>OptionG("shm", &shm)
-call <SID>AddOption("msghistory", gettext("how many messages are remembered"))
-call append("$", " \tset mhi=" . &mhi)
+call <SID>AddOption("messagesopt", gettext("Option settings when outputting messages"))
+call <SID>OptionG("mopt", &mopt)
 call <SID>AddOption("showcmd", gettext("show (partial) command keys in location given by 'showcmdloc'"))
 let &sc = s:old_sc
 call <SID>BinOptionG("sc", &sc)
index 15eaaaeab720c6bc2206a1354226592a8824c749..34a2692184341931f548225cb1f05940a75f919e 100644 (file)
@@ -16,6 +16,7 @@
 #include "vim.h"
 
 static void add_msg_hist(char_u *s, int len, int attr);
+static void check_msg_hist(void);
 static void hit_return_msg(void);
 static void msg_home_replace_attr(char_u *fname, int attr);
 static void msg_puts_attr_len(char *str, int maxlen, int attr);
@@ -51,6 +52,21 @@ struct msg_hist
 static struct msg_hist *first_msg_hist = NULL;
 static struct msg_hist *last_msg_hist = NULL;
 static int msg_hist_len = 0;
+static int msg_hist_max = 500;         // The default max value is 500
+
+// flags obtained from the 'messagesopt' option
+#define MESSAGES_HIT_ENTER     0x001
+#define MESSAGES_WAIT          0x002
+#define MESSAGES_HISTORY       0x004
+
+// args in 'messagesopt' option
+#define MESSAGES_OPT_HIT_ENTER "hit-enter"
+#define MESSAGES_OPT_WAIT "wait:"
+#define MESSAGES_OPT_HISTORY "history:"
+
+// The default is "hit-enter,history:500"
+static int msg_flags = MESSAGES_HIT_ENTER | MESSAGES_HISTORY;
+static int msg_wait = 0;
 
 static FILE *verbose_fd = NULL;
 static int  verbose_did_open = FALSE;
@@ -1060,14 +1076,76 @@ delete_first_msg(void)
     return OK;
 }
 
-    void
+    static void
 check_msg_hist(void)
 {
     // Don't let the message history get too big
-    while (msg_hist_len > 0 && msg_hist_len > p_mhi)
+    while (msg_hist_len > 0 && msg_hist_len > msg_hist_max)
        (void)delete_first_msg();
 }
 
+
+    int
+messagesopt_changed(void)
+{
+    char_u     *p;
+    int                messages_flags_new = 0;
+    int                messages_wait_new = 0;
+    int                messages_history_new = 0;
+
+    p = p_meo;
+    while (*p != NUL)
+    {
+       if (STRNCMP(p, MESSAGES_OPT_HIT_ENTER,
+            STRLEN_LITERAL(MESSAGES_OPT_HIT_ENTER)) == 0)
+       {
+           p += STRLEN_LITERAL(MESSAGES_OPT_HIT_ENTER);
+           messages_flags_new |= MESSAGES_HIT_ENTER;
+       }
+       else if (STRNCMP(p, MESSAGES_OPT_WAIT,
+                 STRLEN_LITERAL(MESSAGES_OPT_WAIT)) == 0
+           && VIM_ISDIGIT(p[STRLEN_LITERAL(MESSAGES_OPT_WAIT)]))
+       {
+           p += STRLEN_LITERAL(MESSAGES_OPT_WAIT);
+           messages_wait_new = getdigits(&p);
+           messages_flags_new |= MESSAGES_WAIT;
+       }
+       else if (STRNCMP(p, MESSAGES_OPT_HISTORY,
+                 STRLEN_LITERAL(MESSAGES_OPT_HISTORY)) == 0
+           && VIM_ISDIGIT(p[STRLEN_LITERAL(MESSAGES_OPT_HISTORY)]))
+       {
+           p += STRLEN_LITERAL(MESSAGES_OPT_HISTORY);
+           messages_history_new = getdigits(&p);
+           messages_flags_new |= MESSAGES_HISTORY;
+       }
+
+       if (*p != ',' && *p != NUL)
+           return FAIL;
+       if (*p == ',')
+           ++p;
+    }
+
+    // Either "wait" or "hit-enter" is required
+    if (!(messages_flags_new & (MESSAGES_HIT_ENTER | MESSAGES_WAIT)))
+        return FAIL;
+
+    // "history" must be set
+    if (!(messages_flags_new & MESSAGES_HISTORY))
+        return FAIL;
+
+    // "history" must be <= 10000
+    if (messages_history_new > 10000)
+        return FAIL;
+
+    msg_flags = messages_flags_new;
+    msg_wait = messages_wait_new;
+
+    msg_hist_max = messages_history_new;
+    check_msg_hist();
+
+    return OK;
+}
+
 /*
  * ":messages" command.
  */
@@ -1228,118 +1306,127 @@ wait_return(int redraw)
        if (need_check_timestamps)
            check_timestamps(FALSE);
 
-       hit_return_msg();
-
-       do
+       if (msg_flags & MESSAGES_HIT_ENTER)
        {
-           // Remember "got_int", if it is set vgetc() probably returns a
-           // CTRL-C, but we need to loop then.
-           had_got_int = got_int;
-
-           // Don't do mappings here, we put the character back in the
-           // typeahead buffer.
-           ++no_mapping;
-           ++allow_keys;
-
-           // Temporarily disable Recording. If Recording is active, the
-           // character will be recorded later, since it will be added to the
-           // typebuf after the loop
-           save_reg_recording = reg_recording;
-           save_scriptout = scriptout;
-           reg_recording = 0;
-           scriptout = NULL;
-           c = safe_vgetc();
-           if (had_got_int && !global_busy)
-               got_int = FALSE;
-           --no_mapping;
-           --allow_keys;
-           reg_recording = save_reg_recording;
-           scriptout = save_scriptout;
+           hit_return_msg();
 
-#ifdef FEAT_CLIPBOARD
-           // Strange way to allow copying (yanking) a modeless selection at
-           // the hit-enter prompt.  Use CTRL-Y, because the same is used in
-           // Cmdline-mode and it's harmless when there is no selection.
-           if (c == Ctrl_Y && clip_star.state == SELECT_DONE)
+           do
            {
-               clip_copy_modeless_selection(TRUE);
-               c = K_IGNORE;
-           }
+               // Remember "got_int", if it is set vgetc() probably returns a
+               // CTRL-C, but we need to loop then.
+               had_got_int = got_int;
+
+               // Don't do mappings here, we put the character back in the
+               // typeahead buffer.
+               ++no_mapping;
+               ++allow_keys;
+
+               // Temporarily disable Recording. If Recording is active, the
+               // character will be recorded later, since it will be added to the
+               // typebuf after the loop
+               save_reg_recording = reg_recording;
+               save_scriptout = scriptout;
+               reg_recording = 0;
+               scriptout = NULL;
+               c = safe_vgetc();
+               if (had_got_int && !global_busy)
+                   got_int = FALSE;
+               --no_mapping;
+               --allow_keys;
+               reg_recording = save_reg_recording;
+               scriptout = save_scriptout;
+
+#ifdef FEAT_CLIPBOARD
+               // Strange way to allow copying (yanking) a modeless selection at
+               // the hit-enter prompt.  Use CTRL-Y, because the same is used in
+               // Cmdline-mode and it's harmless when there is no selection.
+               if (c == Ctrl_Y && clip_star.state == SELECT_DONE)
+               {
+                   clip_copy_modeless_selection(TRUE);
+                   c = K_IGNORE;
+               }
 #endif
 
-           /*
-            * Allow scrolling back in the messages.
-            * Also accept scroll-down commands when messages fill the screen,
-            * to avoid that typing one 'j' too many makes the messages
-            * disappear.
-            */
-           if (p_more && !p_cp)
-           {
-               if (c == 'b' || c == 'k' || c == 'u' || c == 'g'
-                                               || c == K_UP || c == K_PAGEUP)
+               /*
+               * Allow scrolling back in the messages.
+               * Also accept scroll-down commands when messages fill the screen,
+               * to avoid that typing one 'j' too many makes the messages
+               * disappear.
+               */
+               if (p_more && !p_cp)
                {
-                   if (msg_scrolled > Rows)
-                       // scroll back to show older messages
-                       do_more_prompt(c);
-                   else
+                   if (c == 'b' || c == 'k' || c == 'u' || c == 'g'
+                                                   || c == K_UP || c == K_PAGEUP)
                    {
-                       msg_didout = FALSE;
-                       c = K_IGNORE;
-                       msg_col =
+                       if (msg_scrolled > Rows)
+                           // scroll back to show older messages
+                           do_more_prompt(c);
+                       else
+                       {
+                           msg_didout = FALSE;
+                           c = K_IGNORE;
+                           msg_col =
 #ifdef FEAT_RIGHTLEFT
-                           cmdmsg_rl ? Columns - 1 :
+                               cmdmsg_rl ? Columns - 1 :
 #endif
-                           0;
-                   }
-                   if (quit_more)
-                   {
-                       c = CAR;                // just pretend CR was hit
-                       quit_more = FALSE;
-                       got_int = FALSE;
+                               0;
+                       }
+                       if (quit_more)
+                       {
+                           c = CAR;            // just pretend CR was hit
+                           quit_more = FALSE;
+                           got_int = FALSE;
+                       }
+                       else if (c != K_IGNORE)
+                       {
+                           c = K_IGNORE;
+                           hit_return_msg();
+                       }
                    }
-                   else if (c != K_IGNORE)
-                   {
+                   else if (msg_scrolled > Rows - 2
+                           && (c == 'j' || c == 'd' || c == 'f'
+                                           || c == K_DOWN || c == K_PAGEDOWN))
                        c = K_IGNORE;
-                       hit_return_msg();
-                   }
                }
-               else if (msg_scrolled > Rows - 2
-                        && (c == 'j' || c == 'd' || c == 'f'
-                                          || c == K_DOWN || c == K_PAGEDOWN))
-                   c = K_IGNORE;
-           }
-       } while ((had_got_int && c == Ctrl_C)
-                               || c == K_IGNORE
+           } while ((had_got_int && c == Ctrl_C)
+                                   || c == K_IGNORE
 #ifdef FEAT_GUI
-                               || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR
+                                   || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR
 #endif
-                               || c == K_LEFTDRAG   || c == K_LEFTRELEASE
-                               || c == K_MIDDLEDRAG || c == K_MIDDLERELEASE
-                               || c == K_RIGHTDRAG  || c == K_RIGHTRELEASE
-                               || c == K_MOUSELEFT  || c == K_MOUSERIGHT
-                               || c == K_MOUSEDOWN  || c == K_MOUSEUP
-                               || c == K_MOUSEMOVE
-                               || (!mouse_has(MOUSE_RETURN)
-                                   && mouse_row < msg_row
-                                   && (c == K_LEFTMOUSE
-                                       || c == K_MIDDLEMOUSE
-                                       || c == K_RIGHTMOUSE
-                                       || c == K_X1MOUSE
-                                       || c == K_X2MOUSE))
-                               );
-       ui_breakcheck();
-
-       // Avoid that the mouse-up event causes Visual mode to start.
-       if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE
-                                         || c == K_X1MOUSE || c == K_X2MOUSE)
-           (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0);
-       else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C)
+                                   || c == K_LEFTDRAG   || c == K_LEFTRELEASE
+                                   || c == K_MIDDLEDRAG || c == K_MIDDLERELEASE
+                                   || c == K_RIGHTDRAG  || c == K_RIGHTRELEASE
+                                   || c == K_MOUSELEFT  || c == K_MOUSERIGHT
+                                   || c == K_MOUSEDOWN  || c == K_MOUSEUP
+                                   || c == K_MOUSEMOVE
+                                   || (!mouse_has(MOUSE_RETURN)
+                                       && mouse_row < msg_row
+                                       && (c == K_LEFTMOUSE
+                                           || c == K_MIDDLEMOUSE
+                                           || c == K_RIGHTMOUSE
+                                           || c == K_X1MOUSE
+                                           || c == K_X2MOUSE))
+                                   );
+           ui_breakcheck();
+
+           // Avoid that the mouse-up event causes Visual mode to start.
+           if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE
+                                           || c == K_X1MOUSE || c == K_X2MOUSE)
+               (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0);
+           else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C)
+           {
+               // Put the character back in the typeahead buffer.  Don't use the
+               // stuff buffer, because lmaps wouldn't work.
+               ins_char_typebuf(vgetc_char, vgetc_mod_mask);
+               do_redraw = TRUE;           // need a redraw even though there is
+                                       // typeahead
+           }
+       }
+       else
        {
-           // Put the character back in the typeahead buffer.  Don't use the
-           // stuff buffer, because lmaps wouldn't work.
-           ins_char_typebuf(vgetc_char, vgetc_mod_mask);
-           do_redraw = TRUE;       // need a redraw even though there is
-                                   // typeahead
+           c = CAR;
+           // Wait to allow the user to verify the output.
+           do_sleep(msg_wait, TRUE);
        }
     }
     redir_off = FALSE;
index 31b00be7b0f2f11ca82e06cf2dba013294bc6e19..f069d0f4bc51bc539bf45c091b997f3381ba888e 100644 (file)
@@ -3864,31 +3864,6 @@ did_set_number_relativenumber(optset_T *args UNUSED)
     return NULL;
 }
 
-/*
- * Process the updated 'msghistory' option value.
- */
-    char *
-did_set_msghistory(optset_T *args UNUSED)
-{
-    char *errmsg = NULL;
-
-    // 'msghistory' must be positive
-    if (p_mhi < 0)
-    {
-       errmsg = e_argument_must_be_positive;
-       p_mhi = 0;
-    }
-    else if (p_mhi > 10000)
-    {
-       errmsg = e_invalid_argument;
-       p_mhi = 10000;
-    }
-
-    check_msg_hist();
-
-    return errmsg;
-}
-
 #if defined(FEAT_LINEBREAK) || defined(PROTO)
 /*
  * Process the new 'numberwidth' option value.
index 18a7c2ad565f5ddb96b7bfe981c3e2098e6b92d9..e747addf0b57e4284a3aca617cb68f73b5ec0b31 100644 (file)
@@ -775,6 +775,7 @@ EXTERN long p_mmt;          // 'maxmemtot'
 #ifdef FEAT_MENU
 EXTERN long    p_mis;          // 'menuitems'
 #endif
+EXTERN char_u  *p_meo;         // 'messagesopt'
 #ifdef FEAT_SPELL
 EXTERN char_u  *p_msm;         // 'mkspellmem'
 #endif
@@ -794,7 +795,6 @@ EXTERN int  p_mousemev;     // 'mousemoveevent'
 #endif
 EXTERN long    p_mouset;       // 'mousetime'
 EXTERN int     p_more;         // 'more'
-EXTERN long    p_mhi;          // 'msghistory'
 #ifdef FEAT_MZSCHEME
 EXTERN long    p_mzq;          // 'mzquantum
 # if defined(DYNAMIC_MZSCHEME)
index 2959232d0697f841e3af241ada12a25a125211e2..f42178b135ec7f7f53b5f9fac072b14f6d65a131 100644 (file)
@@ -1695,6 +1695,9 @@ static struct vimoption options[] =
     {"mesg",       NULL,   P_BOOL|P_VI_DEF,
                            (char_u *)NULL, PV_NONE, NULL, NULL,
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
+    {"messagesopt","mopt",  P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_COLON|P_NODUP,
+                           (char_u *)&p_meo, PV_NONE, did_set_messagesopt, expand_set_messagesopt,
+                           {(char_u *)"hit-enter,history:500", (char_u *)NULL} SCTX_INIT},
     {"mkspellmem",  "msm",  P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
 #ifdef FEAT_SPELL
                            (char_u *)&p_msm, PV_NONE, did_set_mkspellmem, NULL,
@@ -1778,9 +1781,6 @@ static struct vimoption options[] =
     {"mousetime",   "mouset",  P_NUM|P_VI_DEF,
                            (char_u *)&p_mouset, PV_NONE, NULL, NULL,
                            {(char_u *)500L, (char_u *)0L} SCTX_INIT},
-    {"msghistory","mhi",    P_NUM|P_VI_DEF,
-                           (char_u *)&p_mhi, PV_NONE, did_set_msghistory, NULL,
-                           {(char_u *)500L, (char_u *)0L} SCTX_INIT},
     {"mzquantum",  "mzq",   P_NUM,
 #ifdef FEAT_MZSCHEME
                            (char_u *)&p_mzq, PV_NONE, did_set_mzquantum, NULL,
index d7cb38a3aad21a76c7e02da8e89352789406a411..08b235056cd1126c6e2e857d34f03d18fcddf84d 100644 (file)
@@ -3040,6 +3040,30 @@ did_set_matchpairs(optset_T *args)
     return NULL;
 }
 
+/*
+ * Process the updated 'messagesopt' option value.
+ */
+    char *
+did_set_messagesopt(optset_T *args UNUSED)
+{
+    if (messagesopt_changed() == FAIL)
+       return e_invalid_argument;
+
+    return NULL;
+}
+
+    int
+expand_set_messagesopt(optexpand_T *args, int *numMatches, char_u ***matches)
+{
+    static char *(p_meo_values[]) = {"hit-enter", "wait:", "history:", NULL};
+    return expand_set_opt_string(
+           args,
+           p_meo_values,
+           ARRAY_LENGTH(p_meo_values) - 1,
+           numMatches,
+           matches);
+}
+
 #if defined(FEAT_SPELL) || defined(PROTO)
 /*
  * The 'mkspellmem' option is changed.
index 1c11444fcbdededf3afe1137cc1e5a3e1bb7d11d..34b381866f5909030b6d12a7403c58fa7166f00a 100644 (file)
@@ -18,7 +18,7 @@ void emsg_namelen(char *msg, char_u *name, int len);
 char *msg_trunc_attr(char *s, int force, int attr);
 char_u *msg_may_trunc(int force, char_u *s);
 int delete_first_msg(void);
-void check_msg_hist(void);
+int messagesopt_changed(void);
 void ex_messages(exarg_T *eap);
 void msg_end_prompt(void);
 void wait_return(int redraw);
index 8aa49c01867ea74f5e62e2eb3e7598b6582f11ab..83f32aad618da65c2df0cf83114e2ccedf211b19 100644 (file)
@@ -56,7 +56,6 @@ char *did_set_maxcombine(optset_T *args);
 char *did_set_modifiable(optset_T *args);
 char *did_set_modified(optset_T *args);
 char *did_set_mousehide(optset_T *args);
-char *did_set_msghistory(optset_T *args);
 char *did_set_number_relativenumber(optset_T *args);
 char *did_set_numberwidth(optset_T *args);
 char *did_set_paste(optset_T *args);
index 561faa86c118065fa99fc0c0a4ea381db68ac81c..75a8d73b63b1021a33d22986ff5be107447dbdbc 100644 (file)
@@ -111,6 +111,8 @@ int expand_set_keyprotocol(optexpand_T *args, int *numMatches, char_u ***matches
 char *did_set_lispoptions(optset_T *args);
 int expand_set_lispoptions(optexpand_T *args, int *numMatches, char_u ***matches);
 char *did_set_matchpairs(optset_T *args);
+char *did_set_messagesopt(optset_T *args);
+int expand_set_messagesopt(optexpand_T *args, int *numMatches, char_u ***matches);
 char *did_set_mkspellmem(optset_T *args);
 char *did_set_mouse(optset_T *args);
 int expand_set_mouse(optexpand_T *args, int *numMatches, char_u ***matches);
index ac9401ecad4e2900654861d6545c0714c5dcc3a0..8bfa57d646dd4289a4d139efbfc2a910701ed78d 100644 (file)
@@ -85,7 +85,6 @@ let test_values = {
       \ 'imstyle': [[0, 1], [-1, 2, 999]],
       \ 'lines': [[2, 24, 1000], [-1, 0, 1]],
       \ 'linespace': [[-1, 0, 2, 4, 999], ['']],
-      \ 'msghistory': [[0, 1, 100, 10000], [-1, 10001]],
       \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
       \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
       \ 'report': [[0, 1, 2, 9999], [-1]],
@@ -233,6 +232,11 @@ let test_values = {
       \                'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'],
       \                ['xxx', 'eol:']],
       \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
+      \ 'messagesopt': [['hit-enter,history:1', 'hit-enter,history:10000',
+      \                'history:100,wait:100', 'history:0,wait:0',
+      \                'hit-enter,history:1,wait:1'],
+      \                ['xxx', 'history:500', 'hit-enter,history:-1',
+      \                'hit-enter,history:10001', 'hit-enter']],
       \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']],
       \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'],
       \                ['xxx', 'n,v,i']],
index 2fbce74ce0f210c443f1bec95edfa61715b065a7..6d4fdd781167f3e2ed04e095da23e2d11d0ec936 100644 (file)
@@ -4032,30 +4032,4 @@ func Test_cd_bslash_completion_windows()
   let &shellslash = save_shellslash
 endfunc
 
-func Test_msghistory()
-  " After setting 'msghistory' to 2 and outputting a message 4 times with
-  " :echomsg, is the number of output lines of :messages 2?
-  set msghistory=2
-  echomsg 'foo'
-  echomsg 'bar'
-  echomsg 'baz'
-  echomsg 'foobar'
-  call assert_equal(['baz', 'foobar'], GetMessages())
-
-  " When the number of messages is 10 and 'msghistory' is changed to 5, is the
-  " number of output lines of :messages 5?
-  set msghistory=10
-  for num in range(1, 10)
-    echomsg num
-  endfor
-  set msghistory=5
-  call assert_equal(5, len(GetMessages()))
-
-  " Check empty list
-  set msghistory=0
-  call assert_true(empty(GetMessages()))
-
-  set msghistory&
-endfunc
-
 " vim: shiftwidth=2 sts=2 expandtab
index 46f336834614f6200844210dee25cde17edecee9..1b5f809c78194ebe78fc7b65a0d8519bfc55fee7 100644 (file)
@@ -211,6 +211,7 @@ endfunc
 " Test more-prompt (see :help more-prompt).
 func Test_message_more()
   CheckRunVimInTerminal
+
   let buf = RunVimInTerminal('', {'rows': 6})
   call term_sendkeys(buf, ":call setline(1, range(1, 100))\n")
 
@@ -657,5 +658,50 @@ func Test_echowin_showmode()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_messagesopt_history()
+  " After setting 'messagesopt' "history" to 2 and outputting a message 4 times
+  " with :echomsg, is the number of output lines of :messages 2?
+  set messagesopt=hit-enter,history:2
+  echomsg 'foo'
+  echomsg 'bar'
+  echomsg 'baz'
+  echomsg 'foobar'
+  call assert_equal(['baz', 'foobar'], GetMessages())
+
+  " When the number of messages is 10 and 'messagesopt' "history" is changed to
+  " 5, is the number of output lines of :messages 5?
+  set messagesopt=hit-enter,history:10
+  for num in range(1, 10)
+    echomsg num
+  endfor
+  set messagesopt=hit-enter,history:5
+  call assert_equal(5, len(GetMessages()))
+
+  " Check empty list
+  set messagesopt=hit-enter,history:0
+  call assert_true(empty(GetMessages()))
+
+  set messagesopt&
+endfunc
+
+func Test_messagesopt_wait()
+  CheckRunVimInTerminal
+
+  let buf = RunVimInTerminal('', {'rows': 6, 'cols': 45})
+  call term_sendkeys(buf, ":set cmdheight=1\n")
+
+  " Check hit-enter prompt
+  call term_sendkeys(buf, ":set messagesopt=hit-enter,history:500\n")
+  call term_sendkeys(buf, ":echo 'foo' | echo 'bar' echo 'baz'\n")
+  call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
+
+  " Check no hit-enter prompt when "wait:" is set
+  call term_sendkeys(buf, ":set messagesopt=wait:100,history:500\n")
+  call term_sendkeys(buf, ":echo 'foo' | echo 'bar' echo 'baz'\n")
+  call WaitForAssert({-> assert_equal('                           0,0-1         All', term_getline(buf, 6))})
+
+  " clean up
+  call StopVimInTerminal(buf)
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
index cd66cdfaeb2d0b8367e5c9d3fe6ea5b4797a55eb..34efbb527a54bdf544f097ac6b7b63694998e9c7 100644 (file)
@@ -633,6 +633,10 @@ func Test_set_completion_string_values()
   call feedkeys(":set hl=8b i\<Left>\<Left>\<Tab>\<C-B>\"\<CR>", 'xt')
   call assert_equal("\"set hl=8bi i", @:)
 
+  " messagesopt
+  call assert_equal(['history:', 'hit-enter', 'wait:'],
+        \ getcompletion('set messagesopt+=', 'cmdline')->sort())
+
   "
   " Test flag lists
   "
@@ -732,7 +736,6 @@ func Test_set_option_errors()
   call assert_fails('set backupcopy=', 'E474:')
   call assert_fails('set regexpengine=3', 'E474:')
   call assert_fails('set history=10001', 'E474:')
-  call assert_fails('set msghistory=10001', 'E474:')
   call assert_fails('set numberwidth=21', 'E474:')
   call assert_fails('set colorcolumn=-a', 'E474:')
   call assert_fails('set colorcolumn=a', 'E474:')
@@ -746,7 +749,6 @@ func Test_set_option_errors()
   endif
   call assert_fails('set helpheight=-1', 'E487:')
   call assert_fails('set history=-1', 'E487:')
-  call assert_fails('set msghistory=-1', 'E487:')
   call assert_fails('set report=-1', 'E487:')
   call assert_fails('set shiftwidth=-1', 'E487:')
   call assert_fails('set sidescroll=-1', 'E487:')
@@ -2509,6 +2511,7 @@ func Test_string_option_revert_on_failure()
         \ ['lispoptions', 'expr:1', 'a123'],
         \ ['listchars', 'tab:->', 'tab:'],
         \ ['matchpairs', '<:>', '<:'],
+        \ ['messagesopt', 'hit-enter,history:100', 'a123'],
         \ ['mkspellmem', '100000,1000,100', '100000'],
         \ ['mouse', 'nvi', 'z'],
         \ ['mousemodel', 'extend', 'a123'],
index bdd605317fbe54530e0e67418bcb834cf7872167..4cb67efba95a12ad58b3bd77cd5b8e8676bc878d 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    908,
 /**/
     907,
 /**/