# HG changeset patch # User Richard M. Stallman # Date 841293338 0 # Node ID b791ab74ff3046fe4941bab4070e0a32d324469a # Parent ceb8d03a04f6fdbba3cb3e4c67bf06eeff349f1b (Vhistory_length, Qhistory_length): New variables. (syms_of_minibuf): Register and initialise these. (read_minibuf): Truncate history list if needed. diff -r ceb8d03a04f6 -r b791ab74ff30 src/minibuf.c --- a/src/minibuf.c Thu Aug 29 03:50:02 1996 +0000 +++ b/src/minibuf.c Thu Aug 29 04:35:38 1996 +0000 @@ -46,9 +46,12 @@ /* Depth in minibuffer invocations. */ int minibuf_level; -/* Nonzero means display completion help for invalid input */ +/* Nonzero means display completion help for invalid input. */ int auto_help; +/* The maximum length of a minibuffer history. */ +Lisp_Object Qhistory_length, Vhistory_length; + /* Fread_minibuffer leaves the input here as a string. */ Lisp_Object last_minibuf_string; @@ -356,8 +359,27 @@ if (NILP (histval) || (CONSP (histval) && NILP (Fequal (last_minibuf_string, Fcar (histval))))) - Fset (Vminibuffer_history_variable, - Fcons (last_minibuf_string, histval)); + { + Lisp_Object length; + + histval = Fcons (last_minibuf_string, histval); + Fset (Vminibuffer_history_variable, histval); + + /* Truncate if requested. */ + length = Fget (Vminibuffer_history_variable, Qhistory_length); + if (NILP (length)) length = Vhistory_length; + if (INTEGERP (length)) { + if (XINT (length) <= 0) + Fset (Vminibuffer_history_variable, Qnil); + else + { + Lisp_Object temp; + + temp = Fnthcdr (Fsub1 (length), histval); + if (CONSP (temp)) Fsetcdr (temp, Qnil); + } + } + } } /* If Lisp form desired instead of string, parse it. */ @@ -1794,6 +1816,9 @@ Qminibuffer_exit_hook = intern ("minibuffer-exit-hook"); staticpro (&Qminibuffer_exit_hook); + Qhistory_length = intern ("history-length"); + staticpro (&Qhistory_length); + DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook, "Normal hook run just after entry to minibuffer."); Vminibuffer_setup_hook = Qnil; @@ -1802,6 +1827,13 @@ "Normal hook run just after exit from minibuffer."); Vminibuffer_exit_hook = Qnil; + DEFVAR_LISP ("history-length", &Vhistory_length, + "*Maximum length for history lists before truncation takes place.\n\ +A number means that length; t means infinite. Truncation takes place\n\ +just after a new element is inserted. Setting the history-length\n\ +property of a history variable overrides this default."); + XSETFASTINT (Vhistory_length, 30); + DEFVAR_BOOL ("completion-auto-help", &auto_help, "*Non-nil means automatically provide help for invalid completion input."); auto_help = 1;