changeset 39878:d90eb1d4b881

(file_name_completion): Ignore a candidate directory if it matches an element in completion-ignored-extensions that ends in a slash. (syms_of_dired) <completion-ignored-extensions>: Mention the above feature in the doc string. (Ffile_name_completion): Ditto.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 13 Oct 2001 11:57:52 +0000
parents 2ebf10c960af
children fba70cf81a87
files src/dired.c
diffstat 1 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/dired.c	Sat Oct 13 11:37:44 2001 +0000
+++ b/src/dired.c	Sat Oct 13 11:57:52 2001 +0000
@@ -404,7 +404,10 @@
 Returns the longest string\n\
 common to all file names in DIRECTORY that start with FILE.\n\
 If there is only one and FILE matches it exactly, returns t.\n\
-Returns nil if DIR contains no name starting with FILE.")
+Returns nil if DIR contains no name starting with FILE.\n\
+\n\
+This function ignores some of the possible completions as\n\
+determined by the variable `completion-ignored-extensions', which see.")
   (file, directory)
      Lisp_Object file, directory;
 {
@@ -555,6 +558,31 @@
 		 actually in the way in a directory contains only one file.  */
 	      if (!passcount && TRIVIAL_DIRECTORY_ENTRY (dp->d_name))
 		continue;
+	      if (!passcount && len > XSTRING (encoded_file)->size)
+		/* Ignore directories if they match an element of
+		   completion-ignored-extensions which ends in a slash.  */
+		for (tem = Vcompletion_ignored_extensions;
+		     CONSP (tem); tem = XCDR (tem))
+		  {
+		    int elt_len;
+
+		    elt = XCAR (tem);
+		    if (!STRINGP (elt))
+		      continue;
+		    elt_len = XSTRING (elt)->size - 1; /* -1 for trailing / */
+		    if (elt_len == 0)
+		      continue;
+		    p1 = XSTRING (elt)->data;
+		    if (p1[elt_len] != '/')
+		      continue;
+		    skip = len - elt_len;
+		    if (skip < 0)
+		      continue;
+
+		    if (0 <= scmp (dp->d_name + skip, p1, elt_len))
+		      continue;
+		    break;
+		  }
 	    }
 	  else
             {
@@ -952,6 +980,8 @@
 
   DEFVAR_LISP ("completion-ignored-extensions", &Vcompletion_ignored_extensions,
     "*Completion ignores filenames ending in any string in this list.\n\
+Directories are ignored if they match any string in this list which\n\
+ends in a slash.\n\
 This variable does not affect lists of possible completions,\n\
 but does affect the commands that actually do completions.");
   Vcompletion_ignored_extensions = Qnil;