diff options
| author | Stefan Monnier | 2024-07-25 08:39:38 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2024-07-25 08:39:38 -0400 |
| commit | 7170282a59a1981cd44f46d69a28f2c47a46884b (patch) | |
| tree | 040b1bec87ea0b5c30f0428866bcf7e004b81cd2 | |
| parent | 68906f184cba8b1fb75401917cccfe219f6826b0 (diff) | |
| download | emacs-7170282a59a1981cd44f46d69a28f2c47a46884b.tar.gz emacs-7170282a59a1981cd44f46d69a28f2c47a46884b.zip | |
lisp/minibuffer.el (completion--sifn-requote): Fix bug#72176
| -rw-r--r-- | lisp/minibuffer.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index baed4edcf89..bef565378ea 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -3343,7 +3343,7 @@ same as `substitute-in-file-name'." | |||
| 3343 | (file-error nil))) ;PCM often calls with invalid directories. | 3343 | (file-error nil))) ;PCM often calls with invalid directories. |
| 3344 | 3344 | ||
| 3345 | (defun completion--sifn-requote (upos qstr) | 3345 | (defun completion--sifn-requote (upos qstr) |
| 3346 | ;; We're looking for `qpos' such that: | 3346 | ;; We're looking for (the largest) `qpos' such that: |
| 3347 | ;; (equal (substring (substitute-in-file-name qstr) 0 upos) | 3347 | ;; (equal (substring (substitute-in-file-name qstr) 0 upos) |
| 3348 | ;; (substitute-in-file-name (substring qstr 0 qpos))) | 3348 | ;; (substitute-in-file-name (substring qstr 0 qpos))) |
| 3349 | ;; Big problem here: we have to reverse engineer substitute-in-file-name to | 3349 | ;; Big problem here: we have to reverse engineer substitute-in-file-name to |
| @@ -3373,11 +3373,13 @@ same as `substitute-in-file-name'." | |||
| 3373 | ;; Main assumption: nothing after qpos should affect the text before upos, | 3373 | ;; Main assumption: nothing after qpos should affect the text before upos, |
| 3374 | ;; so we can work our way backward from the end of qstr, one character | 3374 | ;; so we can work our way backward from the end of qstr, one character |
| 3375 | ;; at a time. | 3375 | ;; at a time. |
| 3376 | ;; Second assumptions: If qpos is far from the end this can be a bit slow, | 3376 | ;; Second assumption: If qpos is far from the end this can be a bit slow, |
| 3377 | ;; so we speed it up by doing a first loop that skips a word at a time. | 3377 | ;; so we speed it up by doing a first loop that skips a word at a time. |
| 3378 | ;; This word-sized loop is careful not to cut in the middle of env-vars. | 3378 | ;; This word-sized loop is careful not to cut in the middle of env-vars. |
| 3379 | (while (let ((boundary (string-match "\\(\\$+{?\\)?\\w+\\W*\\'" qstr))) | 3379 | (while (let ((boundary (string-match "\\(\\$+{?\\)?\\w+\\W*\\'" qstr))) |
| 3380 | (and boundary | 3380 | (and boundary |
| 3381 | ;; Try and make sure we keep the largest `qpos' (bug#72176). | ||
| 3382 | (not (string-match-p "/[/~]" qstr boundary)) | ||
| 3381 | (progn | 3383 | (progn |
| 3382 | (setq qprefix (substring qstr 0 boundary)) | 3384 | (setq qprefix (substring qstr 0 boundary)) |
| 3383 | (string-prefix-p uprefix | 3385 | (string-prefix-p uprefix |