From 86011bf229c999b8932b338ec7b28e063b504a52 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 26 Jun 2008 02:48:56 +0000 Subject: [PATCH] (completion-basic-try-completion): Use the text after point to consrain the completion candidates. (completion-basic-all-completions): Adjust accordingly. --- lisp/ChangeLog | 6 ++++++ lisp/minibuffer.el | 50 +++++++++++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 24ae11bc585..7d67a5576c8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2008-06-26 Stefan Monnier + + * 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 * textmodes/tex-mode.el (tex-verbatim): Use monospace instead of diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 706de22e772..6bae7cdfda4 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -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) -- 2.39.2