# HG changeset patch # User Eli Zaretskii # Date 1002974272 0 # Node ID d90eb1d4b881f4277cee19a9e16f4abea8b368a6 # Parent 2ebf10c960af9859d385a6f8d99ce16862358e77 (file_name_completion): Ignore a candidate directory if it matches an element in completion-ignored-extensions that ends in a slash. (syms_of_dired) : Mention the above feature in the doc string. (Ffile_name_completion): Ditto. diff -r 2ebf10c960af -r d90eb1d4b881 src/dired.c --- 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;