diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 35 |
2 files changed, 35 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e1a0ee66dd7..bef5f1ba71f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-05-05 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * minibuffer.el (completion-table-with-quoting) <completion--unquote>: | ||
| 4 | Make sure the new point we return is within the new string (bug#17239). | ||
| 5 | |||
| 1 | 2014-05-03 Eli Zaretskii <eliz@gnu.org> | 6 | 2014-05-03 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | * mail/rmailsum.el (rmail-new-summary-1): Fix a typo in a comment. | 8 | * mail/rmailsum.el (rmail-new-summary-1): Fix a typo in a comment. |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 9dd4ef9fe04..87ba8a22e64 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -519,11 +519,35 @@ for use at QPOS." | |||
| 519 | completions)) | 519 | completions)) |
| 520 | 520 | ||
| 521 | ((eq action 'completion--unquote) | 521 | ((eq action 'completion--unquote) |
| 522 | (let ((ustring (funcall unquote string)) | 522 | ;; PRED is really a POINT in STRING. |
| 523 | (uprefix (funcall unquote (substring string 0 pred)))) | 523 | ;; We should return a new set (STRING TABLE POINT REQUOTE) |
| 524 | ;; We presume (more or less) that `concat' and `unquote' commute. | 524 | ;; where STRING is a new (unquoted) STRING to match against the new TABLE |
| 525 | (cl-assert (string-prefix-p uprefix ustring)) | 525 | ;; using a new POINT inside it, and REQUOTE is a requoting function which |
| 526 | (list ustring table (length uprefix) | 526 | ;; should reverse the unquoting, (i.e. it receives the completion result |
| 527 | ;; of using the new TABLE and should turn it into the corresponding | ||
| 528 | ;; quoted result). | ||
| 529 | (let* ((qpos pred) | ||
| 530 | (ustring (funcall unquote string)) | ||
| 531 | (uprefix (funcall unquote (substring string 0 qpos))) | ||
| 532 | ;; FIXME: we really should pass `qpos' to `unuote' and have that | ||
| 533 | ;; function give us the corresponding `uqpos'. But for now we | ||
| 534 | ;; presume (more or less) that `concat' and `unquote' commute. | ||
| 535 | (uqpos (if (string-prefix-p uprefix ustring) | ||
| 536 | ;; Yay!! They do seem to commute! | ||
| 537 | (length uprefix) | ||
| 538 | ;; They don't commute this time! :-( | ||
| 539 | ;; Maybe qpos is in some text that disappears in the | ||
| 540 | ;; ustring (bug#17239). Let's try a second chance guess. | ||
| 541 | (let ((usuffix (funcall unquote (substring string qpos)))) | ||
| 542 | (if (string-suffix-p usuffix ustring) | ||
| 543 | ;; Yay!! They still "commute" in a sense! | ||
| 544 | (- (length ustring) (length usuffix)) | ||
| 545 | ;; Still no luck! Let's just choose *some* position | ||
| 546 | ;; within ustring. | ||
| 547 | (/ (+ (min (length uprefix) (length ustring)) | ||
| 548 | (max (- (length ustring) (length usuffix)) 0)) | ||
| 549 | 2)))))) | ||
| 550 | (list ustring table uqpos | ||
| 527 | (lambda (unquoted-result op) | 551 | (lambda (unquoted-result op) |
| 528 | (pcase op | 552 | (pcase op |
| 529 | (1 ;;try | 553 | (1 ;;try |
| @@ -853,6 +877,7 @@ completing buffer and file names, respectively." | |||
| 853 | (setq string (pop new)) | 877 | (setq string (pop new)) |
| 854 | (setq table (pop new)) | 878 | (setq table (pop new)) |
| 855 | (setq point (pop new)) | 879 | (setq point (pop new)) |
| 880 | (cl-assert (<= point (length string))) | ||
| 856 | (pop new)))) | 881 | (pop new)))) |
| 857 | (result | 882 | (result |
| 858 | (completion--some (lambda (style) | 883 | (completion--some (lambda (style) |