X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/c71a0d48f3c880248a7f7f25e92ddbcbad5ef0e7..b1367cba38b88b64530f40b1935b38a8c08f2fd6:/lisp/icomplete.el diff --git a/lisp/icomplete.el b/lisp/icomplete.el index ab67fcfcdf..a4e3e33947 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -1,6 +1,6 @@ ;;; icomplete.el --- minibuffer completion incremental feedback -;; Copyright (C) 1992-1994, 1997, 1999, 2001-2011 +;; Copyright (C) 1992-1994, 1997, 1999, 2001-2012 ;; Free Software Foundation, Inc. ;; Author: Ken Manheimer @@ -172,18 +172,16 @@ except those on this list.") ;;;_ > icomplete-mode (&optional prefix) ;;;###autoload (define-minor-mode icomplete-mode - "Toggle incremental minibuffer completion for this Emacs session. -With a numeric argument, turn Icomplete mode on if ARG is positive, -otherwise turn it off." + "Toggle incremental minibuffer completion (Icomplete mode). +With a prefix argument ARG, enable Icomplete mode if ARG is +positive, and disable it otherwise. If called from Lisp, enable +the mode if ARG is omitted or nil." :global t :group 'icomplete (if icomplete-mode ;; The following is not really necessary after first time - ;; no great loss. - (progn - (setq completion-show-inline-help nil) - (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup)) - (remove-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup) - (setq completion-show-inline-help t))) + (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup) + (remove-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup))) ;;;_ > icomplete-simple-completing-p () (defun icomplete-simple-completing-p () @@ -209,11 +207,14 @@ Conditions are: "Run in minibuffer on activation to establish incremental completion. Usually run by inclusion in `minibuffer-setup-hook'." (when (and icomplete-mode (icomplete-simple-completing-p)) + (set (make-local-variable 'completion-show-inline-help) nil) (add-hook 'pre-command-hook - (lambda () (run-hooks 'icomplete-pre-command-hook)) + (lambda () (let ((non-essential t)) + (run-hooks 'icomplete-pre-command-hook))) nil t) (add-hook 'post-command-hook - (lambda () (run-hooks 'icomplete-post-command-hook)) + (lambda () (let ((non-essential t)) ;E.g. don't prompt for password! + (run-hooks 'icomplete-post-command-hook))) nil t) (run-hooks 'icomplete-minibuffer-setup-hook))) ; @@ -286,7 +287,7 @@ The displays for unambiguous matches have ` [Matched]' appended matches exist. \(Keybindings for uniquely matched commands are exhibited within the square braces.)" - (let* ((non-essential t) + (let* ((md (completion--field-metadata (field-beginning))) (comps (completion-all-sorted-completions)) (last (if (consp comps) (last comps))) (base-size (cdr last)) @@ -299,11 +300,11 @@ are exhibited within the square braces.)" (let* ((most-try (if (and base-size (> base-size 0)) (completion-try-completion - name candidates predicate (length name)) + name candidates predicate (length name) md) ;; If the `comps' are 0-based, the result should be ;; the same with `comps'. (completion-try-completion - name comps nil (length name)))) + name comps nil (length name) md))) (most (if (consp most-try) (car most-try) (if most-try (car comps) ""))) ;; Compare name and most, so we can determine if name is @@ -333,21 +334,23 @@ are exhibited within the square braces.)" (window-width))) (prefix-len ;; Find the common prefix among `comps'. - (if (eq t (compare-strings (car comps) nil (length most) - most nil nil completion-ignore-case)) - ;; Common case. - (length most) - ;; Else, use try-completion. - (let ((comps-prefix (try-completion "" comps))) - (and (stringp comps-prefix) - (length comps-prefix))))) + ;; We can't use the optimization below because its assumptions + ;; aren't always true, e.g. when completion-cycling (bug#10850): + ;; (if (eq t (compare-strings (car comps) nil (length most) + ;; most nil nil completion-ignore-case)) + ;; ;; Common case. + ;; (length most) + ;; Else, use try-completion. + (let ((comps-prefix (try-completion "" comps))) + (and (stringp comps-prefix) + (length comps-prefix)))) ;;) prospects most-is-exact comp limit) (if (eq most-try t) ;; (or (null (cdr comps)) (setq prospects nil) (while (and comps (not limit)) (setq comp - (if prefix-len (substring (car comps) prefix-len) (car comps)) + (if prefix-len (substring (car comps) prefix-len) (car comps)) comps (cdr comps)) (cond ((string-equal comp "") (setq most-is-exact t)) ((member comp prospects))