Mercurial > emacs
annotate lisp/icomplete.el @ 98392:7c5cb1da6c7f
(locate-dominating-file): Take file-attributes of `dir', not of `file'
(which never changes).
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Mon, 29 Sep 2008 11:30:03 +0000 |
parents | 27c911ed0a73 |
children | 5de002dfa264 |
rev | line source |
---|---|
29154 | 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 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 1992, 1993, 1994, 1997, 1999, 2001, 2002, 2003, |
79721 | 4 ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
5147 | 5 |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
6 ;; Author: Ken Manheimer <klm@i.am> |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
7 ;; Maintainer: Ken Manheimer <klm@i.am> |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
8 ;; 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
|
9 ;; Last update: Ken Manheimer <klm@i.am>, 11/18/1999. |
13337 | 10 ;; Keywords: help, abbrev |
5147 | 11 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
12 ;; 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
|
13 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93101
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
15 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93101
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93101
diff
changeset
|
17 ;; (at your option) any later version. |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
18 |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 ;; 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
|
23 |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
24 ;; You should have received a copy of the GNU General Public License |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93101
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
26 |
5147 | 27 ;;; Commentary: |
28 | |
14169 | 29 ;; Loading this package implements a more fine-grained minibuffer |
30 ;; completion feedback scheme. Prospective completions are concisely | |
31 ;; indicated within the minibuffer itself, with each successive | |
32 ;; keystroke. | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
33 |
20764 | 34 ;; See `icomplete-completions' docstring for a description of the |
14169 | 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 | 37 ;; See the `icomplete-minibuffer-setup-hook' docstring for a means to |
38 ;; customize icomplete setup for interoperation with other | |
39 ;; minibuffer-oriented packages. | |
5147 | 40 |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
41 ;; 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
|
42 ;; `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
|
43 ;; 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
|
44 ;; (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
|
45 ;; 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
|
46 ;; `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
|
47 ;; 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
|
48 ;; arg. |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
49 |
14169 | 50 ;; Thanks to everyone for their suggestions for refinements of this |
51 ;; package. I particularly have to credit Michael Cook, who | |
52 ;; implemented an incremental completion style in his 'iswitch' | |
53 ;; functions that served as a model for icomplete. Some other | |
20764 | 54 ;; 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
|
55 ;; 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
|
56 |
14169 | 57 ;; klm. |
5147 | 58 |
59 ;;; Code: | |
60 | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
61 ;;;_* Provide |
5147 | 62 (provide 'icomplete) |
63 | |
20764 | 64 |
65 (defgroup icomplete nil | |
66 "Show completions dynamically in minibuffer." | |
67 :prefix "icomplete-" | |
68 :group 'minibuffer) | |
69 | |
95386
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
70 (defvar icomplete-prospects-length 80) |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
71 (make-obsolete-variable |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
72 'icomplete-prospects-length 'icomplete-prospects-height "23.1") |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
73 |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
74 ;;;_* User Customization variables |
95386
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
75 (defcustom icomplete-prospects-height |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
76 ;; 20 is an estimated common size for the prompt + minibuffer content, to |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
77 ;; try to guess the number of lines used up by icomplete-prospects-length. |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
78 (+ 1 (/ (+ icomplete-prospects-length 20) (window-width))) |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
79 "Maximum number of lines to use in the minibuffer." |
95391
436059aff075
(icomplete-prospects-height): Add :group.
Juanma Barranquero <lekktu@gmail.com>
parents:
95390
diff
changeset
|
80 :type 'integer |
436059aff075
(icomplete-prospects-height): Add :group.
Juanma Barranquero <lekktu@gmail.com>
parents:
95390
diff
changeset
|
81 :group 'icomplete) |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
82 |
20764 | 83 (defcustom icomplete-compute-delay .3 |
93099
898c706f1ace
(icomplete-prospects-length, icomplete-max-delay-chars,
Juanma Barranquero <lekktu@gmail.com>
parents:
92743
diff
changeset
|
84 "Completions-computation stall, used only with large-number completions. |
898c706f1ace
(icomplete-prospects-length, icomplete-max-delay-chars,
Juanma Barranquero <lekktu@gmail.com>
parents:
92743
diff
changeset
|
85 See `icomplete-delay-completions-threshold'." |
20764 | 86 :type 'number |
87 :group 'icomplete) | |
88 | |
89 (defcustom icomplete-delay-completions-threshold 400 | |
93099
898c706f1ace
(icomplete-prospects-length, icomplete-max-delay-chars,
Juanma Barranquero <lekktu@gmail.com>
parents:
92743
diff
changeset
|
90 "Pending-completions number over which to apply `icomplete-compute-delay'." |
20764 | 91 :type 'integer |
92 :group 'icomplete) | |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
93 |
20764 | 94 (defcustom icomplete-max-delay-chars 3 |
93099
898c706f1ace
(icomplete-prospects-length, icomplete-max-delay-chars,
Juanma Barranquero <lekktu@gmail.com>
parents:
92743
diff
changeset
|
95 "Maximum number of initial chars to apply icomplete compute delay." |
20764 | 96 :type 'integer |
97 :group 'icomplete) | |
98 | |
99 (defcustom icomplete-show-key-bindings t | |
93099
898c706f1ace
(icomplete-prospects-length, icomplete-max-delay-chars,
Juanma Barranquero <lekktu@gmail.com>
parents:
92743
diff
changeset
|
100 "If non-nil, show key bindings as well as completion for sole matches." |
20764 | 101 :type 'boolean |
102 :group 'icomplete) | |
103 | |
104 (defcustom icomplete-minibuffer-setup-hook nil | |
93099
898c706f1ace
(icomplete-prospects-length, icomplete-max-delay-chars,
Juanma Barranquero <lekktu@gmail.com>
parents:
92743
diff
changeset
|
105 "Icomplete-specific customization of minibuffer setup. |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
106 |
78492
7c8949dbfa0d
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78236
diff
changeset
|
107 This hook is run during minibuffer setup if icomplete is active. |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
108 It is intended for use in customizing icomplete for interoperation |
35467
d9a298a82b9a
(icomplete-minibuffer-setup-hook): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
29154
diff
changeset
|
109 with other features and packages. For instance: |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
110 |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
111 \(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
|
112 \(function |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
113 \(lambda () |
35467
d9a298a82b9a
(icomplete-minibuffer-setup-hook): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
29154
diff
changeset
|
114 \(make-local-variable 'max-mini-window-height) |
d9a298a82b9a
(icomplete-minibuffer-setup-hook): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
29154
diff
changeset
|
115 \(setq max-mini-window-height 3)))) |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
116 |
35467
d9a298a82b9a
(icomplete-minibuffer-setup-hook): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
29154
diff
changeset
|
117 will constrain Emacs to a maximum minibuffer height of 3 lines when |
20764 | 118 icompletion is occurring." |
119 :type 'hook | |
120 :group 'icomplete) | |
121 | |
122 | |
123 ;;;_* Initialization | |
5147 | 124 |
5375
0e30cf7aa525
(icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents:
5147
diff
changeset
|
125 ;;;_ + Internal Variables |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
126 ;;;_ = icomplete-eoinput nil |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
127 (defvar icomplete-overlay (make-overlay (point-min) (point-min) nil t t) |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
128 "Overlay used to display the list of completions.") |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
129 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
130 ;;;_ = icomplete-pre-command-hook |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
131 (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
|
132 "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
|
133 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
134 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
|
135 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
|
136 minibuffer completion.") |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
137 (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
|
138 ;;;_ = icomplete-post-command-hook |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
139 (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
|
140 "Incremental-minibuffer-completion post-command-hook. |
5147 | 141 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
142 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
|
143 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
|
144 minibuffer completion.") |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
145 (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
|
146 |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
147 (defun icomplete-get-keys (func-name) |
95448
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
148 "Return strings naming keys bound to FUNC-NAME, or nil if none. |
18251
e0327e90d706
Don't call icomplete-mode; let the user do that.
Richard M. Stallman <rms@gnu.org>
parents:
18060
diff
changeset
|
149 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
|
150 is minibuffer." |
95448
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
151 (when (commandp func-name) |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
152 (save-excursion |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
153 (let* ((sym (intern func-name)) |
68983
064f4da012f5
(icomplete-get-keys): Use `t' for the second arg `visible-ok'
Juri Linkov <juri@jurta.org>
parents:
68866
diff
changeset
|
154 (buf (other-buffer nil t)) |
79872
63a2e3bc921c
(icomplete-get-keys): Look up KEYS using all maps in proper buffer.
Richard M. Stallman <rms@gnu.org>
parents:
79721
diff
changeset
|
155 (keys (with-current-buffer buf (where-is-internal sym)))) |
95448
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
156 (when keys |
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
157 (concat "<" |
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
158 (mapconcat 'key-description |
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
159 (sort keys |
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
160 #'(lambda (x y) |
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
161 (< (length x) (length y)))) |
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
162 ", ") |
27c911ed0a73
(icomplete-get-keys): Doc fix. Use `when'.
Juanma Barranquero <lekktu@gmail.com>
parents:
95391
diff
changeset
|
163 ">")))))) |
73078
4bf12abbb384
2006-09-23 Ken Manheimer <ken.manheimer@gmail.com>
Chong Yidong <cyd@stupidchicken.com>
parents:
68983
diff
changeset
|
164 ;;;_ = icomplete-with-completion-tables |
4bf12abbb384
2006-09-23 Ken Manheimer <ken.manheimer@gmail.com>
Chong Yidong <cyd@stupidchicken.com>
parents:
68983
diff
changeset
|
165 (defvar icomplete-with-completion-tables '(internal-complete-buffer) |
4bf12abbb384
2006-09-23 Ken Manheimer <ken.manheimer@gmail.com>
Chong Yidong <cyd@stupidchicken.com>
parents:
68983
diff
changeset
|
166 "Specialized completion tables with which icomplete should operate. |
4bf12abbb384
2006-09-23 Ken Manheimer <ken.manheimer@gmail.com>
Chong Yidong <cyd@stupidchicken.com>
parents:
68983
diff
changeset
|
167 |
4bf12abbb384
2006-09-23 Ken Manheimer <ken.manheimer@gmail.com>
Chong Yidong <cyd@stupidchicken.com>
parents:
68983
diff
changeset
|
168 Icomplete does not operate with any specialized completion tables |
4bf12abbb384
2006-09-23 Ken Manheimer <ken.manheimer@gmail.com>
Chong Yidong <cyd@stupidchicken.com>
parents:
68983
diff
changeset
|
169 except those on this list.") |
18029
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
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-mode (&optional prefix) |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
172 ;;;###autoload |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
173 (define-minor-mode icomplete-mode |
37171
b2411ccdbf22
(icomplete-mode): Treat an argument like other
Gerd Moellmann <gerd@gnu.org>
parents:
35467
diff
changeset
|
174 "Toggle incremental minibuffer completion for this Emacs session. |
78492
7c8949dbfa0d
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78236
diff
changeset
|
175 With a numeric argument, turn Icomplete mode on if ARG is positive, |
7c8949dbfa0d
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78236
diff
changeset
|
176 otherwise turn it off." |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
177 :global t :group 'icomplete |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
178 (if icomplete-mode |
37171
b2411ccdbf22
(icomplete-mode): Treat an argument like other
Gerd Moellmann <gerd@gnu.org>
parents:
35467
diff
changeset
|
179 ;; The following is not really necessary after first time - |
b2411ccdbf22
(icomplete-mode): Treat an argument like other
Gerd Moellmann <gerd@gnu.org>
parents:
35467
diff
changeset
|
180 ;; no great loss. |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
181 (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
182 (remove-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup))) |
5147 | 183 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
184 ;;;_ > icomplete-simple-completing-p () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
185 (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
|
186 "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
|
187 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
188 Conditions are: |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
189 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
|
190 and not in the middle of macro execution, |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
191 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
|
192 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
|
193 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
|
194 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
195 (and (window-minibuffer-p (selected-window)) |
15302
c23c9712ef5c
Use executing-kbd-macro, not executing-macro.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
196 (not executing-kbd-macro) |
60853
53a24edea9ee
(icomplete-simple-completing-p): Don't turn on icomplete
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60805
diff
changeset
|
197 minibuffer-completion-table |
73078
4bf12abbb384
2006-09-23 Ken Manheimer <ken.manheimer@gmail.com>
Chong Yidong <cyd@stupidchicken.com>
parents:
68983
diff
changeset
|
198 (or (not (functionp minibuffer-completion-table)) |
95121
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
199 (eq icomplete-with-completion-tables t) |
73078
4bf12abbb384
2006-09-23 Ken Manheimer <ken.manheimer@gmail.com>
Chong Yidong <cyd@stupidchicken.com>
parents:
68983
diff
changeset
|
200 (member minibuffer-completion-table |
73095
9566558723f8
* icomplete.el (icomplete-simple-completing-p): Use the correct
Chong Yidong <cyd@stupidchicken.com>
parents:
73078
diff
changeset
|
201 icomplete-with-completion-tables)))) |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
202 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
203 ;;;_ > icomplete-minibuffer-setup () |
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'." |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
207 (when (and icomplete-mode (icomplete-simple-completing-p)) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
208 (add-hook 'pre-command-hook |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
209 (lambda () (run-hooks 'icomplete-pre-command-hook)) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
210 nil t) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
211 (add-hook 'post-command-hook |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
212 (lambda () (run-hooks 'icomplete-post-command-hook)) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
213 nil t) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
214 (run-hooks 'icomplete-minibuffer-setup-hook))) |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
215 ; |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
216 |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
217 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
218 ;;;_* Completion |
5375
0e30cf7aa525
(icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents:
5147
diff
changeset
|
219 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
220 ;;;_ > icomplete-tidy () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
221 (defun icomplete-tidy () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
222 "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
|
223 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
|
224 and `minibuffer-setup-hook'." |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
225 (delete-overlay icomplete-overlay)) |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
226 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
227 ;;;_ > icomplete-exhibit () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
228 (defun icomplete-exhibit () |
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
229 "Insert icomplete completions display. |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
230 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
|
231 and `minibuffer-setup-hook'." |
74296
9e75cb6ef88c
(icomplete-tidy, icomplete-exhibit): Check that
Kim F. Storm <storm@cua.dk>
parents:
73095
diff
changeset
|
232 (when (and icomplete-mode (icomplete-simple-completing-p)) |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
233 (save-excursion |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
234 (goto-char (point-max)) |
5147 | 235 ; Insert the match-status information: |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
236 (if (and (> (point-max) (minibuffer-prompt-end)) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
237 buffer-undo-list ; Wait for some user input. |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
238 (or |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
239 ;; Don't bother with delay after certain number of chars: |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
240 (> (- (point) (field-beginning)) icomplete-max-delay-chars) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
241 ;; Don't delay if alternatives number is small enough: |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
242 (and (sequencep minibuffer-completion-table) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
243 (< (length minibuffer-completion-table) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
244 icomplete-delay-completions-threshold)) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
245 ;; Delay - give some grace time for next keystroke, before |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
246 ;; embarking on computing completions: |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
247 (sit-for icomplete-compute-delay))) |
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
248 (let ((text (while-no-input |
64793
2898eac3abad
(icomplete-exhibit): Adapt to new while-no-input calling convention.
Richard M. Stallman <rms@gnu.org>
parents:
64762
diff
changeset
|
249 (icomplete-completions |
2898eac3abad
(icomplete-exhibit): Adapt to new while-no-input calling convention.
Richard M. Stallman <rms@gnu.org>
parents:
64762
diff
changeset
|
250 (field-string) |
2898eac3abad
(icomplete-exhibit): Adapt to new while-no-input calling convention.
Richard M. Stallman <rms@gnu.org>
parents:
64762
diff
changeset
|
251 minibuffer-completion-table |
2898eac3abad
(icomplete-exhibit): Adapt to new while-no-input calling convention.
Richard M. Stallman <rms@gnu.org>
parents:
64762
diff
changeset
|
252 minibuffer-completion-predicate |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
253 (not minibuffer-completion-confirm)))) |
76442
b7ca30840f44
(icomplete-tidy, icomplete-exhibit): Bind deactivate-mark to nil.
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
254 (buffer-undo-list t) |
b7ca30840f44
(icomplete-tidy, icomplete-exhibit): Bind deactivate-mark to nil.
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
255 deactivate-mark) |
64793
2898eac3abad
(icomplete-exhibit): Adapt to new while-no-input calling convention.
Richard M. Stallman <rms@gnu.org>
parents:
64762
diff
changeset
|
256 ;; Do nothing if while-no-input was aborted. |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
257 (when (stringp text) |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
258 (move-overlay icomplete-overlay (point) (point) (current-buffer)) |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
259 ;; The current C cursor code doesn't know to use the overlay's |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
260 ;; marker's stickiness to figure out whether to place the cursor |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
261 ;; before or after the string, so let's spoon-feed it the pos. |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
262 (put-text-property 0 1 'cursor t text) |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
263 (overlay-put icomplete-overlay 'after-string text))))))) |
12933
61f11030ecc9
(icomplete-minibuffer-setup): Use make-local-hook
Richard M. Stallman <rms@gnu.org>
parents:
11035
diff
changeset
|
264 |
8871
299cfe0a6069
Major rewrite to behave more like a minor mode.
Richard M. Stallman <rms@gnu.org>
parents:
8434
diff
changeset
|
265 ;;;_ > 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
|
266 (defun icomplete-completions (name candidates predicate require-match) |
5147 | 267 "Identify prospective candidates for minibuffer completion. |
268 | |
5375
0e30cf7aa525
(icomplete-pre-command-hook): Reconciled with keyboard macro operation.
Richard M. Stallman <rms@gnu.org>
parents:
5147
diff
changeset
|
269 The display is updated with each minibuffer keystroke during |
5147 | 270 minibuffer completion. |
271 | |
272 Prospective completion suffixes (if any) are displayed, bracketed by | |
273 one of \(), \[], or \{} pairs. The choice of brackets is as follows: | |
274 | |
275 \(...) - a single prospect is identified and matching is enforced, | |
276 \[...] - a single prospect is identified but matching is optional, or | |
277 \{...} - 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
|
278 further input is required to distinguish a single one. |
5147 | 279 |
13989
d60fffb9acd1
(icomplete-simple-completing-p, icomplete-completions):
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
280 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
|
281 \(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
|
282 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
|
283 are exhibited within the square braces.)" |
82a56bdb2381
Integrated Emacs 19.34 and XEmacs 19.15
Karl Heuer <kwzh@gnu.org>
parents:
15302
diff
changeset
|
284 |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
285 (let* ((comps (completion-all-sorted-completions)) |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
286 (last (if (consp comps) (last comps))) |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
287 (base-size (cdr last)) |
95121
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
288 (open-bracket (if require-match "(" "[")) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
289 (close-bracket (if require-match ")" "]"))) |
95386
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
290 ;; `concat'/`mapconcat' is the slow part. |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
291 (if (not (consp comps)) |
95121
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
292 (format " %sNo matches%s" open-bracket close-bracket) |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
293 (if last (setcdr last nil)) |
95141
17032874a3da
(icomplete-completions): Don't use `predicate' with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95121
diff
changeset
|
294 (let* ((most-try |
17032874a3da
(icomplete-completions): Don't use `predicate' with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95121
diff
changeset
|
295 (if (and base-size (> base-size 0)) |
17032874a3da
(icomplete-completions): Don't use `predicate' with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95121
diff
changeset
|
296 (completion-try-completion |
17032874a3da
(icomplete-completions): Don't use `predicate' with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95121
diff
changeset
|
297 name candidates predicate (length name)) |
17032874a3da
(icomplete-completions): Don't use `predicate' with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95121
diff
changeset
|
298 ;; If the `comps' are 0-based, the result should be |
17032874a3da
(icomplete-completions): Don't use `predicate' with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95121
diff
changeset
|
299 ;; the same with `comps'. |
17032874a3da
(icomplete-completions): Don't use `predicate' with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95121
diff
changeset
|
300 (completion-try-completion |
17032874a3da
(icomplete-completions): Don't use `predicate' with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95121
diff
changeset
|
301 name comps nil (length name)))) |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
302 (most (if (consp most-try) (car most-try) |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
303 (if most-try (car comps) ""))) |
95121
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
304 ;; Compare name and most, so we can determine if name is |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
305 ;; a prefix of most, or something else. |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
306 (compare (compare-strings name nil nil |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
307 most nil nil completion-ignore-case)) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
308 (determ (unless (or (eq t compare) (eq t most-try) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
309 (= (setq compare (1- (abs compare))) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
310 (length most))) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
311 (concat open-bracket |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
312 (cond |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
313 ((= compare (length name)) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
314 ;; Typical case: name is a prefix. |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
315 (substring most compare)) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
316 ((< compare 5) most) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
317 (t (concat "..." (substring most compare)))) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
318 close-bracket))) |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
319 ;;"-prospects" - more than one candidate |
95386
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
320 (prospects-len (+ (length determ) 6 ;; take {,...} into account |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
321 (string-width (buffer-string)))) |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
322 (prospects-max |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
323 ;; Max total length to use, including the minibuffer content. |
95390
dbcab9d8dd2a
(icomplete-completions): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95386
diff
changeset
|
324 (* (+ icomplete-prospects-height |
95386
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
325 ;; If the minibuffer content already uses up more than |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
326 ;; one line, increase the allowable space accordingly. |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
327 (/ prospects-len (window-width))) |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
328 (window-width))) |
95121
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
329 (prefix-len |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
330 ;; Find the common prefix among `comps'. |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
331 (if (eq t (compare-strings (car comps) nil (length most) |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
332 most nil nil completion-ignore-case)) |
95121
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
333 ;; Common case. |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
334 (length most) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
335 ;; Else, use try-completion. |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
336 (let ((comps-prefix (try-completion "" comps))) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
337 (and (stringp comps-prefix) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
338 (length comps-prefix))))) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
339 |
93101
98814f79eb94
(icomplete-completions): While collecting the list of prospective candidates,
Juanma Barranquero <lekktu@gmail.com>
parents:
93099
diff
changeset
|
340 prospects most-is-exact comp limit) |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
341 (if (eq most-try t) ;; (or (null (cdr comps)) |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
342 (setq prospects nil) |
93101
98814f79eb94
(icomplete-completions): While collecting the list of prospective candidates,
Juanma Barranquero <lekktu@gmail.com>
parents:
93099
diff
changeset
|
343 (while (and comps (not limit)) |
95121
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
344 (setq comp |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
345 (if prefix-len (substring (car comps) prefix-len) (car comps)) |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
346 comps (cdr comps)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
347 (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
|
348 ((member comp prospects)) |
95386
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
349 (t (setq prospects-len |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
350 (+ (string-width comp) 1 prospects-len)) |
9d7e990b655a
(icomplete-prospects-length): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95187
diff
changeset
|
351 (if (< prospects-len prospects-max) |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
352 (push comp prospects) |
93101
98814f79eb94
(icomplete-completions): While collecting the list of prospective candidates,
Juanma Barranquero <lekktu@gmail.com>
parents:
93099
diff
changeset
|
353 (setq limit t)))))) |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
354 ;; Restore the base-size info, since completion-all-sorted-completions |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
355 ;; is cached. |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
356 (if last (setcdr last base-size)) |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
357 (if prospects |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
358 (concat determ |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
359 "{" |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
360 (and most-is-exact ",") |
95187
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
361 (mapconcat 'identity (nreverse prospects) ",") |
ee32b9c9936c
(icomplete-eoinput): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95141
diff
changeset
|
362 (and limit ",...") |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
363 "}") |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
364 (concat determ |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
365 " [Matched" |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
366 (let ((keys (and icomplete-show-key-bindings |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
367 (commandp (intern-soft most)) |
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
368 (icomplete-get-keys most)))) |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
369 (if keys (concat "; " keys) "")) |
26516
d9368f38a7b5
(icomplete-completions): Use an explicit variable
Gerd Moellmann <gerd@gnu.org>
parents:
24644
diff
changeset
|
370 "]")))))) |
5147 | 371 |
95121
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
372 ;;_* Local emacs vars. |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
373 ;;Local variables: |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
374 ;;allout-layout: (-2 :) |
cc51187bbc1d
(icomplete-simple-completing-p):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
375 ;;End: |
5147 | 376 |
60805
aba5f8c41ae0
Don't forcibly turn on the mode upon load.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
377 ;; arch-tag: 339ec25a-0741-4eb6-be63-997532e89b0f |
5147 | 378 ;;; icomplete.el ends here |