From 81ff94589d497e73142b795689b558c22f56f3e5 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 30 Apr 2008 03:41:39 +0000 Subject: [PATCH] (completion--do-completion): Move point even if the completion makes no change. (completion-pcm-try-completion): Fix computation of new point. --- lisp/ChangeLog | 6 ++++++ lisp/minibuffer.el | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 29d8e2bf80d..516c4f65462 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2008-04-30 Stefan Monnier + + * minibuffer.el (completion--do-completion): Move point even if the + completion makes no change. + (completion-pcm-try-completion): Fix computation of new point. + 2008-04-30 David Hansen * dired.el: Require 'cl. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f3c95df3f31..21988d823a2 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -360,8 +360,9 @@ E = after completion we now have an Exact match. ;; Insert in minibuffer the chars we got. (goto-char end) (insert completion) - (delete-region beg end) - (goto-char (+ beg comp-pos))) + (delete-region beg end)) + ;; Move point. + (goto-char (+ beg comp-pos)) (if (not (or unchanged completed)) ;; The case of the string changed, but that's all. We're not sure @@ -1283,13 +1284,17 @@ PATTERN is as returned by `completion-pcm--string->pattern'." (all (completion-pcm--all-completions pattern table pred))) (when all (let* ((mergedpat (completion-pcm--merge-completions all pattern)) - ;; `mergedpat' is in reverse order. - (pointpat (or (memq 'point mergedpat) (memq 'any mergedpat))) - ;; New pos from the end. + ;; `mergedpat' is in reverse order. Place new point (by + ;; order of preference) either at the old point, or at + ;; the last place where there's something to choose, or + ;; at the very end. + (pointpat (or (memq 'point mergedpat) (memq 'any mergedpat) + margedpat)) + ;; New pos from the start. (newpos (length (completion-pcm--pattern->string pointpat))) - ;; Do it afterwards because it changes `pointpat' by sideeffect. + ;; Do it afterwards because it changes `pointpat' by sideeffect. (merged (completion-pcm--pattern->string (nreverse mergedpat)))) - (cons merged (- (length merged) newpos)))))) + (cons merged newpos))))) (provide 'minibuffer) -- 2.39.5