diff options
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 44 |
2 files changed, 37 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index de2cfc6f0ac..ac2aff0d9c7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2012-05-15 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2012-05-15 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * minibuffer.el (completion--sifn-requote): Handle sifn's truncation | ||
| 4 | behavior. | ||
| 5 | (completion--string-equal-p): New function. | ||
| 6 | (completion--twq-all): Use it to get better assertion failure data. | ||
| 7 | |||
| 3 | Only handle ".." and '..' quoting in shell-mode (bug#11466). | 8 | Only handle ".." and '..' quoting in shell-mode (bug#11466). |
| 4 | * shell.el (shell--unquote&requote-argument, shell--unquote-argument) | 9 | * shell.el (shell--unquote&requote-argument, shell--unquote-argument) |
| 5 | (shell--requote-argument): New functions. | 10 | (shell--requote-argument): New functions. |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 60a70fbcce7..9fb7627fe64 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -508,6 +508,9 @@ for use at QPOS." | |||
| 508 | (assert (equal (funcall unquote qstring) completion)) | 508 | (assert (equal (funcall unquote qstring) completion)) |
| 509 | (cons qstring qpoint))) | 509 | (cons qstring qpoint))) |
| 510 | 510 | ||
| 511 | (defun completion--string-equal-p (s1 s2) | ||
| 512 | (eq t (compare-strings s1 nil nil s2 nil nil 'ignore-case))) | ||
| 513 | |||
| 511 | (defun completion--twq-all (string ustring completions boundary | 514 | (defun completion--twq-all (string ustring completions boundary |
| 512 | unquote requote) | 515 | unquote requote) |
| 513 | (when completions | 516 | (when completions |
| @@ -519,10 +522,10 @@ for use at QPOS." | |||
| 519 | (`(,qfullpos . ,qfun) | 522 | (`(,qfullpos . ,qfun) |
| 520 | (funcall requote (+ boundary (length prefix)) string)) | 523 | (funcall requote (+ boundary (length prefix)) string)) |
| 521 | (qfullprefix (substring string 0 qfullpos)) | 524 | (qfullprefix (substring string 0 qfullpos)) |
| 522 | (_ (assert (eq t (compare-strings | 525 | (_ (assert (completion--string-equal-p |
| 523 | (funcall unquote qfullprefix) nil nil | 526 | (funcall unquote qfullprefix) |
| 524 | (concat (substring ustring 0 boundary) prefix) | 527 | (concat (substring ustring 0 boundary) prefix)) |
| 525 | nil nil 'ignore-case)))) | 528 | t)) |
| 526 | (qboundary (car (funcall requote boundary string))) | 529 | (qboundary (car (funcall requote boundary string))) |
| 527 | (_ (assert (<= qboundary qfullpos))) | 530 | (_ (assert (<= qboundary qfullpos))) |
| 528 | ;; FIXME: this split/quote/concat business messes up the carefully | 531 | ;; FIXME: this split/quote/concat business messes up the carefully |
| @@ -552,14 +555,13 @@ for use at QPOS." | |||
| 552 | (qnew (funcall qfun new)) | 555 | (qnew (funcall qfun new)) |
| 553 | (qcompletion (concat qprefix qnew))) | 556 | (qcompletion (concat qprefix qnew))) |
| 554 | (assert | 557 | (assert |
| 555 | (eq t (compare-strings | 558 | (completion--string-equal-p |
| 556 | (funcall unquote | 559 | (funcall unquote |
| 557 | (concat (substring string 0 qboundary) | 560 | (concat (substring string 0 qboundary) |
| 558 | qcompletion)) | 561 | qcompletion)) |
| 559 | nil nil | 562 | (concat (substring ustring 0 boundary) |
| 560 | (concat (substring ustring 0 boundary) | 563 | completion)) |
| 561 | completion) | 564 | t) |
| 562 | nil nil 'ignore-case))) | ||
| 563 | qcompletion)) | 565 | qcompletion)) |
| 564 | completions) | 566 | completions) |
| 565 | qboundary)))) | 567 | qboundary)))) |
| @@ -2121,7 +2123,25 @@ same as `substitute-in-file-name'." | |||
| 2121 | "use the regular PRED argument" "23.2") | 2123 | "use the regular PRED argument" "23.2") |
| 2122 | 2124 | ||
| 2123 | (defun completion--sifn-requote (upos qstr) | 2125 | (defun completion--sifn-requote (upos qstr) |
| 2126 | ;; We're looking for `qupos' such that: | ||
| 2127 | ;; (equal (substring (substitute-in-file-name qstr) 0 upos) | ||
| 2128 | ;; (substitute-in-file-name (substring qstr 0 qupos))) | ||
| 2129 | ;; Big problem here: we have to reverse engineer substitute-in-file-name to | ||
| 2130 | ;; find the position corresponding to UPOS in QSTR, but | ||
| 2131 | ;; substitute-in-file-name can do anything, depending on file-name-handlers. | ||
| 2132 | ;; Kind of like in rfn-eshadow-update-overlay, only worse. | ||
| 2124 | (let ((qpos 0)) | 2133 | (let ((qpos 0)) |
| 2134 | ;; Handle substitute-in-file-name's truncation behavior. | ||
| 2135 | (while (and (string-match "[\\/][~/\\]" qstr qpos) | ||
| 2136 | ;; Hopefully our regexp covers all truncation cases. | ||
| 2137 | ;; Also let's make sure sifn indeed truncates here. | ||
| 2138 | (let ((tpos (1+ (match-beginning 0)))) | ||
| 2139 | (equal (substitute-in-file-name qstr) | ||
| 2140 | (substitute-in-file-name (substring qstr tpos))))) | ||
| 2141 | (setq qpos tpos)) | ||
| 2142 | ;; `upos' is relative to the position corresponding to `qpos' in | ||
| 2143 | ;; (substitute-in-file-name qstr), so as qpos moves forward, upos | ||
| 2144 | ;; gets smaller. | ||
| 2125 | (while (and (> upos 0) | 2145 | (while (and (> upos 0) |
| 2126 | (string-match "\\$\\(\\$\\|\\([[:alnum:]_]+\\|{[^}]*}\\)\\)?" | 2146 | (string-match "\\$\\(\\$\\|\\([[:alnum:]_]+\\|{[^}]*}\\)\\)?" |
| 2127 | qstr qpos)) | 2147 | qstr qpos)) |