From 75fa7206f08d2b34f8e53c681a2423abe12e12c3 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Tue, 21 Dec 2004 11:33:16 +0000 Subject: [PATCH] (Fread_file_name): Delete duplicates in file-name-history when history_delete_duplicates is true. --- src/fileio.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index aa37c296eb3..d58c49d2825 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -228,6 +228,8 @@ extern int minibuf_level; extern int minibuffer_auto_raise; +extern int history_delete_duplicates; + /* These variables describe handlers that have "already" had a chance to handle the current operation. @@ -6383,7 +6385,13 @@ and `read-file-name-function'. */) if (replace_in_history) /* Replace what Fcompleting_read added to the history with what we will actually return. */ - XSETCAR (Fsymbol_value (Qfile_name_history), double_dollars (val)); + { + Lisp_Object val1 = double_dollars (val); + tem = Fsymbol_value (Qfile_name_history); + if (history_delete_duplicates) + XSETCDR (tem, Fdelete (val1, XCDR(tem))); + XSETCAR (tem, val1); + } else if (add_to_history) { /* Add the value to the history--but not if it matches @@ -6391,8 +6399,10 @@ and `read-file-name-function'. */) Lisp_Object val1 = double_dollars (val); tem = Fsymbol_value (Qfile_name_history); if (! CONSP (tem) || NILP (Fequal (XCAR (tem), val1))) - Fset (Qfile_name_history, - Fcons (val1, tem)); + { + if (history_delete_duplicates) tem = Fdelete (val1, tem); + Fset (Qfile_name_history, Fcons (val1, tem)); + } } return val; -- 2.39.5