diff options
| author | Stefan Monnier | 2010-05-30 10:17:31 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2010-05-30 10:17:31 -0400 |
| commit | 5feec8cac13043a08abf3abb396911b042275fea (patch) | |
| tree | 50f7e74956c20861e7bb2fde477c14213ed42b07 | |
| parent | 2b94133fee8a97f556a61feffd2debfdb3d82f27 (diff) | |
| download | emacs-5feec8cac13043a08abf3abb396911b042275fea.tar.gz emacs-5feec8cac13043a08abf3abb396911b042275fea.zip | |
* lisp/minibuffer.el (completion-file-name-table): Don't return a boundary
past the end of `string'.
(completion--file-name-table): Delegate to completion-file-name-table
for the `boundaries' case.
Fixes: debbugs:6299
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 42 |
2 files changed, 32 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 021d5a07421..e335ee5c344 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2010-05-30 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * minibuffer.el (completion-file-name-table): Don't return a boundary | ||
| 4 | past the end of `string' (bug#6299). | ||
| 5 | (completion--file-name-table): Delegate to completion-file-name-table | ||
| 6 | for the `boundaries' case. | ||
| 7 | |||
| 1 | 2010-05-30 Juanma Barranquero <lekktu@gmail.com> | 8 | 2010-05-30 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 9 | ||
| 3 | * emulation/cua-base.el: Recognize `right-char' and `left-char' as | 10 | * emulation/cua-base.el: Recognize `right-char' and `left-char' as |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index b1ecae3801d..646b773caf2 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -1342,12 +1342,19 @@ same as `substitute-in-file-name'." | |||
| 1342 | ((eq (car-safe action) 'boundaries) | 1342 | ((eq (car-safe action) 'boundaries) |
| 1343 | (let ((start (length (file-name-directory string))) | 1343 | (let ((start (length (file-name-directory string))) |
| 1344 | (end (string-match-p "/" (cdr action)))) | 1344 | (end (string-match-p "/" (cdr action)))) |
| 1345 | (list* 'boundaries start end))) | 1345 | (list* 'boundaries |
| 1346 | 1346 | ;; if `string' is "C:" in w32, (file-name-directory string) | |
| 1347 | ((eq action 'lambda) | 1347 | ;; returns "C:/", so `start' is 3 rather than 2. |
| 1348 | (if (zerop (length string)) | 1348 | ;; Not quite sure what is The Right Fix, but clipping it |
| 1349 | nil ;Not sure why it's here, but it probably doesn't harm. | 1349 | ;; back to 2 will work for this particular case. We'll |
| 1350 | (funcall (or pred 'file-exists-p) string))) | 1350 | ;; see if we can come up with a better fix when we bump |
| 1351 | ;; into more such problematic cases. | ||
| 1352 | (min start (length string)) end))) | ||
| 1353 | |||
| 1354 | ((eq action 'lambda) | ||
| 1355 | (if (zerop (length string)) | ||
| 1356 | nil ;Not sure why it's here, but it probably doesn't harm. | ||
| 1357 | (funcall (or pred 'file-exists-p) string))) | ||
| 1351 | 1358 | ||
| 1352 | (t | 1359 | (t |
| 1353 | (let* ((name (file-name-nondirectory string)) | 1360 | (let* ((name (file-name-nondirectory string)) |
| @@ -1395,19 +1402,20 @@ except that it passes the file name through `substitute-in-file-name'." | |||
| 1395 | (cond | 1402 | (cond |
| 1396 | ((eq (car-safe action) 'boundaries) | 1403 | ((eq (car-safe action) 'boundaries) |
| 1397 | ;; For the boundaries, we can't really delegate to | 1404 | ;; For the boundaries, we can't really delegate to |
| 1398 | ;; completion-file-name-table and then fix them up, because it | 1405 | ;; substitute-in-file-name+completion-file-name-table and then fix |
| 1399 | ;; would require us to track the relationship between `str' and | 1406 | ;; them up (as we do for the other actions), because it would |
| 1407 | ;; require us to track the relationship between `str' and | ||
| 1400 | ;; `string', which is difficult. And in any case, if | 1408 | ;; `string', which is difficult. And in any case, if |
| 1401 | ;; substitute-in-file-name turns "fo-$TO-ba" into "fo-o/b-ba", there's | 1409 | ;; substitute-in-file-name turns "fo-$TO-ba" into "fo-o/b-ba", |
| 1402 | ;; no way for us to return proper boundaries info, because the | 1410 | ;; there's no way for us to return proper boundaries info, because |
| 1403 | ;; boundary is not (yet) in `string'. | 1411 | ;; the boundary is not (yet) in `string'. |
| 1404 | ;; FIXME: Actually there is a way to return correct boundaries info, | 1412 | ;; |
| 1405 | ;; at the condition of modifying the all-completions return accordingly. | 1413 | ;; FIXME: Actually there is a way to return correct boundaries |
| 1406 | (let ((start (length (file-name-directory string))) | 1414 | ;; info, at the condition of modifying the all-completions |
| 1407 | (end (string-match-p "/" (cdr action)))) | 1415 | ;; return accordingly. But for now, let's not bother. |
| 1408 | (list* 'boundaries start end))) | 1416 | (completion-file-name-table string pred action)) |
| 1409 | 1417 | ||
| 1410 | (t | 1418 | (t |
| 1411 | (let* ((default-directory | 1419 | (let* ((default-directory |
| 1412 | (if (stringp pred) | 1420 | (if (stringp pred) |
| 1413 | ;; It used to be that `pred' was abused to pass `dir' | 1421 | ;; It used to be that `pred' was abused to pass `dir' |