diff options
| author | Eli Zaretskii | 2019-11-09 21:56:30 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-11-09 21:56:30 +0200 |
| commit | f2019fc676c2206bbdc53855e3bc4f1086676d3d (patch) | |
| tree | 5396d1b08da9f2592ac76fffee3b5bd93b19b70c /src | |
| parent | a1a724d73afae87b8c4daa2d64382be06fa37d0e (diff) | |
| download | emacs-f2019fc676c2206bbdc53855e3bc4f1086676d3d.tar.gz emacs-f2019fc676c2206bbdc53855e3bc4f1086676d3d.zip | |
Fix case-insensitive completion of buffer names
* test/src/minibuf-tests.el (test-try-completion-ignore-case):
New test, suggested by Stefan Monnier <monnier@iro.umontreal.ca>.
* src/minibuf.c (Ftry_completion): Don't treat strings that
are identical but for the case as if they were identical for
the purposes of not counting the same string twice. This
fixes case-insensitive completion when all the candidates are
identical but for the letter-case. (Bug#11339)
Diffstat (limited to 'src')
| -rw-r--r-- | src/minibuf.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/minibuf.c b/src/minibuf.c index f6cf47f1f28..1e87c5044af 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -1323,13 +1323,13 @@ is used to further constrain the set of candidates. */) | |||
| 1323 | else | 1323 | else |
| 1324 | { | 1324 | { |
| 1325 | compare = min (bestmatchsize, SCHARS (eltstring)); | 1325 | compare = min (bestmatchsize, SCHARS (eltstring)); |
| 1326 | tem = Fcompare_strings (bestmatch, zero, | 1326 | Lisp_Object lcompare = make_fixnum (compare); |
| 1327 | make_fixnum (compare), | 1327 | tem = Fcompare_strings (bestmatch, zero, lcompare, |
| 1328 | eltstring, zero, | 1328 | eltstring, zero, lcompare, |
| 1329 | make_fixnum (compare), | ||
| 1330 | completion_ignore_case ? Qt : Qnil); | 1329 | completion_ignore_case ? Qt : Qnil); |
| 1331 | matchsize = EQ (tem, Qt) ? compare : eabs (XFIXNUM (tem)) - 1; | 1330 | matchsize = EQ (tem, Qt) ? compare : eabs (XFIXNUM (tem)) - 1; |
| 1332 | 1331 | ||
| 1332 | Lisp_Object old_bestmatch = bestmatch; | ||
| 1333 | if (completion_ignore_case) | 1333 | if (completion_ignore_case) |
| 1334 | { | 1334 | { |
| 1335 | /* If this is an exact match except for case, | 1335 | /* If this is an exact match except for case, |
| @@ -1363,7 +1363,12 @@ is used to further constrain the set of candidates. */) | |||
| 1363 | bestmatch = eltstring; | 1363 | bestmatch = eltstring; |
| 1364 | } | 1364 | } |
| 1365 | if (bestmatchsize != SCHARS (eltstring) | 1365 | if (bestmatchsize != SCHARS (eltstring) |
| 1366 | || bestmatchsize != matchsize) | 1366 | || bestmatchsize != matchsize |
| 1367 | || (completion_ignore_case | ||
| 1368 | && !EQ (Fcompare_strings (old_bestmatch, zero, lcompare, | ||
| 1369 | eltstring, zero, lcompare, | ||
| 1370 | Qnil), | ||
| 1371 | Qt))) | ||
| 1367 | /* Don't count the same string multiple times. */ | 1372 | /* Don't count the same string multiple times. */ |
| 1368 | matchcount += matchcount <= 1; | 1373 | matchcount += matchcount <= 1; |
| 1369 | bestmatchsize = matchsize; | 1374 | bestmatchsize = matchsize; |