diff options
| author | Brian Fox | 1993-09-22 18:25:03 +0000 |
|---|---|---|
| committer | Brian Fox | 1993-09-22 18:25:03 +0000 |
| commit | 97e98a56769de54b19b95de880b777b185bb2ca6 (patch) | |
| tree | f88713be6b1f386a60059f109625583f82251bc2 /src | |
| parent | 2554751d80f1817ad97364cd99a6c19d92a895c3 (diff) | |
| download | emacs-97e98a56769de54b19b95de880b777b185bb2ca6.tar.gz emacs-97e98a56769de54b19b95de880b777b185bb2ca6.zip | |
(file_name_completion): Install case-preserving changes from Emacs 18
for completion_ignore_case.
(completion_ignore_case): Declare.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dired.c | 36 |
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 | ||
| 83 | extern int completion_ignore_case; | ||
| 83 | extern Lisp_Object Ffind_file_name_handler (); | 84 | extern Lisp_Object Ffind_file_name_handler (); |
| 84 | 85 | ||
| 85 | Lisp_Object Vcompletion_ignored_extensions; | 86 | Lisp_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 | } |