From 67982e2b74ad72987459a6995f34161053a1dbfb Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 6 Sep 2013 18:46:44 -0400 Subject: * lisp/minibuffer.el: Make minibuffer-complete call completion-in-region rather than other way around. (completion--some, completion-pcm--find-all-completions): Don't delay signals when debugging. (minibuffer-completion-contents): Beware fields within the minibuffer contents. (completion-all-sorted-completions): Use defvar-local. (completion--do-completion, completion--cache-all-sorted-completions) (completion-all-sorted-completions, minibuffer-force-complete): Add args `beg' and `end'. (completion--in-region-1): New fun, extracted from minibuffer-complete. (minibuffer-complete): Use completion-in-region. (completion-complete-and-exit): New fun, extracted from minibuffer-complete-and-exit. (minibuffer-complete-and-exit): Use it. (completion--complete-and-exit): Rename from minibuffer--complete-and-exit. (completion-in-region--single-word): New function, extracted from minibuffer-complete-word. (minibuffer-complete-word): Use it. (display-completion-list): Make `common-substring' argument obsolete. (completion--in-region): Call completion--in-region-1 instead of minibuffer-complete. (completion-help-at-point): Pass boundaries to minibuffer-completion-help as args rather than via an overlay. (completion-pcm--string->pattern): Use `any-delim'. (completion-pcm--optimize-pattern): New function. (completion-pcm--pattern->regex): Handle `any-delim'. * lisp/icomplete.el (icomplete-forward-completions) (icomplete-backward-completions, icomplete-completions): Adjust calls to completion-all-sorted-completions and completion--cache-all-sorted-completions. (icomplete-with-completion-tables): Default to t. * lisp/emacs-lisp/crm.el (crm--current-element): Rename from crm--select-current-element. Don't put an overlay but return the boundaries instead. (crm--completion-command): Take two new args to bind to the boundaries. (crm-completion-help): Adjust accordingly. (crm-complete): Use completion-in-region. (crm-complete-word): Use completion-in-region--single-word. (crm-complete-and-exit): Use completion-complete-and-exit. --- lisp/icomplete.el | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'lisp/icomplete.el') diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 104e3363831..9aec829cd97 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -158,11 +158,13 @@ minibuffer completion.") (add-hook 'icomplete-post-command-hook 'icomplete-exhibit) ;;;_ = icomplete-with-completion-tables -(defvar icomplete-with-completion-tables '(internal-complete-buffer) +(defcustom icomplete-with-completion-tables t "Specialized completion tables with which icomplete should operate. Icomplete does not operate with any specialized completion tables -except those on this list.") +except those on this list." + :type '(choice (const :tag "All" t) + (repeat function))) (defvar icomplete-minibuffer-map (let ((map (make-sparse-keymap))) @@ -177,24 +179,28 @@ except those on this list.") Second entry becomes the first and can be selected with `minibuffer-force-complete-and-exit'." (interactive) - (let* ((comps (completion-all-sorted-completions)) + (let* ((beg (minibuffer-prompt-end)) + (end (point-max)) + (comps (completion-all-sorted-completions beg end)) (last (last comps))) (when comps (setcdr last (cons (car comps) (cdr last))) - (completion--cache-all-sorted-completions (cdr comps))))) + (completion--cache-all-sorted-completions beg end (cdr comps))))) (defun icomplete-backward-completions () "Step backward completions by one entry. Last entry becomes the first and can be selected with `minibuffer-force-complete-and-exit'." (interactive) - (let* ((comps (completion-all-sorted-completions)) + (let* ((beg (minibuffer-prompt-end)) + (end (point-max)) + (comps (completion-all-sorted-completions beg end)) (last-but-one (last comps 2)) (last (cdr last-but-one))) (when (consp last) ; At least two elements in comps (setcdr last-but-one (cdr last)) (push (car last) comps) - (completion--cache-all-sorted-completions comps)))) + (completion--cache-all-sorted-completions beg end comps)))) ;;;_ > icomplete-mode (&optional prefix) ;;;###autoload @@ -263,7 +269,8 @@ and `minibuffer-setup-hook'." "Insert icomplete completions display. Should be run via minibuffer `post-command-hook'. See `icomplete-mode' and `minibuffer-setup-hook'." - (when (and icomplete-mode (icomplete-simple-completing-p)) + (when (and icomplete-mode + (icomplete-simple-completing-p)) ;Shouldn't be necessary. (save-excursion (goto-char (point-max)) ; Insert the match-status information: @@ -319,7 +326,8 @@ matches exist. \(Keybindings for uniquely matched commands are exhibited within the square braces.)" (let* ((md (completion--field-metadata (field-beginning))) - (comps (completion-all-sorted-completions)) + (comps (completion-all-sorted-completions + (minibuffer-prompt-end) (point-max))) (last (if (consp comps) (last comps))) (base-size (cdr last)) (open-bracket (if require-match "(" "[")) -- cgit v1.2.1