Mercurial > emacs
annotate lisp/complete.el @ 16670:37fa6003964d
Fix previous change.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 11 Dec 1996 21:06:53 +0000 |
parents | e2858bcbed43 |
children | 058970c0f57f |
rev | line source |
---|---|
15261 | 1 ;;; complete.el --- partial completion mechanism plus other goodies |
3725 | 2 |
3 ;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Dave Gillespie <daveg@synaptics.com> | |
11487
577cd5d36667
Add Keywords: comment header for finder.el.
Roland McGrath <roland@gnu.org>
parents:
10164
diff
changeset
|
6 ;; Keywords: abbrev |
3725 | 7 ;; Version: 2.02 |
8 ;; Special thanks to Hallvard Furuseth for his many ideas and contributions. | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
15 ;; any later version. |
3725 | 16 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
20 ;; GNU General Public License for more details. |
3725 | 21 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
3725
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
3725 | 26 |
7942 | 27 ;;; Commentary: |
3725 | 28 |
29 ;; Extended completion for the Emacs minibuffer. | |
30 ;; | |
31 ;; The basic idea is that the command name or other completable text is | |
32 ;; divided into words and each word is completed separately, so that | |
33 ;; "M-x p-b" expands to "M-x print-buffer". If the entry is ambiguous | |
34 ;; each word is completed as much as possible and then the cursor is | |
35 ;; left at the first position where typing another letter will resolve | |
36 ;; the ambiguity. | |
37 ;; | |
38 ;; Word separators for this purpose are hyphen, space, and period. | |
39 ;; These would most likely occur in command names, Info menu items, | |
40 ;; and file names, respectively. But all word separators are treated | |
41 ;; alike at all times. | |
42 ;; | |
43 ;; This completion package replaces the old-style completer's key | |
44 ;; bindings for TAB, SPC, RET, and `?'. The old completer is still | |
45 ;; available on the Meta versions of those keys. If you set | |
46 ;; PC-meta-flag to nil, the old completion keys will be left alone | |
47 ;; and the partial completer will use the Meta versions of the keys. | |
48 | |
49 | |
50 ;; Usage: Load this file. Now, during completable minibuffer entry, | |
51 ;; | |
52 ;; TAB means to do a partial completion; | |
53 ;; SPC means to do a partial complete-word; | |
54 ;; RET means to do a partial complete-and-exit; | |
55 ;; ? means to do a partial completion-help. | |
56 ;; | |
57 ;; If you set PC-meta-flag to nil, then TAB, SPC, RET, and ? perform | |
58 ;; original Emacs completions, and M-TAB etc. do partial completion. | |
59 ;; To do this, put the command, | |
60 ;; | |
61 ;; (setq PC-meta-flag nil) | |
62 ;; | |
63 ;; in your .emacs file. To load partial completion automatically, put | |
64 ;; | |
65 ;; (load "complete") | |
66 ;; | |
67 ;; in your .emacs file, too. Things will be faster if you byte-compile | |
68 ;; this file when you install it. | |
69 ;; | |
70 ;; As an extra feature, in cases where RET would not normally | |
71 ;; complete (such as `C-x b'), the M-RET key will always do a partial | |
72 ;; complete-and-exit. Thus `C-x b f.c RET' will select or create a | |
73 ;; buffer called "f.c", but `C-x b f.c M-RET' will select the existing | |
74 ;; buffer whose name matches that pattern (perhaps "filing.c"). | |
75 ;; (PC-meta-flag does not affect this behavior; M-RET used to be | |
76 ;; undefined in this situation.) | |
77 ;; | |
78 ;; The regular M-TAB (lisp-complete-symbol) command also supports | |
79 ;; partial completion in this package. | |
80 | |
81 ;; This package also contains a wildcard feature for C-x C-f (find-file). | |
82 ;; For example, `C-x C-f *.c RET' loads all .c files at once, exactly | |
83 ;; as if you had typed C-x C-f separately for each file. Completion | |
84 ;; is supported in connection with wildcards. Currently only the `*' | |
85 ;; wildcard character works. | |
86 | |
87 ;; File name completion does not do partial completion of directories | |
88 ;; on the path, e.g., "/u/b/f" will not complete to "/usr/bin/foo", | |
89 ;; but you can put *'s in the path to accomplish this: "/u*/b*/f". | |
90 ;; Stars are required for performance reasons. | |
91 | |
92 ;; In addition, this package includes a feature for accessing include | |
93 ;; files. For example, `C-x C-f <sys/time.h> RET' reads the file | |
94 ;; /usr/include/sys/time.h. The variable PC-include-file-path is a | |
95 ;; list of directories in which to search for include files. Completion | |
96 ;; is supported in include file names. | |
97 | |
98 | |
7942 | 99 ;;; Code: |
3725 | 100 |
101 (defvar PC-meta-flag t | |
102 "*If nil, TAB does normal Emacs completion and M-TAB does Partial Completion. | |
103 If t, TAB does Partial Completion and M-TAB does normal completion.") | |
104 | |
105 | |
106 (defvar PC-word-delimiters "-_. " | |
107 "*A string of characters which are to be treated as word delimiters | |
108 by the Partial Completion system. | |
109 | |
110 Some arcane rules: If `]' is in this string it must come first. | |
111 If `^' is in this string it must NOT come first. If `-' is in this | |
112 string, it must come first or right after `]'. In other words, if | |
113 S is this string, then `[S]' must be a legal Emacs regular expression | |
7639 | 114 \(not containing character ranges like `a-z').") |
3725 | 115 |
116 | |
117 (defvar PC-first-char 'x | |
118 "*If t, first character of a string to be completed is always taken literally. | |
119 If nil, word delimiters are handled even if they appear as first character. | |
120 This controls whether \".e\" matches \".e*\" (t) or \"*.e*\" (nil). | |
121 If neither nil nor t, first char is literal only for filename completion.") | |
122 | |
123 | |
124 (defvar PC-include-file-path '("/usr/include") | |
125 "*List of directories in which to look for include files. | |
126 If this is nil, uses the colon-separated path in $INCPATH instead.") | |
127 | |
128 | |
129 (defvar PC-disable-wildcards nil | |
130 "Set this to non-nil to disable wildcard support in \\[find-file].") | |
131 | |
132 (defvar PC-disable-includes nil | |
133 "Set this to non-nil to disable include-file support in \\[find-file].") | |
134 | |
135 | |
136 (defvar PC-default-bindings t | |
137 "Set this to nil to suppress the default partial completion key bindings.") | |
138 | |
139 (if PC-default-bindings (progn | |
140 (define-key minibuffer-local-completion-map "\t" 'PC-complete) | |
141 (define-key minibuffer-local-completion-map " " 'PC-complete-word) | |
142 (define-key minibuffer-local-completion-map "?" 'PC-completion-help) | |
143 | |
144 (define-key minibuffer-local-completion-map "\e\t" 'PC-complete) | |
145 (define-key minibuffer-local-completion-map "\e " 'PC-complete-word) | |
146 (define-key minibuffer-local-completion-map "\e\r" 'PC-force-complete-and-exit) | |
147 (define-key minibuffer-local-completion-map "\e\n" 'PC-force-complete-and-exit) | |
148 (define-key minibuffer-local-completion-map "\e?" 'PC-completion-help) | |
149 | |
150 (define-key minibuffer-local-must-match-map "\t" 'PC-complete) | |
151 (define-key minibuffer-local-must-match-map " " 'PC-complete-word) | |
152 (define-key minibuffer-local-must-match-map "\r" 'PC-complete-and-exit) | |
153 (define-key minibuffer-local-must-match-map "\n" 'PC-complete-and-exit) | |
154 (define-key minibuffer-local-must-match-map "?" 'PC-completion-help) | |
155 | |
156 (define-key minibuffer-local-must-match-map "\e\t" 'PC-complete) | |
157 (define-key minibuffer-local-must-match-map "\e " 'PC-complete-word) | |
158 (define-key minibuffer-local-must-match-map "\e\r" 'PC-complete-and-exit) | |
159 (define-key minibuffer-local-must-match-map "\e\n" 'PC-complete-and-exit) | |
160 (define-key minibuffer-local-must-match-map "\e?" 'PC-completion-help) | |
161 | |
162 (define-key global-map "\e\t" 'PC-lisp-complete-symbol) | |
163 )) | |
164 | |
165 | |
166 (defun PC-complete () | |
167 "Like minibuffer-complete, but allows \"b--di\"-style abbreviations. | |
168 For example, \"M-x b--di\" would match `byte-recompile-directory', or any | |
169 name which consists of three or more words, the first beginning with \"b\" | |
170 and the third beginning with \"di\". | |
171 | |
172 The pattern \"b--d\" is ambiguous for `byte-recompile-directory' and | |
173 `beginning-of-defun', so this would produce a list of completions | |
174 just like when normal Emacs completions are ambiguous. | |
175 | |
176 Word-delimiters for the purposes of Partial Completion are \"-\", \"_\", | |
177 \".\", and SPC." | |
178 (interactive) | |
179 (if (PC-was-meta-key) | |
180 (minibuffer-complete) | |
15802
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
181 ;; If the previous command was not this one, |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
182 ;; never scroll, always retry completion. |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
183 (or (eq last-command this-command) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
184 (setq minibuffer-scroll-window nil)) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
185 (let ((window minibuffer-scroll-window)) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
186 ;; If there's a fresh completion window with a live buffer, |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
187 ;; and this command is repeated, scroll that window. |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
188 (if (and window (window-buffer window) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
189 (buffer-name (window-buffer window))) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
190 (save-excursion |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
191 (set-buffer (window-buffer window)) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
192 (if (pos-visible-in-window-p (point-max) window) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
193 (set-window-start window (point-min) nil) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
194 (scroll-other-window))) |
1595df9ed1e8
(PC-complete): When command is repeated,
Richard M. Stallman <rms@gnu.org>
parents:
15261
diff
changeset
|
195 (PC-do-completion nil))))) |
3725 | 196 |
197 | |
198 (defun PC-complete-word () | |
199 "Like `minibuffer-complete-word', but allows \"b--di\"-style abbreviations. | |
200 See `PC-complete' for details. | |
201 This can be bound to other keys, like `-' and `.', if you wish." | |
202 (interactive) | |
203 (if (eq (PC-was-meta-key) PC-meta-flag) | |
204 (if (eq last-command-char ? ) | |
205 (minibuffer-complete-word) | |
206 (self-insert-command 1)) | |
207 (self-insert-command 1) | |
208 (if (eobp) | |
209 (PC-do-completion 'word)))) | |
210 | |
211 | |
212 (defun PC-complete-space () | |
213 "Like `minibuffer-complete-word', but allows \"b--di\"-style abbreviations. | |
214 See `PC-complete' for details. | |
215 This is suitable for binding to other keys which should act just like SPC." | |
216 (interactive) | |
217 (if (eq (PC-was-meta-key) PC-meta-flag) | |
218 (minibuffer-complete-word) | |
219 (insert " ") | |
220 (if (eobp) | |
221 (PC-do-completion 'word)))) | |
222 | |
223 | |
224 (defun PC-complete-and-exit () | |
225 "Like `minibuffer-complete-and-exit', but allows \"b--di\"-style abbreviations. | |
226 See `PC-complete' for details." | |
227 (interactive) | |
228 (if (eq (PC-was-meta-key) PC-meta-flag) | |
229 (minibuffer-complete-and-exit) | |
230 (PC-do-complete-and-exit))) | |
231 | |
232 (defun PC-force-complete-and-exit () | |
233 "Like `minibuffer-complete-and-exit', but allows \"b--di\"-style abbreviations. | |
234 See `PC-complete' for details." | |
235 (interactive) | |
236 (let ((minibuffer-completion-confirm nil)) | |
237 (PC-do-complete-and-exit))) | |
238 | |
239 (defun PC-do-complete-and-exit () | |
240 (if (= (buffer-size) 0) ; Duplicate the "bug" that Info-menu relies on... | |
241 (exit-minibuffer) | |
242 (let ((flag (PC-do-completion 'exit))) | |
243 (and flag | |
244 (if (or (eq flag 'complete) | |
245 (not minibuffer-completion-confirm)) | |
246 (exit-minibuffer) | |
10164
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
247 (PC-temp-minibuffer-message " [Confirm]")))))) |
3725 | 248 |
249 | |
250 (defun PC-completion-help () | |
251 "Like `minibuffer-completion-help', but allows \"b--di\"-style abbreviations. | |
252 See `PC-complete' for details." | |
253 (interactive) | |
254 (if (eq (PC-was-meta-key) PC-meta-flag) | |
255 (minibuffer-completion-help) | |
256 (PC-do-completion 'help))) | |
257 | |
258 (defun PC-was-meta-key () | |
259 (or (/= (length (this-command-keys)) 1) | |
260 (let ((key (aref (this-command-keys) 0))) | |
261 (if (integerp key) | |
262 (>= key 128) | |
263 (not (null (memq 'meta (event-modifiers key)))))))) | |
264 | |
265 | |
266 (defvar PC-ignored-extensions 'empty-cache) | |
267 (defvar PC-delims 'empty-cache) | |
268 (defvar PC-ignored-regexp nil) | |
269 (defvar PC-word-failed-flag nil) | |
270 (defvar PC-delim-regex nil) | |
271 (defvar PC-ndelims-regex nil) | |
272 (defvar PC-delims-list nil) | |
273 | |
14765
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
274 (defvar PC-completion-as-file-name-predicate |
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
275 (function |
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
276 (lambda () |
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
277 (memq minibuffer-completion-table |
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
278 '(read-file-name-internal read-directory-name-internal)))) |
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
279 "A function testing whether a minibuffer completion now will work filename-style. |
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
280 The function takes no arguments, and typically looks at the value |
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
281 of `minibuffer-completion-table' and the minibuffer contents.") |
14759
f93ed65c0584
(PC-do-completion-filename-completers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
282 |
3725 | 283 (defun PC-do-completion (&optional mode beg end) |
284 (or beg (setq beg (point-min))) | |
285 (or end (setq end (point-max))) | |
286 (let* ((table minibuffer-completion-table) | |
287 (pred minibuffer-completion-predicate) | |
14765
844686eabff0
(PC-completion-as-file-name-predicate):
Richard M. Stallman <rms@gnu.org>
parents:
14759
diff
changeset
|
288 (filename (funcall PC-completion-as-file-name-predicate)) |
3725 | 289 (dirname nil) |
8478
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
290 dirlength |
3725 | 291 (str (buffer-substring beg end)) |
292 (incname (and filename (string-match "<\\([^\"<>]*\\)>?$" str))) | |
293 (ambig nil) | |
294 basestr | |
295 regex | |
296 p offset | |
297 (poss nil) | |
298 helpposs | |
299 (case-fold-search completion-ignore-case)) | |
300 | |
301 ;; Check if buffer contents can already be considered complete | |
302 (if (and (eq mode 'exit) | |
303 (PC-is-complete-p str table pred)) | |
304 'complete | |
305 | |
8478
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
306 ;; Record how many characters at the beginning are not included |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
307 ;; in completion. |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
308 (setq dirlength |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
309 (if filename |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
310 (length (file-name-directory str)) |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
311 0)) |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
312 |
3725 | 313 ;; Do substitutions in directory names |
314 (and filename | |
315 (not (equal str (setq p (substitute-in-file-name str)))) | |
316 (progn | |
317 (delete-region beg end) | |
318 (insert p) | |
319 (setq str p end (+ beg (length str))))) | |
320 | |
321 ;; Prepare various delimiter strings | |
322 (or (equal PC-word-delimiters PC-delims) | |
323 (setq PC-delims PC-word-delimiters | |
324 PC-delim-regex (concat "[" PC-delims "]") | |
325 PC-ndelims-regex (concat "[^" PC-delims "]*") | |
326 PC-delims-list (append PC-delims nil))) | |
327 | |
328 ;; Look for wildcard expansions in directory name | |
329 (and filename | |
330 (string-match "\\*.*/" str) | |
331 (let ((pat str) | |
332 files) | |
333 (setq p (1+ (string-match "/[^/]*\\'" pat))) | |
334 (while (setq p (string-match PC-delim-regex pat p)) | |
335 (setq pat (concat (substring pat 0 p) | |
336 "*" | |
337 (substring pat p)) | |
338 p (+ p 2))) | |
339 (setq files (PC-expand-many-files (concat pat "*"))) | |
340 (if files | |
341 (let ((dir (file-name-directory (car files))) | |
342 (p files)) | |
343 (while (and (setq p (cdr p)) | |
344 (equal dir (file-name-directory (car p))))) | |
345 (if p | |
346 (setq filename nil table nil pred nil | |
347 ambig t) | |
348 (delete-region beg end) | |
349 (setq str (concat dir (file-name-nondirectory str))) | |
350 (insert str) | |
351 (setq end (+ beg (length str))))) | |
352 (setq filename nil table nil pred nil)))) | |
353 | |
354 ;; Strip directory name if appropriate | |
355 (if filename | |
356 (if incname | |
357 (setq basestr (substring str incname) | |
358 dirname (substring str 0 incname)) | |
359 (setq basestr (file-name-nondirectory str) | |
360 dirname (file-name-directory str))) | |
361 (setq basestr str)) | |
362 | |
363 ;; Convert search pattern to a standard regular expression | |
364 (setq regex (regexp-quote basestr) | |
365 offset (if (and (> (length regex) 0) | |
366 (not (eq (aref basestr 0) ?\*)) | |
367 (or (eq PC-first-char t) | |
368 (and PC-first-char filename))) 1 0) | |
369 p offset) | |
370 (while (setq p (string-match PC-delim-regex regex p)) | |
371 (if (eq (aref regex p) ? ) | |
372 (setq regex (concat (substring regex 0 p) | |
373 PC-ndelims-regex | |
374 PC-delim-regex | |
375 (substring regex (1+ p))) | |
376 p (+ p (length PC-ndelims-regex) (length PC-delim-regex))) | |
377 (let ((bump (if (memq (aref regex p) | |
378 '(?$ ?^ ?\. ?* ?+ ?? ?[ ?] ?\\)) | |
379 -1 0))) | |
380 (setq regex (concat (substring regex 0 (+ p bump)) | |
381 PC-ndelims-regex | |
382 (substring regex (+ p bump))) | |
383 p (+ p (length PC-ndelims-regex) 1))))) | |
384 (setq p 0) | |
385 (if filename | |
386 (while (setq p (string-match "\\\\\\*" regex p)) | |
387 (setq regex (concat (substring regex 0 p) | |
388 "[^/]*" | |
389 (substring regex (+ p 2)))))) | |
390 ;;(setq the-regex regex) | |
391 (setq regex (concat "\\`" regex)) | |
392 | |
393 ;; Find an initial list of possible completions | |
394 (if (not (setq p (string-match (concat PC-delim-regex | |
395 (if filename "\\|\\*" "")) | |
396 str | |
397 (+ (length dirname) offset)))) | |
398 | |
399 ;; Minibuffer contains no hyphens -- simple case! | |
400 (setq poss (all-completions str | |
401 table | |
402 pred)) | |
403 | |
404 ;; Use all-completions to do an initial cull. This is a big win, | |
405 ;; since all-completions is written in C! | |
406 (let ((compl (all-completions (substring str 0 p) | |
407 table | |
408 pred))) | |
409 (setq p compl) | |
410 (while p | |
411 (and (string-match regex (car p)) | |
16608
e2858bcbed43
(PC-do-completion): Remove text properties from
Karl Heuer <kwzh@gnu.org>
parents:
15802
diff
changeset
|
412 (progn |
e2858bcbed43
(PC-do-completion): Remove text properties from
Karl Heuer <kwzh@gnu.org>
parents:
15802
diff
changeset
|
413 (set-text-properties 0 (length (car p)) '() (car p)) |
e2858bcbed43
(PC-do-completion): Remove text properties from
Karl Heuer <kwzh@gnu.org>
parents:
15802
diff
changeset
|
414 (setq poss (cons (car p) poss)))) |
3725 | 415 (setq p (cdr p))))) |
416 | |
417 ;; Now we have a list of possible completions | |
418 (cond | |
419 | |
420 ;; No valid completions found | |
421 ((null poss) | |
422 (if (and (eq mode 'word) | |
423 (not PC-word-failed-flag)) | |
424 (let ((PC-word-failed-flag t)) | |
425 (delete-backward-char 1) | |
426 (PC-do-completion 'word)) | |
427 (beep) | |
428 (PC-temp-minibuffer-message (if ambig | |
10164
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
429 " [Ambiguous dir name]" |
3725 | 430 (if (eq mode 'help) |
10164
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
431 " [No completions]" |
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
432 " [No match]"))) |
3725 | 433 nil)) |
434 | |
435 ;; More than one valid completion found | |
436 ((or (cdr (setq helpposs poss)) | |
437 (memq mode '(help word))) | |
438 | |
439 ;; Handle completion-ignored-extensions | |
440 (and filename | |
441 (not (eq mode 'help)) | |
442 (let ((p2 poss)) | |
443 | |
444 ;; Build a regular expression representing the extensions list | |
445 (or (equal completion-ignored-extensions PC-ignored-extensions) | |
446 (setq PC-ignored-regexp | |
447 (concat "\\(" | |
448 (mapconcat | |
449 'regexp-quote | |
450 (setq PC-ignored-extensions | |
451 completion-ignored-extensions) | |
452 "\\|") | |
453 "\\)\\'"))) | |
454 | |
455 ;; Check if there are any without an ignored extension | |
456 (setq p nil) | |
457 (while p2 | |
458 (or (string-match PC-ignored-regexp (car p2)) | |
459 (setq p (cons (car p2) p))) | |
460 (setq p2 (cdr p2))) | |
461 | |
462 ;; If there are "good" names, use them | |
463 (and p (setq poss p)))) | |
464 | |
465 ;; Is the actual string one of the possible completions? | |
466 (setq p (and (not (eq mode 'help)) poss)) | |
467 (while (and p | |
16608
e2858bcbed43
(PC-do-completion): Remove text properties from
Karl Heuer <kwzh@gnu.org>
parents:
15802
diff
changeset
|
468 (not (string-equal (car p) basestr))) |
3725 | 469 (setq p (cdr p))) |
10164
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
470 (and p (null mode) |
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
471 (PC-temp-minibuffer-message " [Complete, but not unique]")) |
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
472 (if (and p |
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
473 (not (and (null mode) |
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
474 (eq this-command last-command)))) |
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
475 t |
3725 | 476 |
477 ;; If ambiguous, try for a partial completion | |
478 (let ((improved nil) | |
479 prefix | |
480 (pt nil) | |
481 (skip "\\`")) | |
482 | |
483 ;; Check if next few letters are the same in all cases | |
484 (if (and (not (eq mode 'help)) | |
485 (setq prefix (try-completion "" (mapcar 'list poss)))) | |
486 (let ((first t) i) | |
487 (if (eq mode 'word) | |
488 (setq prefix (PC-chop-word prefix basestr))) | |
489 (goto-char (+ beg (length dirname))) | |
490 (while (and (progn | |
491 (setq i 0) | |
492 (while (< i (length prefix)) | |
493 (if (and (< (point) end) | |
494 (eq (aref prefix i) | |
495 (following-char))) | |
496 (forward-char 1) | |
497 (if (and (< (point) end) | |
498 (or (and (looking-at " ") | |
499 (memq (aref prefix i) | |
500 PC-delims-list)) | |
501 (eq (downcase (aref prefix i)) | |
502 (downcase | |
503 (following-char))))) | |
504 (progn | |
505 (delete-char 1) | |
506 (setq end (1- end))) | |
507 (and filename (looking-at "\\*") | |
508 (progn | |
509 (delete-char 1) | |
510 (setq end (1- end)))) | |
511 (setq improved t)) | |
16608
e2858bcbed43
(PC-do-completion): Remove text properties from
Karl Heuer <kwzh@gnu.org>
parents:
15802
diff
changeset
|
512 (insert (substring prefix i (1+ i))) |
3725 | 513 (setq end (1+ end))) |
514 (setq i (1+ i))) | |
515 (or pt (equal (point) beg) | |
516 (setq pt (point))) | |
517 (looking-at PC-delim-regex)) | |
518 (setq skip (concat skip | |
519 (regexp-quote prefix) | |
520 PC-ndelims-regex) | |
521 prefix (try-completion | |
522 "" | |
523 (mapcar | |
524 (function | |
525 (lambda (x) | |
526 (list | |
527 (and (string-match skip x) | |
528 (substring | |
529 x | |
530 (match-end 0)))))) | |
531 poss))) | |
532 (or (> i 0) (> (length prefix) 0)) | |
533 (or (not (eq mode 'word)) | |
534 (and first (> (length prefix) 0) | |
535 (setq first nil | |
536 prefix (substring prefix 0 1)))))) | |
537 (goto-char (if (eq mode 'word) end | |
538 (or pt beg))))) | |
539 | |
540 (if (and (eq mode 'word) | |
541 (not PC-word-failed-flag)) | |
542 | |
543 (if improved | |
544 | |
545 ;; We changed it... would it be complete without the space? | |
546 (if (PC-is-complete-p (buffer-substring 1 (1- end)) | |
547 table pred) | |
548 (delete-region (1- end) end))) | |
549 | |
550 (if improved | |
551 | |
552 ;; We changed it... enough to be complete? | |
553 (and (eq mode 'exit) | |
554 (PC-is-complete-p (buffer-string) table pred)) | |
555 | |
556 ;; If totally ambiguous, display a list of completions | |
557 (if (or completion-auto-help | |
558 (eq mode 'help)) | |
7844
86402e8c677b
(PC-do-completion): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
7792
diff
changeset
|
559 (with-output-to-temp-buffer "*Completions*" |
8478
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
560 (display-completion-list (sort helpposs 'string-lessp)) |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
561 (save-excursion |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
562 (set-buffer standard-output) |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
563 ;; Record which part of the buffer we are completing |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
564 ;; so that choosing a completion from the list |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
565 ;; knows how much old text to replace. |
9d3d84a3c3fa
(PC-do-completion): Set completion-base-size.
Richard M. Stallman <rms@gnu.org>
parents:
7942
diff
changeset
|
566 (setq completion-base-size dirlength))) |
10164
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
567 (PC-temp-minibuffer-message " [Next char not unique]")) |
3725 | 568 nil))))) |
569 | |
570 ;; Only one possible completion | |
571 (t | |
572 (if (equal basestr (car poss)) | |
573 (if (null mode) | |
10164
d16e46a4e34c
(PC-do-completion): If complete but not unique,
Richard M. Stallman <rms@gnu.org>
parents:
8478
diff
changeset
|
574 (PC-temp-minibuffer-message " [Sole completion]")) |
3725 | 575 (delete-region beg end) |
7792
1335cec8a016
(PC-do-completion): Clear text props from inserted text.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
576 (insert (format "%s" |
1335cec8a016
(PC-do-completion): Clear text props from inserted text.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
577 (if filename |
1335cec8a016
(PC-do-completion): Clear text props from inserted text.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
578 (substitute-in-file-name (concat dirname (car poss))) |
1335cec8a016
(PC-do-completion): Clear text props from inserted text.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
579 (car poss))))) |
3725 | 580 t))))) |
581 | |
582 | |
583 (defun PC-is-complete-p (str table pred) | |
584 (let ((res (if (listp table) | |
585 (assoc str table) | |
586 (if (vectorp table) | |
587 (or (equal str "nil") ; heh, heh, heh | |
588 (intern-soft str table)) | |
589 (funcall table str pred 'lambda))))) | |
590 (and res | |
591 (or (not pred) | |
592 (and (not (listp table)) (not (vectorp table))) | |
593 (funcall pred res)) | |
594 res))) | |
595 | |
596 (defun PC-chop-word (new old) | |
597 (let ((i -1) | |
598 (j -1)) | |
599 (while (and (setq i (string-match PC-delim-regex old (1+ i))) | |
600 (setq j (string-match PC-delim-regex new (1+ j))))) | |
601 (if (and j | |
602 (or (not PC-word-failed-flag) | |
603 (setq j (string-match PC-delim-regex new (1+ j))))) | |
604 (substring new 0 (1+ j)) | |
605 new))) | |
606 | |
607 (defvar PC-not-minibuffer nil) | |
608 | |
609 (defun PC-temp-minibuffer-message (m) | |
610 "A Lisp version of `temp_minibuffer_message' from minibuf.c." | |
611 (if PC-not-minibuffer | |
612 (progn | |
613 (message m) | |
614 (sit-for 2) | |
615 (message "")) | |
616 (if (fboundp 'temp-minibuffer-message) | |
617 (temp-minibuffer-message m) | |
618 (let ((savemax (point-max))) | |
619 (save-excursion | |
620 (goto-char (point-max)) | |
621 (insert m)) | |
622 (let ((inhibit-quit t)) | |
623 (sit-for 2) | |
624 (delete-region savemax (point-max)) | |
625 (if quit-flag | |
626 (setq quit-flag nil | |
627 unread-command-char 7))))))) | |
628 | |
629 | |
630 (defun PC-lisp-complete-symbol () | |
631 "Perform completion on Lisp symbol preceding point. | |
632 That symbol is compared against the symbols that exist | |
633 and any additional characters determined by what is there | |
634 are inserted. | |
635 If the symbol starts just after an open-parenthesis, | |
636 only symbols with function definitions are considered. | |
637 Otherwise, all symbols with function definitions, values | |
638 or properties are considered." | |
639 (interactive) | |
640 (let* ((end (point)) | |
641 (buffer-syntax (syntax-table)) | |
642 (beg (unwind-protect | |
643 (save-excursion | |
644 (if lisp-mode-syntax-table | |
645 (set-syntax-table lisp-mode-syntax-table)) | |
646 (backward-sexp 1) | |
647 (while (= (char-syntax (following-char)) ?\') | |
648 (forward-char 1)) | |
649 (point)) | |
650 (set-syntax-table buffer-syntax))) | |
651 (minibuffer-completion-table obarray) | |
652 (minibuffer-completion-predicate | |
653 (if (eq (char-after (1- beg)) ?\() | |
654 'fboundp | |
655 (function (lambda (sym) | |
656 (or (boundp sym) (fboundp sym) | |
657 (symbol-plist sym)))))) | |
658 (PC-not-minibuffer t)) | |
659 (PC-do-completion nil beg end))) | |
660 | |
661 | |
662 ;;; Wildcards in `C-x C-f' command. This is independent from the main | |
663 ;;; completion code, except for `PC-expand-many-files' which is called | |
664 ;;; when "*"'s are found in the path during filename completion. (The | |
665 ;;; above completion code always understands "*"'s, except in file paths, | |
666 ;;; without relying on the following code.) | |
667 | |
668 (defvar PC-many-files-list nil) | |
669 | |
670 (defun PC-try-load-many-files () | |
671 (if (string-match "\\*" buffer-file-name) | |
672 (let* ((pat buffer-file-name) | |
673 (files (PC-expand-many-files pat)) | |
674 (first (car files)) | |
675 (next files)) | |
676 (kill-buffer (current-buffer)) | |
677 (or files | |
678 (error "No matching files")) | |
679 (save-window-excursion | |
680 (while (setq next (cdr next)) | |
681 (let ((buf (find-file-noselect (car next)))) | |
682 (switch-to-buffer buf)))) | |
683 ;; This modifies the "buf" variable inside find-file-noselect. | |
684 (setq buf (get-file-buffer first)) | |
685 (if buf | |
686 nil ; should do verify-visited-file-modtime stuff. | |
687 (setq filename first) | |
688 (setq buf (create-file-buffer filename)) | |
689 (set-buffer buf) | |
690 (erase-buffer) | |
691 (insert-file-contents filename t)) | |
692 (if (cdr files) | |
693 (setq PC-many-files-list (mapconcat | |
694 (if (string-match "\\*.*/" pat) | |
695 'identity | |
696 'file-name-nondirectory) | |
697 (cdr files) ", ") | |
698 find-file-hooks (cons 'PC-after-load-many-files | |
699 find-file-hooks))) | |
700 ;; This modifies the "error" variable inside find-file-noselect. | |
701 (setq error nil) | |
702 t) | |
703 nil)) | |
704 | |
705 (defun PC-after-load-many-files () | |
706 (setq find-file-hooks (delq 'PC-after-load-many-files find-file-hooks)) | |
707 (message "Also loaded %s." PC-many-files-list)) | |
708 | |
709 (defun PC-expand-many-files (name) | |
710 (save-excursion | |
711 (set-buffer (generate-new-buffer " *Glob Output*")) | |
712 (erase-buffer) | |
713 (shell-command (concat "echo " name) t) | |
714 (goto-char (point-min)) | |
715 (if (looking-at ".*No match") | |
716 nil | |
717 (insert "(\"") | |
718 (while (search-forward " " nil t) | |
719 (delete-backward-char 1) | |
720 (insert "\" \"")) | |
721 (goto-char (point-max)) | |
722 (delete-backward-char 1) | |
723 (insert "\")") | |
724 (goto-char (point-min)) | |
725 (let ((files (read (current-buffer)))) | |
726 (kill-buffer (current-buffer)) | |
727 files)))) | |
728 | |
729 (or PC-disable-wildcards | |
730 (memq 'PC-try-load-many-files find-file-not-found-hooks) | |
731 (setq find-file-not-found-hooks (cons 'PC-try-load-many-files | |
732 find-file-not-found-hooks))) | |
733 | |
734 | |
735 | |
736 ;;; Facilities for loading C header files. This is independent from the | |
737 ;;; main completion code. See also the variable `PC-include-file-path' | |
738 ;;; at top of this file. | |
739 | |
740 (defun PC-look-for-include-file () | |
741 (if (string-match "[\"<]\\([^\"<>]*\\)[\">]?$" (buffer-file-name)) | |
742 (let ((name (substring (buffer-file-name) | |
743 (match-beginning 1) (match-end 1))) | |
744 (punc (aref (buffer-file-name) (match-beginning 0))) | |
745 (path nil) | |
746 new-buf) | |
747 (kill-buffer (current-buffer)) | |
748 (if (equal name "") | |
749 (save-excursion | |
750 (set-buffer (car (buffer-list))) | |
751 (save-excursion | |
752 (beginning-of-line) | |
753 (if (looking-at | |
754 "[ \t]*#[ \t]*include[ \t]+[<\"]\\(.+\\)[>\"][ \t]*[\n/]") | |
755 (setq name (buffer-substring (match-beginning 1) | |
756 (match-end 1)) | |
757 punc (char-after (1- (match-beginning 1)))) | |
758 ;; Suggested by Frank Siebenlist: | |
759 (if (or (looking-at | |
760 "[ \t]*([ \t]*load[ \t]+\"\\([^\"]+\\)\"") | |
761 (looking-at | |
762 "[ \t]*([ \t]*load-library[ \t]+\"\\([^\"]+\\)\"") | |
763 (looking-at | |
764 "[ \t]*([ \t]*require[ \t]+'\\([^\t )]+\\)[\t )]")) | |
765 (progn | |
766 (setq name (buffer-substring (match-beginning 1) | |
767 (match-end 1)) | |
768 punc ?\< | |
769 path load-path) | |
770 (if (string-match "\\.elc$" name) | |
771 (setq name (substring name 0 -1)) | |
772 (or (string-match "\\.el$" name) | |
773 (setq name (concat name ".el"))))) | |
774 (error "Not on an #include line")))))) | |
775 (or (string-match "\\.[a-zA-Z0-9]+$" name) | |
776 (setq name (concat name ".h"))) | |
777 (if (eq punc ?\<) | |
778 (let ((path (or path (PC-include-file-path)))) | |
779 (while (and path | |
780 (not (file-exists-p | |
781 (concat (file-name-as-directory (car path)) | |
782 name)))) | |
783 (setq path (cdr path))) | |
784 (if path | |
785 (setq name (concat (file-name-as-directory (car path)) name)) | |
786 (error "No such include file: <%s>" name))) | |
787 (let ((dir (save-excursion | |
788 (set-buffer (car (buffer-list))) | |
789 default-directory))) | |
790 (if (file-exists-p (concat dir name)) | |
791 (setq name (concat dir name)) | |
792 (error "No such include file: \"%s\"" name)))) | |
793 (setq new-buf (get-file-buffer name)) | |
794 (if new-buf | |
795 ;; no need to verify last-modified time for this! | |
796 (set-buffer new-buf) | |
797 (setq new-buf (create-file-buffer name)) | |
798 (set-buffer new-buf) | |
799 (erase-buffer) | |
800 (insert-file-contents name t)) | |
801 (setq filename name | |
802 error nil | |
803 buf new-buf) | |
804 t) | |
805 nil)) | |
806 | |
807 (defun PC-include-file-path () | |
808 (or PC-include-file-path | |
809 (let ((env (getenv "INCPATH")) | |
810 (path nil) | |
811 pos) | |
812 (or env (error "No include file path specified")) | |
813 (while (setq pos (string-match ":[^:]+$" env)) | |
814 (setq path (cons (substring env (1+ pos)) path) | |
815 env (substring env 0 pos))) | |
816 path))) | |
817 | |
818 ;;; This is adapted from lib-complete.el, by Mike Williams. | |
819 (defun PC-include-file-all-completions (file search-path &optional full) | |
820 "Return all completions for FILE in any directory on SEARCH-PATH. | |
821 If optional third argument FULL is non-nil, returned pathnames should be | |
822 absolute rather than relative to some directory on the SEARCH-PATH." | |
823 (setq search-path | |
824 (mapcar '(lambda (dir) | |
825 (if dir (file-name-as-directory dir) default-directory)) | |
826 search-path)) | |
827 (if (file-name-absolute-p file) | |
828 ;; It's an absolute file name, so don't need search-path | |
829 (progn | |
830 (setq file (expand-file-name file)) | |
831 (file-name-all-completions | |
832 (file-name-nondirectory file) (file-name-directory file))) | |
833 (let ((subdir (file-name-directory file)) | |
834 (ndfile (file-name-nondirectory file)) | |
835 file-lists) | |
836 ;; Append subdirectory part to each element of search-path | |
837 (if subdir | |
838 (setq search-path | |
839 (mapcar '(lambda (dir) (concat dir subdir)) | |
840 search-path) | |
841 file )) | |
842 ;; Make list of completions in each directory on search-path | |
843 (while search-path | |
844 (let* ((dir (car search-path)) | |
845 (subdir (if full dir subdir))) | |
846 (if (file-directory-p dir) | |
847 (progn | |
848 (setq file-lists | |
849 (cons | |
850 (mapcar '(lambda (file) (concat subdir file)) | |
851 (file-name-all-completions ndfile | |
852 (car search-path))) | |
853 file-lists)))) | |
854 (setq search-path (cdr search-path)))) | |
855 ;; Compress out duplicates while building complete list (slloooow!) | |
856 (let ((sorted (sort (apply 'nconc file-lists) | |
857 '(lambda (x y) (not (string-lessp x y))))) | |
858 compressed) | |
859 (while sorted | |
860 (if (equal (car sorted) (car compressed)) nil | |
861 (setq compressed (cons (car sorted) compressed))) | |
862 (setq sorted (cdr sorted))) | |
863 compressed)))) | |
864 | |
865 (defvar PC-old-read-file-name-internal nil) | |
866 | |
867 (defun PC-read-include-file-name-internal (string dir action) | |
868 (if (string-match "<\\([^\"<>]*\\)>?$" string) | |
869 (let* ((name (substring string (match-beginning 1) (match-end 1))) | |
870 (str2 (substring string (match-beginning 0))) | |
871 (completion-table | |
872 (mapcar (function (lambda (x) (list (format "<%s>" x)))) | |
873 (PC-include-file-all-completions | |
874 name (PC-include-file-path))))) | |
875 (cond | |
876 ((not completion-table) nil) | |
877 ((eq action nil) (try-completion str2 completion-table nil)) | |
878 ((eq action t) (all-completions str2 completion-table nil)) | |
879 ((eq action 'lambda) | |
880 (eq (try-completion str2 completion-table nil) t)))) | |
881 (funcall PC-old-read-file-name-internal string dir action))) | |
882 | |
883 (or PC-disable-includes | |
884 (memq 'PC-look-for-include-file find-file-not-found-hooks) | |
885 (setq find-file-not-found-hooks (cons 'PC-look-for-include-file | |
886 find-file-not-found-hooks))) | |
887 | |
888 (or PC-disable-includes | |
889 PC-old-read-file-name-internal | |
890 (progn | |
891 (setq PC-old-read-file-name-internal | |
892 (symbol-function 'read-file-name-internal)) | |
893 (fset 'read-file-name-internal 'PC-read-include-file-name-internal))) | |
894 | |
895 | |
896 (provide 'complete) | |
897 | |
898 ;;; End. |