From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Piet van Oostrum Newsgroups: gmane.emacs.devel Subject: Re: history-delete-duplicates and read-file-name Date: Mon, 20 Dec 2004 09:17:09 +0100 Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1103530715 20532 80.91.229.6 (20 Dec 2004 08:18:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 20 Dec 2004 08:18:35 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 20 09:18:26 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CgIkM-0003Pi-00 for ; Mon, 20 Dec 2004 09:18:26 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CgIun-00060t-BL for ged-emacs-devel@m.gmane.org; Mon, 20 Dec 2004 03:29:13 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CgIu7-0005px-Jz for emacs-devel@gnu.org; Mon, 20 Dec 2004 03:28:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CgIu4-0005mH-D4 for emacs-devel@gnu.org; Mon, 20 Dec 2004 03:28:30 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CgIu3-0005kZ-0r for emacs-devel@gnu.org; Mon, 20 Dec 2004 03:28:27 -0500 Original-Received: from [213.116.162.247] (helo=ordesa.cs.uu.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CgIjA-0000i9-I6 for emacs-devel@gnu.org; Mon, 20 Dec 2004 03:17:13 -0500 Original-Received: from ordesa.local (localhost [127.0.0.1]) by ordesa.cs.uu.nl (Postfix) with ESMTP id 8184B279180 for ; Mon, 20 Dec 2004 09:17:13 +0100 (CET) X-Mailer: emacs 21.3.50.20 (via feedmail 8 I) Original-To: emacs-devel@gnu.org In-Reply-To: (Piet van Oostrum's message of "Mon, 08 Nov 2004 13:40:55 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (darwin) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:31282 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:31282 >>>>> Piet van Oostrum (PvO) wrote: PvO> The variable history-delete-duplicates, when non-nil, is supposed to PvO> suppress duplicates in minibuffer reads with history. However, there is one PvO> occasion where it fails: PvO> Calling read-file-name with a default that is somewhere in the PvO> file-name-history but not the most recent entry, and selecting the default, PvO> causes read-file-name to add the selected filename, without removing the PvO> existing entry. This is because it adds the new entry after read_minibuf PvO> has finished. It should also check history-delete-duplicates. Here is a patch. Please check it and someone check it in if you agree it is OK. I don't think I have CVS privileges. I have signed copyright papers. Index: src/fileio.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/fileio.c,v retrieving revision 1.521 diff -u -r1.521 fileio.c --- src/fileio.c 7 Nov 2004 11:07:21 -0000 1.521 +++ src/fileio.c 20 Dec 2004 08:03:48 -0000 @@ -6196,6 +6196,8 @@ return Qnil; } +extern int history_delete_duplicates; + DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0, doc: /* Read file name, prompting with PROMPT and completing in directory DIR. Value is not expanded---you must call `expand-file-name' yourself. @@ -6383,7 +6385,13 @@ 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,11 @@ 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; Index: src/ChangeLog =================================================================== RCS file: /cvsroot/emacs/emacs/src/ChangeLog,v retrieving revision 1.4101 diff -u -r1.4101 ChangeLog --- src/ChangeLog 18 Dec 2004 16:36:29 -0000 1.4101 +++ src/ChangeLog 20 Dec 2004 08:09:28 -0000 @@ -1,3 +1,8 @@ +2004-12-20 Piet van Oostrum + + * fileio.c (Fread_file_name): Delele duplicates in + file-name-history when history_delete_duplicates is true. + 2004-12-18 YAMAMOTO Mitsuharu * macterm.c (endif, x_font_name_to_mac_font_name): Use -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum@hccnet.nl