changeset 94486:ca90422b8114

(completion--do-completion): Move point even if the completion makes no change. (completion-pcm-try-completion): Fix computation of new point.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 30 Apr 2008 03:41:39 +0000
parents a01f79200343
children 432e68e359fa
files lisp/ChangeLog lisp/minibuffer.el
diffstat 2 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Apr 30 03:40:37 2008 +0000
+++ b/lisp/ChangeLog	Wed Apr 30 03:41:39 2008 +0000
@@ -1,3 +1,9 @@
+2008-04-30  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* 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  <david.hansen@gmx.net>
 
 	* dired.el: Require 'cl.
--- a/lisp/minibuffer.el	Wed Apr 30 03:40:37 2008 +0000
+++ b/lisp/minibuffer.el	Wed Apr 30 03:41:39 2008 +0000
@@ -360,8 +360,9 @@
           ;; 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 @@
          (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)