aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dired.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/dired.c b/src/dired.c
index ff51345183b..410729fe3dc 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -80,6 +80,7 @@ extern struct re_pattern_buffer searchbuf;
80#define lstat stat 80#define lstat stat
81#endif 81#endif
82 82
83extern int completion_ignore_case;
83extern Lisp_Object Ffind_file_name_handler (); 84extern Lisp_Object Ffind_file_name_handler ();
84 85
85Lisp_Object Vcompletion_ignored_extensions; 86Lisp_Object Vcompletion_ignored_extensions;
@@ -392,14 +393,43 @@ file_name_completion (file, dirname, all_flag, ver_flag)
392 matchsize = scmp(p1, p2, compare); 393 matchsize = scmp(p1, p2, compare);
393 if (matchsize < 0) 394 if (matchsize < 0)
394 matchsize = compare; 395 matchsize = compare;
395 /* If this dirname all matches, 396 if (completion_ignore_case)
396 see if implicit following slash does too. */ 397 {
398 /* If this is an exact match except for case,
399 use it as the best match rather than one that is not
400 an exact match. This way, we get the case pattern
401 of the actual match. */
402 if ((matchsize == len
403 && matchsize + !!directoryp
404 < XSTRING (bestmatch)->size)
405 ||
406 /* If there is no exact match ignoring case,
407 prefer a match that does not change the case
408 of the input. */
409 (((matchsize == len)
410 ==
411 (matchsize + !!directoryp
412 == XSTRING (bestmatch)->size))
413 /* If there is more than one exact match aside from
414 case, and one of them is exact including case,
415 prefer that one. */
416 && !bcmp (p2, XSTRING (file)->data, XSTRING (file)->size)
417 && bcmp (p1, XSTRING (file)->data, XSTRING (file)->size)))
418 {
419 bestmatch = make_string (dp->d_name, len);
420 if (directoryp)
421 bestmatch = Ffile_name_as_directory (bestmatch);
422 }
423 }
424
425 /* If this dirname all matches, see if implicit following
426 slash does too. */
397 if (directoryp 427 if (directoryp
398 && compare == matchsize 428 && compare == matchsize
399 && bestmatchsize > matchsize 429 && bestmatchsize > matchsize
400 && p1[matchsize] == '/') 430 && p1[matchsize] == '/')
401 matchsize++; 431 matchsize++;
402 bestmatchsize = min (matchsize, bestmatchsize); 432 bestmatchsize = matchsize;
403 } 433 }
404 } 434 }
405 } 435 }