summaryrefslogtreecommitdiff
path: root/lisp/iswitchb.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-04-17 22:04:04 +0000
committerJohn Wiegley <johnw@newartisans.com>2004-04-17 22:04:04 +0000
commitc80d953400f64cc8d7c336074aa7581749a54a27 (patch)
treef4904463394475cf4d9b87181801a0c78a0d0699 /lisp/iswitchb.el
parent554e27417b3e621a40b72cc75f9a3424330bf7e7 (diff)
downloademacs-c80d953400f64cc8d7c336074aa7581749a54a27.tar.gz
2004-04-17 John Wiegley <johnw@newartisans.com>
* iswitchb.el (iswitchb-max-to-show): Added a new config variable which optionally limits the number of names shown in the minibuffer. Off by default. (iswitchb-completions): Use `iswitchb-max-to-show'. This speeds up iswitchb for users with a multitude of open buffers, by showing only the first and last N/2 buffers in the completion list (which is enough for C-s/C-r, and to know that more characters need to be typed to refine the completion list).
Diffstat (limited to 'lisp/iswitchb.el')
-rw-r--r--lisp/iswitchb.el45
1 files changed, 28 insertions, 17 deletions
diff --git a/lisp/iswitchb.el b/lisp/iswitchb.el
index aab768387d0..0c43c270751 100644
--- a/lisp/iswitchb.el
+++ b/lisp/iswitchb.el
@@ -298,6 +298,13 @@ example functions that filter buffernames."
:type '(repeat (choice regexp function))
:group 'iswitchb)
+(defcustom iswitchb-max-to-show nil
+ "*If non-nil, limit the number of names shown in the minibuffer.
+This can greatly speed up iswitchb if you have a multitude of
+buffers open."
+ :type 'integer
+ :group 'iswitchb)
+
(defcustom iswitchb-cannot-complete-hook 'iswitchb-completion-help
"*Hook run when `iswitchb-complete' can't complete any more.
The most useful values are `iswitchb-completion-help', which pops up a
@@ -1185,6 +1192,15 @@ Copied from `icomplete-exhibit' with two changes:
contents
(not minibuffer-completion-confirm)))))))
+(defun iswitchb-output-completion (com)
+ (if (= (length com) most-len)
+ ;; Most is one exact match,
+ ;; note that and leave out
+ ;; for later indication:
+ (ignore
+ (setq most-is-exact t))
+ (substring com most-len)))
+
(defun iswitchb-completions (name require-match)
"Return the string that is displayed after the user's text.
Modified from `icomplete-completions'."
@@ -1224,28 +1240,23 @@ Modified from `icomplete-completions'."
"")
(if (not iswitchb-use-fonts) " [Matched]")))
(t ;multiple matches
+ (if (and iswitchb-max-to-show
+ (> (length comps) iswitchb-max-to-show))
+ (setq comps
+ (append
+ (subseq comps 0 (/ iswitchb-max-to-show 2))
+ (list "...")
+ (subseq comps (- (length comps)
+ (/ iswitchb-max-to-show 2))))))
(let* (
;;(most (try-completion name candidates predicate))
(most nil)
(most-len (length most))
most-is-exact
- (alternatives
- (apply
- (function concat)
- (cdr (apply
- (function nconc)
- (mapcar '(lambda (com)
- (if (= (length com) most-len)
- ;; Most is one exact match,
- ;; note that and leave out
- ;; for later indication:
- (progn
- (setq most-is-exact t)
- ())
- (list ","
- (substring com
- most-len))))
- comps))))))
+ (alternatives (if most
+ (mapconcat 'iswitchb-output-completion
+ comps ",")
+ (mapconcat 'identity comps ","))))
(concat