all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* history-delete-duplicates and read-file-name
@ 2004-11-08 12:40 Piet van Oostrum
  2004-12-20  8:17 ` Piet van Oostrum
  0 siblings, 1 reply; 2+ messages in thread
From: Piet van Oostrum @ 2004-11-08 12:40 UTC (permalink / raw)


The variable history-delete-duplicates, when non-nil, is supposed to
suppress duplicates in minibuffer reads with history. However, there is one
occasion where it fails:

Calling read-file-name with a default that is somewhere in the
file-name-history but not the most recent entry, and selecting the default,
causes read-file-name to add the selected filename, without removing the
existing entry. This is because it adds the new entry after read_minibuf
has finished. It should also check history-delete-duplicates.
-- 
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum@hccnet.nl

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: history-delete-duplicates and read-file-name
  2004-11-08 12:40 history-delete-duplicates and read-file-name Piet van Oostrum
@ 2004-12-20  8:17 ` Piet van Oostrum
  0 siblings, 0 replies; 2+ messages in thread
From: Piet van Oostrum @ 2004-12-20  8:17 UTC (permalink / raw)


>>>>> Piet van Oostrum <piet@cs.uu.nl> (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  <piet@cs.uu.nl>
+
+	* fileio.c (Fread_file_name): Delele duplicates in
+	file-name-history when history_delete_duplicates is true.
+
 2004-12-18  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* macterm.c (endif, x_font_name_to_mac_font_name): Use

-- 
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum@hccnet.nl

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-20  8:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-08 12:40 history-delete-duplicates and read-file-name Piet van Oostrum
2004-12-20  8:17 ` Piet van Oostrum

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.