From: Stefan Monnier Date: Wed, 27 Mar 2013 14:41:06 +0000 (-0400) Subject: * lisp/minibuffer.el (completion-pcm--merge-completions): Make sure prefixes X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~526^2~67 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b1da29572e811d18ee5f200a28192ea2f58ff9bf;p=emacs.git * lisp/minibuffer.el (completion-pcm--merge-completions): Make sure prefixes and suffixes don't overlap. Fixes: debbugs:14061 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 40b7cb011ae..fecad470900 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,12 +1,12 @@ 2013-03-27 Stefan Monnier + * minibuffer.el (completion-pcm--merge-completions): Make sure prefixes + and suffixes don't overlap (bug#14061). + * case-table.el: Use lexical-binding. (case-table-get-table): New function. (get-upcase-table): Use it. Mark as obsolete. Adjust callers. - * minibuffer.el (completion-pcm--merge-completions): Make sure prefixes - and suffixes don't overlap - 2013-03-27 Teodor Zlatanov * progmodes/subword.el: Add `superword-mode' to do word motion diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index ec237f0f664..016b16d0740 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2997,12 +2997,21 @@ the same set of elements." ;; here any more. (unless unique (push elem res) - (when (memq elem '(star point prefix)) - ;; Extract common suffix additionally to common prefix. - ;; Only do it for `point', `star', and `prefix' since for - ;; `any' it could lead to a merged completion that - ;; doesn't itself match the candidates. - (let ((suffix (completion--common-suffix comps))) + ;; Extract common suffix additionally to common prefix. + ;; Don't do it for `any' since it could lead to a merged + ;; completion that doesn't itself match the candidates. + (when (and (memq elem '(star point prefix)) + ;; If prefix is one of the completions, there's no + ;; suffix left to find. + (not (assoc-string prefix comps t))) + (let ((suffix + (completion--common-suffix + (if (zerop (length prefix)) comps + ;; Ignore the chars in the common prefix, so we + ;; don't merge '("abc" "abbc") as "ab*bc". + (let ((skip (length prefix))) + (mapcar (lambda (str) (substring str skip)) + comps)))))) (cl-assert (stringp suffix)) (unless (equal suffix "") (push suffix res)))))