annotate lisp/icomplete.el @ 20622:619c69f1ab83

(set_term_frame_name): Use size_byte.
author Richard M. Stallman <rms@gnu.org>
date Fri, 09 Jan 1998 23:13:22 +0000
parents e0327e90d706
children d1d94511b3b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
1 ;;;_. icomplete.el - minibuffer completion incremental feedback
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
2
18060
640305a5c871 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18029
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
5 ;; Author: Ken Manheimer <klm@python.org>
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
6 ;; Maintainer: Ken Manheimer <klm@python.org>
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 12933
diff changeset
7 ;; Created: Mar 1993 klm@nist.gov - first release to usenet
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 12933
diff changeset
8 ;; Keywords: help, abbrev
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
10 ;; This file is part of GNU Emacs.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
11
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
15 ;; any later version.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
16
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
20 ;; GNU General Public License for more details.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
21
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
25 ;; Boston, MA 02111-1307, USA.
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
26
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
29 ;; Loading this package implements a more fine-grained minibuffer
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
30 ;; completion feedback scheme. Prospective completions are concisely
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
31 ;; indicated within the minibuffer itself, with each successive
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
32 ;; keystroke.
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
33
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
34 ;; See 'icomplete-completions' docstring for a description of the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
35 ;; icomplete display format.
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
36
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
37 ;; See the `icomplete-minibuffer-setup-hook' docstring for a means to
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
38 ;; customize icomplete setup for interoperation with other
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
39 ;; minibuffer-oriented packages.
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
41 ;; To activate icomplete mode, simply load the package. You can
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
42 ;; subsequently deactivate it by invoking the function icomplete-mode
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
43 ;; with a negative prefix-arg (C-U -1 ESC-x icomplete-mode). Also,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
44 ;; you can prevent activation of the mode during package load by
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
45 ;; first setting the variable `icomplete-mode' to nil. Icompletion
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
46 ;; can be enabled any time after the package is loaded by invoking
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
47 ;; icomplete-mode without a prefix arg.
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
48
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
49 ;; This version of icomplete runs on Emacs 19.18 and later. (It
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
50 ;; depends on the incorporation of minibuffer-setup-hook.) The elisp
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
51 ;; archives, ftp://archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive,
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
52 ;; probably still has a version that works in GNU Emacs v18.
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
53
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
54 ;; Thanks to everyone for their suggestions for refinements of this
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
55 ;; package. I particularly have to credit Michael Cook, who
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
56 ;; implemented an incremental completion style in his 'iswitch'
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
57 ;; functions that served as a model for icomplete. Some other
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
58 ;; contributors: Noah Freidman (restructuring as minor mode), Colin
18251
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
59 ;; Rafferty (lemacs reconciliation), Lars Lindberg, RMS, and others.
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
60
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13989
diff changeset
61 ;; klm.
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;;; Code:
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
65 ;;;_* Provide
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (provide 'icomplete)
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
68 ;;;_* User Customization variables
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
69 (defvar icomplete-compute-delay .3
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
70 "*Completions-computation stall, used only with large-number
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
71 completions - see `icomplete-delay-completions-threshold'.")
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
72 (defvar icomplete-delay-completions-threshold 400
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
73 "*Pending-completions number over which to apply icomplete-compute-delay.")
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
74 (defvar icomplete-max-delay-chars 3
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
75 "*Maximum number of initial chars to apply icomplete compute delay.")
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
76
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
77 ;;;_* Initialization
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
78 ;;;_ = icomplete-minibuffer-setup-hook
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
79 (defvar icomplete-minibuffer-setup-hook nil
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
80 "*Icomplete-specific customization of minibuffer setup.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
81
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
82 This hook is run during minibuffer setup iff icomplete will be active.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
83 It is intended for use in customizing icomplete for interoperation
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
84 with other packages. For instance:
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
85
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
86 \(add-hook 'icomplete-minibuffer-setup-hook
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
87 \(function
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
88 \(lambda ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
89 \(make-local-variable 'resize-minibuffer-window-max-height)
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
90 \(setq resize-minibuffer-window-max-height 3))))
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
91
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
92 will constrain rsz-mini to a maximum minibuffer height of 3 lines when
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
93 icompletion is occurring.")
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
95 ;;;_ + Internal Variables
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
96 ;;;_ = icomplete-mode
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
97 (defvar icomplete-mode t
18251
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
98 "*Non-nil enables incremental minibuffer completion (see \\[icomplete-mode].")
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
99 ;;;_ = icomplete-eoinput 1
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (defvar icomplete-eoinput 1
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 "Point where minibuffer input ends and completion info begins.")
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (make-variable-buffer-local 'icomplete-eoinput)
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
103 ;;;_ = icomplete-pre-command-hook
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
104 (defvar icomplete-pre-command-hook nil
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
105 "Incremental-minibuffer-completion pre-command-hook.
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
106
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
107 Is run in minibuffer before user input when `icomplete-mode' is non-nil.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
108 Use `icomplete-mode' function to set it up properly for incremental
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
109 minibuffer completion.")
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
110 (add-hook 'icomplete-pre-command-hook 'icomplete-tidy)
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
111 ;;;_ = icomplete-post-command-hook
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
112 (defvar icomplete-post-command-hook nil
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
113 "Incremental-minibuffer-completion post-command-hook.
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
115 Is run in minibuffer after user input when `icomplete-mode' is non-nil.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
116 Use `icomplete-mode' function to set it up properly for incremental
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
117 minibuffer completion.")
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
118 (add-hook 'icomplete-post-command-hook 'icomplete-exhibit)
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
119
18251
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
120 (defvar icomplete-show-key-bindings t
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
121 "*When non-nil, show key bindings as well as completion for sole matches.")
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
122
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
123 (defun icomplete-get-keys (func-name)
18251
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
124 "Return strings naming keys bound to `func-name', or nil if none.
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
125 Examines the prior, not current, buffer, presuming that current buffer
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
126 is minibuffer."
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
127 (if (commandp func-name)
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
128 (save-excursion
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
129 (let* ((sym (intern func-name))
18251
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
130 (buf (other-buffer))
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
131 (map (save-excursion (set-buffer buf) (current-local-map)))
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
132 (keys (where-is-internal sym map)))
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
133 (if keys
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
134 (concat "<"
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
135 (mapconcat 'key-description
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
136 (sort keys
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
137 #'(lambda (x y)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
138 (< (length x) (length y))))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
139 ", ")
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
140 ">"))))))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
141
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
142 ;;;_ > icomplete-mode (&optional prefix)
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
143 ;;;###autoload
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
144 (defun icomplete-mode (&optional prefix)
18251
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
145 "Activate incremental minibuffer completion for this Emacs session.
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
146 Deactivates with negative universal argument."
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
147 (interactive "p")
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
148 (or prefix (setq prefix 0))
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
149 (cond ((>= prefix 0)
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
150 (setq icomplete-mode t)
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
151 ;; The following is not really necessary after first time -
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
152 ;; no great loss.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
153 (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup))
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
154 (t (setq icomplete-mode nil))))
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
156 ;;;_ > icomplete-simple-completing-p ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
157 (defun icomplete-simple-completing-p ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
158 "Non-nil if current window is minibuffer that's doing simple completion.
8434
36da3d480ccd (icomplete-prime-minibuffer): Copy the hook lists after making them local.
Richard M. Stallman <rms@gnu.org>
parents: 5375
diff changeset
159
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
160 Conditions are:
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
161 the selected window is a minibuffer,
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
162 and not in the middle of macro execution,
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
163 and minibuffer-completion-table is not a symbol (which would
13989
d60fffb9acd1 (icomplete-simple-completing-p, icomplete-completions):
Karl Heuer <kwzh@gnu.org>
parents: 13337
diff changeset
164 indicate some non-standard, non-simple completion mechanism,
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
165 like file-name and other custom-func completions)."
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
166
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
167 (and (window-minibuffer-p (selected-window))
15302
c23c9712ef5c Use executing-kbd-macro, not executing-macro.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
168 (not executing-kbd-macro)
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
169 (not (symbolp minibuffer-completion-table))))
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
170
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
171 ;;;_ > icomplete-minibuffer-setup ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
172 ;;;###autoload
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
173 (defun icomplete-minibuffer-setup ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
174 "Run in minibuffer on activation to establish incremental completion.
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
175 Usually run by inclusion in `minibuffer-setup-hook'."
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
176 (cond ((and icomplete-mode (icomplete-simple-completing-p))
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
177 (make-local-hook 'pre-command-hook)
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
178 (add-hook 'pre-command-hook
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
179 (function (lambda ()
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
180 (run-hooks 'icomplete-pre-command-hook)))
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
181 nil t)
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
182 (make-local-hook 'post-command-hook)
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
183 (add-hook 'post-command-hook
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
184 (function (lambda ()
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
185 (run-hooks 'icomplete-post-command-hook)))
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
186 nil t)
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
187 (run-hooks 'icomplete-minibuffer-setup-hook))))
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
188
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
189 ;;;_* Completion
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
190
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
191 ;;;_ > icomplete-tidy ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
192 (defun icomplete-tidy ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
193 "Remove completions display \(if any) prior to new user input.
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
194 Should be run in on the minibuffer `pre-command-hook'. See `icomplete-mode'
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
195 and `minibuffer-setup-hook'."
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
196 (if (icomplete-simple-completing-p)
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (if (and (boundp 'icomplete-eoinput)
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 icomplete-eoinput)
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
199
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (if (> icomplete-eoinput (point-max))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 ;; Oops, got rug pulled out from under us - reinit:
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (setq icomplete-eoinput (point-max))
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
203 (let ((buffer-undo-list buffer-undo-list )) ; prevent entry
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (delete-region icomplete-eoinput (point-max))))
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
205
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
206 ;; Reestablish the local variable 'cause minibuffer-setup is weird:
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (make-local-variable 'icomplete-eoinput)
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (setq icomplete-eoinput 1))))
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
209
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
210 ;;;_ > icomplete-exhibit ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
211 (defun icomplete-exhibit ()
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
212 "Insert icomplete completions display.
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
213 Should be run via minibuffer `post-command-hook'. See `icomplete-mode'
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
214 and `minibuffer-setup-hook'."
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
215 (if (icomplete-simple-completing-p)
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (let ((contents (buffer-substring (point-min)(point-max)))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (buffer-undo-list t))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (save-excursion
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (goto-char (point-max))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ; Register the end of input, so we
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 ; know where the extra stuff
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 ; (match-status info) begins:
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (if (not (boundp 'icomplete-eoinput))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 ;; In case it got wiped out by major mode business:
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (make-local-variable 'icomplete-eoinput))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (setq icomplete-eoinput (point))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 ; Insert the match-status information:
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
228 (if (and (> (point-max) 1)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
229 (or
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
230 ;; Don't bother with delay after certain number of chars:
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
231 (> (point-max) icomplete-max-delay-chars)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
232 ;; Don't delay if alternatives number is small enough:
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
233 (if minibuffer-completion-table
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
234 (cond ((numberp minibuffer-completion-table)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
235 (< minibuffer-completion-table
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
236 icomplete-delay-completions-threshold))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
237 ((sequencep minibuffer-completion-table)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
238 (< (length minibuffer-completion-table)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
239 icomplete-delay-completions-threshold))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
240 ))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
241 ;; Delay - give some grace time for next keystroke, before
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
242 ;; embarking on computing completions:
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
243 (sit-for icomplete-compute-delay)))
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (insert-string
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
245 (icomplete-completions contents
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
246 minibuffer-completion-table
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
247 minibuffer-completion-predicate
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
248 (not
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
249 minibuffer-completion-confirm))))))))
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
250
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
251 ;;;_ > icomplete-completions (name candidates predicate require-match)
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
252 (defun icomplete-completions (name candidates predicate require-match)
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 "Identify prospective candidates for minibuffer completion.
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254
5375
0e30cf7aa525 (icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents: 5147
diff changeset
255 The display is updated with each minibuffer keystroke during
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 minibuffer completion.
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 Prospective completion suffixes (if any) are displayed, bracketed by
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 one of \(), \[], or \{} pairs. The choice of brackets is as follows:
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 \(...) - a single prospect is identified and matching is enforced,
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 \[...] - a single prospect is identified but matching is optional, or
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 \{...} - multiple prospects, separated by commas, are indicated, and
13989
d60fffb9acd1 (icomplete-simple-completing-p, icomplete-completions):
Karl Heuer <kwzh@gnu.org>
parents: 13337
diff changeset
264 further input is required to distinguish a single one.
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265
13989
d60fffb9acd1 (icomplete-simple-completing-p, icomplete-completions):
Karl Heuer <kwzh@gnu.org>
parents: 13337
diff changeset
266 The displays for unambiguous matches have ` [Matched]' appended
12933
61f11030ecc9 (icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents: 11035
diff changeset
267 \(whether complete or not), or ` \[No matches]', if no eligible
18251
e0327e90d706 Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents: 18060
diff changeset
268 matches exist. \(Keybindings for uniquely matched commands
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
269 are exhibited within the square braces.)"
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
270
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
271 ;; 'all-completions' doesn't like empty
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
272 ;; minibuffer-completion-table's (ie: (nil))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
273 (if (and (listp candidates) (null (car candidates)))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
274 (setq candidates nil))
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (let ((comps (all-completions name candidates predicate))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 ; "-determined" - only one candidate
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (open-bracket-determined (if require-match "(" "["))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (close-bracket-determined (if require-match ")" "]"))
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 ;"-prospects" - more than one candidate
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (open-bracket-prospects "{")
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (close-bracket-prospects "}")
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 )
18029
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
284 (catch 'input
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
285 (cond ((null comps) (format " %sNo matches%s"
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
286 open-bracket-determined
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
287 close-bracket-determined))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
288 ((null (cdr comps)) ;one match
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
289 (concat (if (and (> (length (car comps))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
290 (length name)))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
291 (concat open-bracket-determined
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
292 (substring (car comps) (length name))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
293 close-bracket-determined)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
294 "")
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
295 " [Matched"
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
296 (let ((keys (and icomplete-show-key-bindings
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
297 (commandp (intern-soft (car comps)))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
298 (icomplete-get-keys (car comps)))))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
299 (if keys
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
300 (concat "; " keys)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
301 ""))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
302 "]"))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
303 (t ;multiple matches
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
304 (let* ((most
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
305 (try-completion name candidates
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
306 (and predicate
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
307 ;; Wrap predicate in impatience - ie,
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
308 ;; `throw' up when pending input is
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
309 ;; noticed. Adds some overhead to
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
310 ;; predicate, but should be worth it.
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
311 (function
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
312 (lambda (item)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
313 (if (input-pending-p)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
314 (throw 'input "")
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
315 (apply predicate
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
316 item nil)))))))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
317 (most-len (length most))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
318 most-is-exact
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
319 (alternatives
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
320 (substring
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
321 (apply (function concat)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
322 (mapcar (function
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
323 (lambda (com)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
324 (if (input-pending-p)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
325 (throw 'input ""))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
326 (if (= (length com) most-len)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
327 ;; Most is one exact match,
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
328 ;; note that and leave out
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
329 ;; for later indication:
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
330 (progn
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
331 (setq most-is-exact t)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
332 ())
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
333 (concat ","
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
334 (substring com
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
335 most-len)))))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
336 comps))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
337 1)))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
338 (concat (and (> most-len (length name))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
339 (concat open-bracket-determined
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
340 (substring most (length name))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
341 close-bracket-determined))
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
342 open-bracket-prospects
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
343 (if most-is-exact
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
344 ;; Add a ',' at the front to indicate "complete but
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
345 ;; not unique":
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
346 (concat "," alternatives)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
347 alternatives)
82a56bdb2381 Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents: 15302
diff changeset
348 close-bracket-prospects)))))))
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349
8871
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
350 ;;;_* Local emacs vars.
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
351 ;;;Local variables:
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
352 ;;;outline-layout: (-2 :)
299cfe0a6069 Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents: 8434
diff changeset
353 ;;;End:
5147
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354
54b3438dfc7f Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 ;;; icomplete.el ends here