aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann1999-11-21 13:44:26 +0000
committerGerd Moellmann1999-11-21 13:44:26 +0000
commit1934dbf4c9d4105df42ed3f8a1981b17c7d1dbfa (patch)
tree3ece1a61acb4883a54423c6e16e6d85a41076128
parenta88d2801b8b9a771abf73370dd0f7420df0cbdc9 (diff)
downloademacs-1934dbf4c9d4105df42ed3f8a1981b17c7d1dbfa.tar.gz
emacs-1934dbf4c9d4105df42ed3f8a1981b17c7d1dbfa.zip
(icomplete-completions): Use an explicit variable
`icomplete-prospects-length', obviating the need to use an apparently faulty throw/catch arrangement.
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/icomplete.el156
2 files changed, 78 insertions, 94 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9a7ec62d431..24ec6d40c13 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
11999-11-21 Ken Manheimer <klm@python.org>
2
3 * icomplete.el (icomplete-completions): Use an explicit variable
4 `icomplete-prospects-length', obviating the need to use an
5 apparently faulty throw/catch arrangement.
6
11999-11-21 Eli Zaretskii <eliz@is.elta.co.il> 71999-11-21 Eli Zaretskii <eliz@is.elta.co.il>
2 8
3 * term/internal.el (IT-display-table-setup): Don't overstep 9 * term/internal.el (IT-display-table-setup): Don't overstep
@@ -10,13 +16,13 @@
10 16
111999-11-19 Stefan Monnier <monnier@cs.yale.edu> 171999-11-19 Stefan Monnier <monnier@cs.yale.edu>
12 18
13 * scroll-bar.el (scroll-bar-toolkit-scroll): add handling of the `ratio' 19 * scroll-bar.el (scroll-bar-toolkit-scroll): Add handling of the
14 event for Xaw and Xaw3d(without arrows) scrollbars. 20 `ratio' event for Xaw and Xaw3d(without arrows) scrollbars.
15 21
16 * files.el (auto-mode-alist): add patterns for diff-mode. 22 * files.el (auto-mode-alist): Add patterns for diff-mode.
17 23
18 * complete.el (PC-do-complete-and-exit): use minibuffer-prompt-end to 24 * complete.el (PC-do-complete-and-exit): Use minibuffer-prompt-end
19 detect an empty prompt. 25 to detect an empty prompt.
20 26
211999-11-18 Dave Love <fx@gnu.org> 271999-11-18 Dave Love <fx@gnu.org>
22 28
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 0452971a188..aba6ab49945 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -1,10 +1,11 @@
1;;; icomplete.el --- minibuffer completion incremental feedback 1;;;_+ icomplete.el - minibuffer completion incremental feedback
2 2
3;; Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
4 4
5;; Author: Ken Manheimer <klm@python.org> 5;; Author: Ken Manheimer <klm@i.am>
6;; Maintainer: Ken Manheimer <klm@python.org> 6;; Maintainer: Ken Manheimer <klm@i.am>
7;; Created: Mar 1993 klm@nist.gov - first release to usenet 7;; Created: Mar 1993 Ken Manheimer, klm@nist.gov - first release to usenet
8;; Last update: Ken Manheimer <klm@i.am>, 11/18/1999.
8;; Keywords: help, abbrev 9;; Keywords: help, abbrev
9 10
10;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
@@ -38,19 +39,14 @@
38;; customize icomplete setup for interoperation with other 39;; customize icomplete setup for interoperation with other
39;; minibuffer-oriented packages. 40;; minibuffer-oriented packages.
40 41
41;; To activate icomplete mode, simply add the following to .emacs: 42;; To activate icomplete mode, load the package and use the
42;; (icomplete-mode) 43;; `icomplete-mode' function. You can subsequently deactivate it by
43;; You can subsequently deactivate it by invoking the function 44;; invoking the function icomplete-mode with a negative prefix-arg
44;; icomplete-mode with a negative prefix-arg (C-U -1 ESC-x 45;; (C-U -1 ESC-x icomplete-mode). Also, you can prevent activation of
45;; icomplete-mode). Also, you can prevent activation of the mode 46;; the mode during package load by first setting the variable
46;; during package load by first setting the variable `icomplete-mode' 47;; `icomplete-mode' to nil. Icompletion can be enabled any time after
47;; to nil. Icompletion can be enabled any time after the package is 48;; the package is loaded by invoking icomplete-mode without a prefix
48;; loaded by invoking icomplete-mode without a prefix arg. 49;; arg.
49
50;; This version of icomplete runs on Emacs 19.18 and later. (It
51;; depends on the incorporation of minibuffer-setup-hook.) The elisp
52;; archives, ftp://archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive,
53;; probably still has a version that works in GNU Emacs v18.
54 50
55;; Thanks to everyone for their suggestions for refinements of this 51;; Thanks to everyone for their suggestions for refinements of this
56;; package. I particularly have to credit Michael Cook, who 52;; package. I particularly have to credit Michael Cook, who
@@ -72,9 +68,8 @@
72 :prefix "icomplete-" 68 :prefix "icomplete-"
73 :group 'minibuffer) 69 :group 'minibuffer)
74 70
75;;;_* User Customization variables
76(defcustom icomplete-mode nil 71(defcustom icomplete-mode nil
77 "Toggle incremental minibuffer completion. 72 "*Toggle incremental minibuffer completion.
78As text is typed into the minibuffer, prospective completions are indicated 73As text is typed into the minibuffer, prospective completions are indicated
79in the minibuffer. 74in the minibuffer.
80Setting this variable directly does not take effect; 75Setting this variable directly does not take effect;
@@ -86,6 +81,12 @@ use either \\[customize] or the function `icomplete-mode'."
86 :group 'icomplete 81 :group 'icomplete
87 :require 'icomplete) 82 :require 'icomplete)
88 83
84;;;_* User Customization variables
85(defcustom icomplete-prospects-length 80
86 "*Length of string displaying the prospects."
87 :type 'integer
88 :group 'icomplete)
89
89(defcustom icomplete-compute-delay .3 90(defcustom icomplete-compute-delay .3
90 "*Completions-computation stall, used only with large-number 91 "*Completions-computation stall, used only with large-number
91completions - see `icomplete-delay-completions-threshold'." 92completions - see `icomplete-delay-completions-threshold'."
@@ -215,7 +216,9 @@ Usually run by inclusion in `minibuffer-setup-hook'."
215 (run-hooks 'icomplete-post-command-hook))) 216 (run-hooks 'icomplete-post-command-hook)))
216 nil t) 217 nil t)
217 (run-hooks 'icomplete-minibuffer-setup-hook)))) 218 (run-hooks 'icomplete-minibuffer-setup-hook))))
218 219;
220
221
219;;;_* Completion 222;;;_* Completion
220 223
221;;;_ > icomplete-tidy () 224;;;_ > icomplete-tidy ()
@@ -306,76 +309,51 @@ are exhibited within the square braces.)"
306 (let ((comps (all-completions name candidates predicate)) 309 (let ((comps (all-completions name candidates predicate))
307 ; "-determined" - only one candidate 310 ; "-determined" - only one candidate
308 (open-bracket-determined (if require-match "(" "[")) 311 (open-bracket-determined (if require-match "(" "["))
309 (close-bracket-determined (if require-match ")" "]")) 312 (close-bracket-determined (if require-match ")" "]")))
313 ;; `concat'/`mapconcat' is the slow part. With the introduction of
314 ;; `icomplete-prospects-length', there is no need for `catch'/`throw'.
315 (if (null comps) (format " %sNo matches%s"
316 open-bracket-determined
317 close-bracket-determined)
318 (let* ((most-try (try-completion name (mapcar (function list) comps)))
319 (most (if (stringp most-try) most-try (car comps)))
320 (most-len (length most))
321 (determ (and (> most-len (length name))
322 (concat open-bracket-determined
323 (substring most (length name))
324 close-bracket-determined)))
325 (open-bracket-prospects "{")
326 (close-bracket-prospects "}")
310 ;"-prospects" - more than one candidate 327 ;"-prospects" - more than one candidate
311 (open-bracket-prospects "{") 328 (prospects-len 0)
312 (close-bracket-prospects "}") 329 prospects most-is-exact comp)
313 ) 330 (if (eq most-try t)
314 (catch 'input 331 (setq prospects nil)
315 (cond ((null comps) (format " %sNo matches%s" 332 (while (and comps (< prospects-len icomplete-prospects-length))
316 open-bracket-determined 333 (setq comp (substring (car comps) most-len)
317 close-bracket-determined)) 334 comps (cdr comps))
318 ((null (cdr comps)) ;one match 335 (cond ((string-equal comp "") (setq most-is-exact t))
319 (concat (if (and (> (length (car comps)) 336 ((member comp prospects))
320 (length name))) 337 (t (setq prospects (cons comp prospects)
321 (concat open-bracket-determined 338 prospects-len (+ (length comp) 1 prospects-len))))))
322 (substring (car comps) (length name)) 339 (if prospects
323 close-bracket-determined) 340 (concat determ
324 "") 341 open-bracket-prospects
325 " [Matched" 342 (and most-is-exact ",")
326 (let ((keys (and icomplete-show-key-bindings 343 (mapconcat 'identity
327 (commandp (intern-soft (car comps))) 344 (sort prospects (function string-lessp))
328 (icomplete-get-keys (car comps))))) 345 ",")
329 (if keys 346 (and comps ",...")
330 (concat "; " keys) 347 close-bracket-prospects)
331 "")) 348 (concat determ
332 "]")) 349 " [Matched"
333 (t ;multiple matches 350 (let ((keys (and icomplete-show-key-bindings
334 (let* ((most 351 (commandp (intern-soft most))
335 (try-completion name candidates 352 (icomplete-get-keys most))))
336 (and predicate 353 (if keys
337 ;; Wrap predicate in impatience - ie, 354 (concat "; " keys)
338 ;; `throw' up when pending input is 355 ""))
339 ;; noticed. Adds some overhead to 356 "]"))))))
340 ;; predicate, but should be worth it.
341 (function
342 (lambda (item)
343 (if (input-pending-p)
344 (throw 'input "")
345 (apply predicate
346 item nil)))))))
347 (most-len (length most))
348 most-is-exact
349 (alternatives
350 (substring
351 (apply (function concat)
352 (mapcar (function
353 (lambda (com)
354 (if (input-pending-p)
355 (throw 'input ""))
356 (if (= (length com) most-len)
357 ;; Most is one exact match,
358 ;; note that and leave out
359 ;; for later indication:
360 (progn
361 (setq most-is-exact t)
362 ())
363 (concat ","
364 (substring com
365 most-len)))))
366 comps))
367 1)))
368 (concat (and (> most-len (length name))
369 (concat open-bracket-determined
370 (substring most (length name))
371 close-bracket-determined))
372 open-bracket-prospects
373 (if most-is-exact
374 ;; Add a ',' at the front to indicate "complete but
375 ;; not unique":
376 (concat "," alternatives)
377 alternatives)
378 close-bracket-prospects)))))))
379 357
380(if icomplete-mode 358(if icomplete-mode
381 (icomplete-mode 1)) 359 (icomplete-mode 1))