]> git.eshelyaron.com Git - emacs.git/commitdiff
(completion-basic-try-completion): Use the text after
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 26 Jun 2008 02:48:56 +0000 (02:48 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 26 Jun 2008 02:48:56 +0000 (02:48 +0000)
point to consrain the completion candidates.
(completion-basic-all-completions): Adjust accordingly.

lisp/ChangeLog
lisp/minibuffer.el

index 24ae11bc5859a242f169dd42760c3a270b16e69f..7d67a5576c82f49f1fd4770ff4e811fdd9d29ac5 100644 (file)
@@ -1,3 +1,9 @@
+2008-06-26  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * minibuffer.el (completion-basic-try-completion): Use the text after
+       point to consrain the completion candidates.
+       (completion-basic-all-completions): Adjust accordingly.
+
 2008-06-25  Chong Yidong  <cyd@stupidchicken.com>
 
        * textmodes/tex-mode.el (tex-verbatim): Use monospace instead of
index 706de22e772ce47d79a001252cc380e626ed4206..6bae7cdfda4551dccb931ab56995b4d003b839cb 100644 (file)
@@ -1287,23 +1287,45 @@ Return the new suffix."
 (defun completion-basic-try-completion (string table pred point)
   (let* ((beforepoint (substring string 0 point))
          (afterpoint (substring string point))
-         (completion (try-completion beforepoint table pred)))
-    (if (not (stringp completion))
-        completion
-      (cons
-       (concat completion
-               (completion--merge-suffix completion point afterpoint))
-       (length completion)))))
-
-(defalias 'completion-basic-all-completions 'completion-emacs22-all-completions)
+         (bounds (completion-boundaries beforepoint table pred afterpoint)))
+    (if (zerop (cdr bounds))
+        ;; `try-completion' may return a subtly different result
+        ;; than `all+merge', so try to use it whenever possible.
+        (let ((completion (try-completion beforepoint table pred)))
+          (if (not (stringp completion))
+              completion
+            (cons
+             (concat completion
+                     (completion--merge-suffix completion point afterpoint))
+             (length completion))))
+      (let* ((suffix (substring afterpoint (cdr bounds)))
+             (prefix (substring beforepoint 0 (car bounds)))
+             (pattern (delete
+                       "" (list (substring beforepoint (car bounds))
+                                'point
+                                (substring afterpoint 0 (cdr bounds)))))
+             (all (completion-pcm--all-completions prefix pattern table pred)))
+        (if minibuffer-completing-file-name
+            (setq all (completion-pcm--filename-try-filter all)))
+        (completion-pcm--merge-try pattern all prefix suffix)))))
+
+(defun completion-basic-all-completions (string table pred point)
+  (let* ((beforepoint (substring string 0 point))
+         (afterpoint (substring string point))
+         (bounds (completion-boundaries beforepoint table pred afterpoint))
+         (suffix (substring afterpoint (cdr bounds)))
+         (prefix (substring beforepoint 0 (car bounds)))
+         (pattern (delete
+                   "" (list (substring beforepoint (car bounds))
+                            'point
+                            (substring afterpoint 0 (cdr bounds)))))
+         (all (completion-pcm--all-completions prefix pattern table pred)))
+    (completion-hilit-commonality
+     (if (consp all) (nconc all (car bounds)) all)
+     point)))
 
 ;;; Partial-completion-mode style completion.
 
-;; BUGS:
-
-;; - "minibuffer-s- TAB" with minibuffer-selected-window ends up with
-;;   "minibuffer--s-" which matches other options.
-
 (defvar completion-pcm--delim-wild-regex nil)
 
 (defun completion-pcm--prepare-delim-re (delims)