Mercurial > emacs
comparison lisp/icomplete.el @ 18251:e0327e90d706
Don't call icomplete-mode; let the user do that.
(icomplete-show-key-bindings): Doc fix.
(icomplete-mode): Doc fix.
(icomplete-get-keys): Make it actually work.
(icomplete-mode): Doc fix.
(icomplete-completions): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 15 Jun 1997 02:37:58 +0000 |
parents | 640305a5c871 |
children | d1d94511b3b7 |
comparison
equal
deleted
inserted
replaced
18250:4eabe22131dd | 18251:e0327e90d706 |
---|---|
54 ;; Thanks to everyone for their suggestions for refinements of this | 54 ;; Thanks to everyone for their suggestions for refinements of this |
55 ;; package. I particularly have to credit Michael Cook, who | 55 ;; package. I particularly have to credit Michael Cook, who |
56 ;; implemented an incremental completion style in his 'iswitch' | 56 ;; implemented an incremental completion style in his 'iswitch' |
57 ;; functions that served as a model for icomplete. Some other | 57 ;; functions that served as a model for icomplete. Some other |
58 ;; contributors: Noah Freidman (restructuring as minor mode), Colin | 58 ;; contributors: Noah Freidman (restructuring as minor mode), Colin |
59 ;; Rafferty (lemacs reconciliation), Lars Lindberg, RMS, and | 59 ;; Rafferty (lemacs reconciliation), Lars Lindberg, RMS, and others. |
60 ;; others. | |
61 | 60 |
62 ;; klm. | 61 ;; klm. |
63 | 62 |
64 ;;; Code: | 63 ;;; Code: |
65 | 64 |
94 icompletion is occurring.") | 93 icompletion is occurring.") |
95 | 94 |
96 ;;;_ + Internal Variables | 95 ;;;_ + Internal Variables |
97 ;;;_ = icomplete-mode | 96 ;;;_ = icomplete-mode |
98 (defvar icomplete-mode t | 97 (defvar icomplete-mode t |
99 "Non-nil enables incremental minibuffer completion, once | 98 "*Non-nil enables incremental minibuffer completion (see \\[icomplete-mode].") |
100 `\\[icomplete-mode]' function has set things up.") | |
101 ;;;_ = icomplete-eoinput 1 | 99 ;;;_ = icomplete-eoinput 1 |
102 (defvar icomplete-eoinput 1 | 100 (defvar icomplete-eoinput 1 |
103 "Point where minibuffer input ends and completion info begins.") | 101 "Point where minibuffer input ends and completion info begins.") |
104 (make-variable-buffer-local 'icomplete-eoinput) | 102 (make-variable-buffer-local 'icomplete-eoinput) |
105 ;;;_ = icomplete-pre-command-hook | 103 ;;;_ = icomplete-pre-command-hook |
117 Is run in minibuffer after user input when `icomplete-mode' is non-nil. | 115 Is run in minibuffer after user input when `icomplete-mode' is non-nil. |
118 Use `icomplete-mode' function to set it up properly for incremental | 116 Use `icomplete-mode' function to set it up properly for incremental |
119 minibuffer completion.") | 117 minibuffer completion.") |
120 (add-hook 'icomplete-post-command-hook 'icomplete-exhibit) | 118 (add-hook 'icomplete-post-command-hook 'icomplete-exhibit) |
121 | 119 |
122 (defvar icomplete-show-key-bindings (string-match "XEmacs\\|Lucid" | 120 (defvar icomplete-show-key-bindings t |
123 emacs-version) | 121 "*When non-nil, show key bindings as well as completion for sole matches.") |
124 "When non-nil show key bindings as well as completion when matching | |
125 a command. Currently working only for XEmacs - see `icomplete-get-keys'.") | |
126 | 122 |
127 (defun icomplete-get-keys (func-name) | 123 (defun icomplete-get-keys (func-name) |
128 "Return the keys `func-name' is bound to as a string, or nil if none. | 124 "Return strings naming keys bound to `func-name', or nil if none. |
129 NOTE that this depends on `owindow' minbuf setting and `current-local-map' | 125 Examines the prior, not current, buffer, presuming that current buffer |
130 taking arg, both present in XEmacs but not present in mainline GNU Emacs | 126 is minibuffer." |
131 19.34." | 127 (if (commandp func-name) |
132 (when (commandp func-name) | |
133 (save-excursion | 128 (save-excursion |
134 (let* ((sym (intern func-name)) | 129 (let* ((sym (intern func-name)) |
135 (buf (set-buffer (window-buffer owindow))) | 130 (buf (other-buffer)) |
136 (keys (where-is-internal sym (current-local-map buf)))) | 131 (map (save-excursion (set-buffer buf) (current-local-map))) |
132 (keys (where-is-internal sym map))) | |
137 (if keys | 133 (if keys |
138 (concat "<" | 134 (concat "<" |
139 (mapconcat 'key-description | 135 (mapconcat 'key-description |
140 (sort keys | 136 (sort keys |
141 #'(lambda (x y) | 137 #'(lambda (x y) |
144 ">")))))) | 140 ">")))))) |
145 | 141 |
146 ;;;_ > icomplete-mode (&optional prefix) | 142 ;;;_ > icomplete-mode (&optional prefix) |
147 ;;;###autoload | 143 ;;;###autoload |
148 (defun icomplete-mode (&optional prefix) | 144 (defun icomplete-mode (&optional prefix) |
149 "Activate incremental minibuffer completion for this emacs session, | 145 "Activate incremental minibuffer completion for this Emacs session. |
150 or deactivate with negative prefix arg." | 146 Deactivates with negative universal argument." |
151 (interactive "p") | 147 (interactive "p") |
152 (or prefix (setq prefix 0)) | 148 (or prefix (setq prefix 0)) |
153 (cond ((>= prefix 0) | 149 (cond ((>= prefix 0) |
154 (setq icomplete-mode t) | 150 (setq icomplete-mode t) |
155 ;; The following is not really necessary after first time - | 151 ;; The following is not really necessary after first time - |
157 (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup)) | 153 (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup)) |
158 (t (setq icomplete-mode nil)))) | 154 (t (setq icomplete-mode nil)))) |
159 | 155 |
160 ;;;_ > icomplete-simple-completing-p () | 156 ;;;_ > icomplete-simple-completing-p () |
161 (defun icomplete-simple-completing-p () | 157 (defun icomplete-simple-completing-p () |
162 | |
163 "Non-nil if current window is minibuffer that's doing simple completion. | 158 "Non-nil if current window is minibuffer that's doing simple completion. |
164 | 159 |
165 Conditions are: | 160 Conditions are: |
166 the selected window is a minibuffer, | 161 the selected window is a minibuffer, |
167 and not in the middle of macro execution, | 162 and not in the middle of macro execution, |
213 (setq icomplete-eoinput 1)))) | 208 (setq icomplete-eoinput 1)))) |
214 | 209 |
215 ;;;_ > icomplete-exhibit () | 210 ;;;_ > icomplete-exhibit () |
216 (defun icomplete-exhibit () | 211 (defun icomplete-exhibit () |
217 "Insert icomplete completions display. | 212 "Insert icomplete completions display. |
218 | |
219 Should be run via minibuffer `post-command-hook'. See `icomplete-mode' | 213 Should be run via minibuffer `post-command-hook'. See `icomplete-mode' |
220 and `minibuffer-setup-hook'." | 214 and `minibuffer-setup-hook'." |
221 (if (icomplete-simple-completing-p) | 215 (if (icomplete-simple-completing-p) |
222 (let ((contents (buffer-substring (point-min)(point-max))) | 216 (let ((contents (buffer-substring (point-min)(point-max))) |
223 (buffer-undo-list t)) | 217 (buffer-undo-list t)) |
269 \{...} - multiple prospects, separated by commas, are indicated, and | 263 \{...} - multiple prospects, separated by commas, are indicated, and |
270 further input is required to distinguish a single one. | 264 further input is required to distinguish a single one. |
271 | 265 |
272 The displays for unambiguous matches have ` [Matched]' appended | 266 The displays for unambiguous matches have ` [Matched]' appended |
273 \(whether complete or not), or ` \[No matches]', if no eligible | 267 \(whether complete or not), or ` \[No matches]', if no eligible |
274 matches exist. \(In XEmacs, keybindings for matched commands, if any, | 268 matches exist. \(Keybindings for uniquely matched commands |
275 are exhibited within the square braces.)" | 269 are exhibited within the square braces.)" |
276 | 270 |
277 ;; 'all-completions' doesn't like empty | 271 ;; 'all-completions' doesn't like empty |
278 ;; minibuffer-completion-table's (ie: (nil)) | 272 ;; minibuffer-completion-table's (ie: (nil)) |
279 (if (and (listp candidates) (null (car candidates))) | 273 (if (and (listp candidates) (null (car candidates))) |
351 ;; not unique": | 345 ;; not unique": |
352 (concat "," alternatives) | 346 (concat "," alternatives) |
353 alternatives) | 347 alternatives) |
354 close-bracket-prospects))))))) | 348 close-bracket-prospects))))))) |
355 | 349 |
356 ;;;_ + Initialization | |
357 ;;; If user hasn't setq-default icomplete-mode to nil, then setup for | |
358 ;;; activation: | |
359 (if icomplete-mode | |
360 (icomplete-mode)) | |
361 | |
362 | |
363 ;;;_* Local emacs vars. | 350 ;;;_* Local emacs vars. |
364 ;;;Local variables: | 351 ;;;Local variables: |
365 ;;;outline-layout: (-2 :) | 352 ;;;outline-layout: (-2 :) |
366 ;;;End: | 353 ;;;End: |
367 | 354 |