-*options.txt* For Vim version 9.1. Last change: 2024 Nov 14
+*options.txt* For Vim version 9.1. Last change: 2024 Nov 24
VIM REFERENCE MANUAL by Bram Moolenaar
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)
if (msg_hist_off || msg_silent != 0)
return;
- // Don't let the message history get too big
- while (msg_hist_len > p_mhi)
- (void)delete_first_msg();
-
// allocate an entry and add the message at the end of the history
p = ALLOC_ONE(struct msg_hist);
if (p == NULL)
if (first_msg_hist == NULL)
first_msg_hist = last_msg_hist;
++msg_hist_len;
+
+ check_msg_hist();
}
/*
return OK;
}
+ void
+check_msg_hist(void)
+{
+ // Don't let the message history get too big
+ while (msg_hist_len > 0 && msg_hist_len > p_mhi)
+ (void)delete_first_msg();
+}
+
/*
* ":messages" command.
*/
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.
errmsg = e_invalid_argument;
p_hi = 10000;
}
- 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;
- }
if (p_re < 0 || p_re > 2)
{
errmsg = e_invalid_argument;
(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, NULL, NULL,
+ (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 *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);
void ex_messages(exarg_T *eap);
void msg_end_prompt(void);
void wait_return(int redraw);
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);
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 883,
/**/
882,
/**/