aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2001-10-13 11:57:52 +0000
committerEli Zaretskii2001-10-13 11:57:52 +0000
commitd013f29b1a8c1474a12219f84dbd9d4395ed4c44 (patch)
tree9165afdd8bb806f084b4de916c878bc63c3a2f13 /src
parent8eaa3bc7cbbe7d5d45d14ec76f9ee2437a5da04a (diff)
downloademacs-d013f29b1a8c1474a12219f84dbd9d4395ed4c44.tar.gz
emacs-d013f29b1a8c1474a12219f84dbd9d4395ed4c44.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/dired.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/dired.c b/src/dired.c
index 74d0bab6a6c..0952e6173b5 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -404,7 +404,10 @@ DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion,
404Returns the longest string\n\ 404Returns the longest string\n\
405common to all file names in DIRECTORY that start with FILE.\n\ 405common to all file names in DIRECTORY that start with FILE.\n\
406If there is only one and FILE matches it exactly, returns t.\n\ 406If there is only one and FILE matches it exactly, returns t.\n\
407Returns nil if DIR contains no name starting with FILE.") 407Returns nil if DIR contains no name starting with FILE.\n\
408\n\
409This function ignores some of the possible completions as\n\
410determined by the variable `completion-ignored-extensions', which see.")
408 (file, directory) 411 (file, directory)
409 Lisp_Object file, directory; 412 Lisp_Object file, directory;
410{ 413{
@@ -555,6 +558,31 @@ file_name_completion (file, dirname, all_flag, ver_flag)
555 actually in the way in a directory contains only one file. */ 558 actually in the way in a directory contains only one file. */
556 if (!passcount && TRIVIAL_DIRECTORY_ENTRY (dp->d_name)) 559 if (!passcount && TRIVIAL_DIRECTORY_ENTRY (dp->d_name))
557 continue; 560 continue;
561 if (!passcount && len > XSTRING (encoded_file)->size)
562 /* Ignore directories if they match an element of
563 completion-ignored-extensions which ends in a slash. */
564 for (tem = Vcompletion_ignored_extensions;
565 CONSP (tem); tem = XCDR (tem))
566 {
567 int elt_len;
568
569 elt = XCAR (tem);
570 if (!STRINGP (elt))
571 continue;
572 elt_len = XSTRING (elt)->size - 1; /* -1 for trailing / */
573 if (elt_len == 0)
574 continue;
575 p1 = XSTRING (elt)->data;
576 if (p1[elt_len] != '/')
577 continue;
578 skip = len - elt_len;
579 if (skip < 0)
580 continue;
581
582 if (0 <= scmp (dp->d_name + skip, p1, elt_len))
583 continue;
584 break;
585 }
558 } 586 }
559 else 587 else
560 { 588 {
@@ -952,6 +980,8 @@ syms_of_dired ()
952 980
953 DEFVAR_LISP ("completion-ignored-extensions", &Vcompletion_ignored_extensions, 981 DEFVAR_LISP ("completion-ignored-extensions", &Vcompletion_ignored_extensions,
954 "*Completion ignores filenames ending in any string in this list.\n\ 982 "*Completion ignores filenames ending in any string in this list.\n\
983Directories are ignored if they match any string in this list which\n\
984ends in a slash.\n\
955This variable does not affect lists of possible completions,\n\ 985This variable does not affect lists of possible completions,\n\
956but does affect the commands that actually do completions."); 986but does affect the commands that actually do completions.");
957 Vcompletion_ignored_extensions = Qnil; 987 Vcompletion_ignored_extensions = Qnil;