Mercurial > emacs
annotate lisp/icomplete.el @ 27444:89c53b25be12
(checkdoc-interactive-loop): Don't lose on a function with an empty
body.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 26 Jan 2000 17:15:13 +0000 |
parents | b190fee70d54 |
children | 23a0f9dcc01d |
rev | line source |
---|---|
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
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 |
26518 | 3 ;; Copyright (C) 1992, 1993, 1994, 1997, 1999 Free Software Foundation, Inc. |
5147 | 4 |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
5 ;; Author: Ken Manheimer <klm@i.am> |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
6 ;; Maintainer: Ken Manheimer <klm@i.am> |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
7 ;; Created: Mar 1993 Ken Manheimer, klm@nist.gov - first release to usenet |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
8 ;; Last update: Ken Manheimer <klm@i.am>, 11/18/1999. |
13337 | 9 ;; Keywords: help, abbrev |
5147 | 10 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
11 ;; 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
|
12 |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
13 ;; 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
|
14 ;; 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
|
15 ;; 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
|
16 ;; any later version. |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
17 |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
18 ;; 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
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
23 ;; You should have received a copy of the GNU General Public License |
14169 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 ;; 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
|
27 |
5147 | 28 ;;; Commentary: |
29 | |
14169 | 30 ;; Loading this package implements a more fine-grained minibuffer |
31 ;; completion feedback scheme. Prospective completions are concisely | |
32 ;; indicated within the minibuffer itself, with each successive | |
33 ;; keystroke. | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
34 |
20764 | 35 ;; See `icomplete-completions' docstring for a description of the |
14169 | 36 ;; icomplete display format. |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
37 |
14169 | 38 ;; See the `icomplete-minibuffer-setup-hook' docstring for a means to |
39 ;; customize icomplete setup for interoperation with other | |
40 ;; minibuffer-oriented packages. | |
5147 | 41 |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
42 ;; To activate icomplete mode, load the package and use the |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
43 ;; `icomplete-mode' function. You can subsequently deactivate it by |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
44 ;; invoking the function icomplete-mode with a negative prefix-arg |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
45 ;; (C-U -1 ESC-x icomplete-mode). Also, you can prevent activation of |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
46 ;; the mode during package load by first setting the variable |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
47 ;; `icomplete-mode' to nil. Icompletion can be enabled any time after |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
48 ;; the package is loaded by invoking icomplete-mode without a prefix |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
49 ;; arg. |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
50 |
14169 | 51 ;; Thanks to everyone for their suggestions for refinements of this |
52 ;; package. I particularly have to credit Michael Cook, who | |
53 ;; implemented an incremental completion style in his 'iswitch' | |
54 ;; functions that served as a model for icomplete. Some other | |
20764 | 55 ;; contributors: Noah Friedman (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
|
56 ;; 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
|
57 |
14169 | 58 ;; klm. |
5147 | 59 |
60 ;;; Code: | |
61 | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
62 ;;;_* Provide |
5147 | 63 (provide 'icomplete) |
64 | |
20764 | 65 |
66 (defgroup icomplete nil | |
67 "Show completions dynamically in minibuffer." | |
68 :prefix "icomplete-" | |
69 :group 'minibuffer) | |
70 | |
71 (defcustom icomplete-mode nil | |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
72 "*Toggle incremental minibuffer completion. |
20764 | 73 As text is typed into the minibuffer, prospective completions are indicated |
74 in the minibuffer. | |
24644 | 75 Setting this variable directly does not take effect; |
76 use either \\[customize] or the function `icomplete-mode'." | |
20764 | 77 :set (lambda (symbol value) |
78 (icomplete-mode (if value 1 -1))) | |
79 :initialize 'custom-initialize-default | |
80 :type 'boolean | |
81 :group 'icomplete | |
82 :require 'icomplete) | |
83 | |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
84 ;;;_* User Customization variables |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
85 (defcustom icomplete-prospects-length 80 |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
86 "*Length of string displaying the prospects." |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
87 :type 'integer |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
88 :group 'icomplete) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
89 |
20764 | 90 (defcustom icomplete-compute-delay .3 |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
91 "*Completions-computation stall, used only with large-number |
20764 | 92 completions - see `icomplete-delay-completions-threshold'." |
93 :type 'number | |
94 :group 'icomplete) | |
95 | |
96 (defcustom icomplete-delay-completions-threshold 400 | |
97 "*Pending-completions number over which to apply icomplete-compute-delay." | |
98 :type 'integer | |
99 :group 'icomplete) | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
100 |
20764 | 101 (defcustom icomplete-max-delay-chars 3 |
102 "*Maximum number of initial chars to apply icomplete compute delay." | |
103 :type 'integer | |
104 :group 'icomplete) | |
105 | |
106 (defcustom icomplete-show-key-bindings t | |
107 "*If non-nil, show key bindings as well as completion for sole matches." | |
108 :type 'boolean | |
109 :group 'icomplete) | |
110 | |
111 (defcustom icomplete-minibuffer-setup-hook nil | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
112 "*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
|
113 |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
118 \(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
|
119 \(function |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
120 \(lambda () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
121 \(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
|
122 \(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
|
123 |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
124 will constrain rsz-mini to a maximum minibuffer height of 3 lines when |
20764 | 125 icompletion is occurring." |
126 :type 'hook | |
127 :group 'icomplete) | |
128 | |
129 | |
130 ;;;_* Initialization | |
5147 | 131 |
5375
0e30cf7aa525
(icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents:
5147
diff
changeset
|
132 ;;;_ + Internal Variables |
0e30cf7aa525
(icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents:
5147
diff
changeset
|
133 ;;;_ = icomplete-eoinput 1 |
5147 | 134 (defvar icomplete-eoinput 1 |
135 "Point where minibuffer input ends and completion info begins.") | |
136 (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
|
137 ;;;_ = icomplete-pre-command-hook |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
138 (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
|
139 "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
|
140 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
141 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
|
142 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
|
143 minibuffer completion.") |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
144 (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
|
145 ;;;_ = icomplete-post-command-hook |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
146 (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
|
147 "Incremental-minibuffer-completion post-command-hook. |
5147 | 148 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
149 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
|
150 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
|
151 minibuffer completion.") |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
152 (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
|
153 |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
154 (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
|
155 "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
|
156 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
|
157 is minibuffer." |
e0327e90d706
Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents:
18060
diff
changeset
|
158 (if (commandp func-name) |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
159 (save-excursion |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
160 (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
|
161 (buf (other-buffer)) |
e0327e90d706
Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents:
18060
diff
changeset
|
162 (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
|
163 (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
|
164 (if keys |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
165 (concat "<" |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
166 (mapconcat 'key-description |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
167 (sort keys |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
168 #'(lambda (x y) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
169 (< (length x) (length y)))) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
170 ", ") |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
171 ">")))))) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
172 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
173 ;;;_ > icomplete-mode (&optional prefix) |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
174 ;;;###autoload |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
175 (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
|
176 "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
|
177 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
|
178 (interactive "p") |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
179 (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
|
180 (cond ((>= prefix 0) |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
181 (setq icomplete-mode t) |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
182 ;; 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
|
183 ;; no great loss. |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
184 (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
|
185 (t (setq icomplete-mode nil)))) |
5147 | 186 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
187 ;;;_ > icomplete-simple-completing-p () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
188 (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
|
189 "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
|
190 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
191 Conditions are: |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
198 (and (window-minibuffer-p (selected-window)) |
15302
c23c9712ef5c
Use executing-kbd-macro, not executing-macro.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
199 (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
|
200 (not (symbolp minibuffer-completion-table)))) |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
201 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
202 ;;;_ > icomplete-minibuffer-setup () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
203 ;;;###autoload |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
204 (defun icomplete-minibuffer-setup () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
205 "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
|
206 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
|
207 (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
|
208 (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
|
209 (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
|
210 (function (lambda () |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
211 (run-hooks 'icomplete-pre-command-hook))) |
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
212 nil t) |
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
213 (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
|
214 (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
|
215 (function (lambda () |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
216 (run-hooks 'icomplete-post-command-hook))) |
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
217 nil t) |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
218 (run-hooks 'icomplete-minibuffer-setup-hook)))) |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
219 ; |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
220 |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
221 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
222 ;;;_* Completion |
5375
0e30cf7aa525
(icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents:
5147
diff
changeset
|
223 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
224 ;;;_ > icomplete-tidy () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
225 (defun icomplete-tidy () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
226 "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
|
227 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
|
228 and `minibuffer-setup-hook'." |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
229 (if (icomplete-simple-completing-p) |
5147 | 230 (if (and (boundp 'icomplete-eoinput) |
231 icomplete-eoinput) | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
232 |
5147 | 233 (if (> icomplete-eoinput (point-max)) |
234 ;; Oops, got rug pulled out from under us - reinit: | |
235 (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
|
236 (let ((buffer-undo-list buffer-undo-list )) ; prevent entry |
5147 | 237 (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
|
238 |
5375
0e30cf7aa525
(icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents:
5147
diff
changeset
|
239 ;; Reestablish the local variable 'cause minibuffer-setup is weird: |
5147 | 240 (make-local-variable 'icomplete-eoinput) |
241 (setq icomplete-eoinput 1)))) | |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
242 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
243 ;;;_ > icomplete-exhibit () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
244 (defun icomplete-exhibit () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
245 "Insert icomplete completions display. |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
246 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
|
247 and `minibuffer-setup-hook'." |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
248 (if (icomplete-simple-completing-p) |
27023
b190fee70d54
(icomplete-exhibit): Adapt to prompt in buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26518
diff
changeset
|
249 (let ((contents (buffer-substring (minibuffer-prompt-end)(point-max))) |
5147 | 250 (buffer-undo-list t)) |
251 (save-excursion | |
252 (goto-char (point-max)) | |
253 ; Register the end of input, so we | |
254 ; know where the extra stuff | |
255 ; (match-status info) begins: | |
256 (if (not (boundp 'icomplete-eoinput)) | |
257 ;; In case it got wiped out by major mode business: | |
258 (make-local-variable 'icomplete-eoinput)) | |
259 (setq icomplete-eoinput (point)) | |
260 ; Insert the match-status information: | |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
261 (if (and (> (point-max) 1) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
262 (or |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
263 ;; 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
|
264 (> (point-max) icomplete-max-delay-chars) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
265 ;; 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
|
266 (if minibuffer-completion-table |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
267 (cond ((numberp minibuffer-completion-table) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
268 (< minibuffer-completion-table |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
269 icomplete-delay-completions-threshold)) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
270 ((sequencep minibuffer-completion-table) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
271 (< (length minibuffer-completion-table) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
272 icomplete-delay-completions-threshold)) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
273 )) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
274 ;; 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
|
275 ;; embarking on computing completions: |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
276 (sit-for icomplete-compute-delay))) |
5147 | 277 (insert-string |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
278 (icomplete-completions contents |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
279 minibuffer-completion-table |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
280 minibuffer-completion-predicate |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
281 (not |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
282 minibuffer-completion-confirm)))))))) |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
283 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
284 ;;;_ > 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
|
285 (defun icomplete-completions (name candidates predicate require-match) |
5147 | 286 "Identify prospective candidates for minibuffer completion. |
287 | |
5375
0e30cf7aa525
(icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents:
5147
diff
changeset
|
288 The display is updated with each minibuffer keystroke during |
5147 | 289 minibuffer completion. |
290 | |
291 Prospective completion suffixes (if any) are displayed, bracketed by | |
292 one of \(), \[], or \{} pairs. The choice of brackets is as follows: | |
293 | |
294 \(...) - a single prospect is identified and matching is enforced, | |
295 \[...] - a single prospect is identified but matching is optional, or | |
296 \{...} - 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
|
297 further input is required to distinguish a single one. |
5147 | 298 |
13989
d60fffb9acd1
(icomplete-simple-completing-p, icomplete-completions):
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
299 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
|
300 \(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
|
301 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
|
302 are exhibited within the square braces.)" |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
303 |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
304 ;; 'all-completions' doesn't like empty |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
305 ;; minibuffer-completion-table's (ie: (nil)) |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
306 (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
|
307 (setq candidates nil)) |
5147 | 308 |
309 (let ((comps (all-completions name candidates predicate)) | |
310 ; "-determined" - only one candidate | |
311 (open-bracket-determined (if require-match "(" "[")) | |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
312 (close-bracket-determined (if require-match ")" "]"))) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
313 ;; `concat'/`mapconcat' is the slow part. With the introduction of |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
314 ;; `icomplete-prospects-length', there is no need for `catch'/`throw'. |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
315 (if (null comps) (format " %sNo matches%s" |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
316 open-bracket-determined |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
317 close-bracket-determined) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
318 (let* ((most-try (try-completion name (mapcar (function list) comps))) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
319 (most (if (stringp most-try) most-try (car comps))) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
320 (most-len (length most)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
321 (determ (and (> most-len (length name)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
322 (concat open-bracket-determined |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
323 (substring most (length name)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
324 close-bracket-determined))) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
325 (open-bracket-prospects "{") |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
326 (close-bracket-prospects "}") |
5147 | 327 ;"-prospects" - more than one candidate |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
328 (prospects-len 0) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
329 prospects most-is-exact comp) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
330 (if (eq most-try t) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
331 (setq prospects nil) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
332 (while (and comps (< prospects-len icomplete-prospects-length)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
333 (setq comp (substring (car comps) most-len) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
334 comps (cdr comps)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
335 (cond ((string-equal comp "") (setq most-is-exact t)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
336 ((member comp prospects)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
337 (t (setq prospects (cons comp prospects) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
338 prospects-len (+ (length comp) 1 prospects-len)))))) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
339 (if prospects |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
340 (concat determ |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
341 open-bracket-prospects |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
342 (and most-is-exact ",") |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
343 (mapconcat 'identity |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
344 (sort prospects (function string-lessp)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
345 ",") |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
346 (and comps ",...") |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
347 close-bracket-prospects) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
348 (concat determ |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
349 " [Matched" |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
350 (let ((keys (and icomplete-show-key-bindings |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
351 (commandp (intern-soft most)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
352 (icomplete-get-keys most)))) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
353 (if keys |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
354 (concat "; " keys) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
355 "")) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
356 "]")))))) |
5147 | 357 |
20764 | 358 (if icomplete-mode |
359 (icomplete-mode 1)) | |
360 | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
361 ;;;_* Local emacs vars. |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
362 ;;;Local variables: |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
363 ;;;outline-layout: (-2 :) |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
364 ;;;End: |
5147 | 365 |
366 ;;; icomplete.el ends here |