aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1998-01-03 00:04:35 +0000
committerRichard M. Stallman1998-01-03 00:04:35 +0000
commit13161e8bd9a9c5362073276c017ff39fd547659d (patch)
treee4be8f4ed08aad77e6b7485653a4ec239b8d87a5 /lisp
parent977101145a5ced87dfd4c134fa4fe4c372d383a0 (diff)
downloademacs-13161e8bd9a9c5362073276c017ff39fd547659d.tar.gz
emacs-13161e8bd9a9c5362073276c017ff39fd547659d.zip
(file-cache-minibuffer-complete): Accept a prefix arg.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/filecache.el177
1 files changed, 50 insertions, 127 deletions
diff --git a/lisp/filecache.el b/lisp/filecache.el
index e8a55ac1645..08ae14c7395 100644
--- a/lisp/filecache.el
+++ b/lisp/filecache.el
@@ -2,35 +2,28 @@
2;; 2;;
3;; Author: Peter Breton 3;; Author: Peter Breton
4;; Created: Sun Nov 10 1996 4;; Created: Sun Nov 10 1996
5;; Version: $Id: filecache.el,v 1.13 1997/02/07 22:27:51 pbreton Exp $
6;; Keywords: 5;; Keywords:
7;; Time-stamp: <97/02/07 17:26:54 peter> 6;; Time-stamp: <97/02/07 17:26:54 peter>
8;; 7;;
9;; Copyright (C) Peter Breton Thu Dec 12 1996 8;; Copyright (C) 1996 Free Software Foundation, Inc.
10;; 9
11;; This is free software; you can redistribute it and/or modify 10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by 13;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation; either version 2, or (at your option) 14;; the Free Software Foundation; either version 2, or (at your option)
14;; any later version. 15;; any later version.
15;; 16
16;; filecache.el is distributed in the hope that it will be useful, 17;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; General Public License for more details. 20;; GNU General Public License for more details.
20;; 21
21;; You should have received a copy of the GNU General Public License 22;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs; see the file COPYING. If not, write to 23;; along with GNU Emacs; see the file COPYING. If not, write to the
23;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 24;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24;; 25;; Boston, MA 02111-1307, USA.
25;; LCD Archive Entry: 26
26;; filecache.el|Peter Breton|pbreton@i-kinetics.com|
27;; Find files using a pre-loaded cache|
28;; Thu Dec 12 1996|1.0|~/misc/filecache.el.gz|
29;;
30;; Purpose:
31;;
32;; Find files using a pre-loaded cache
33;;
34;;; Commentary: 27;;; Commentary:
35;; 28;;
36;; The file-cache package is an attempt to make it easy to locate files 29;; The file-cache package is an attempt to make it easy to locate files
@@ -146,91 +139,7 @@
146;; This package is a distant relative of Noah Friedman's fff utilities. 139;; This package is a distant relative of Noah Friedman's fff utilities.
147;; Our goal is pretty similar, but the implementation strategies are 140;; Our goal is pretty similar, but the implementation strategies are
148;; different. 141;; different.
149;; 142
150;;; Change log:
151;; $Log: filecache.el,v $
152;; Revision 1.13 1997/02/07 22:27:51 pbreton
153;; Keybindings use autoload cookies instead of variable
154;;
155;; Revision 1.12 1997/02/07 22:02:29 pbreton
156;; Added small changes suggested by RMS:
157;; Revamped the doc strings
158;; Added keybindings (using `file-cache-default-minibuffer-key' variable)
159;;
160;; Revision 1.11 1997/02/01 16:44:47 pbreton
161;; Changed `file-cache-directory-name' function. Instead of using a
162;; completing-read, it cycles through the directory list.
163;;
164;; Eliminated bug where file-cache-file-name was called twice per completion.
165;;
166;; Revision 1.10 1997/01/26 05:44:24 pbreton
167;; Added file-cache-delete functions
168;; Added file-cache-completions-buffer variable
169;; Added file-cache-completions-keymap variable
170;; Changed file-cache-completion-setup-function to use
171;; file-cache-completions-keymap
172;; Added file-cache-choose-completion and file-cache-mouse-choose-completion.
173;; These rely on a patch to 'simple.el'
174;; Added file-cache-debug-read-from-minibuffer function
175;;
176;; Revision 1.9 1997/01/17 17:54:24 pbreton
177;; File names are no longer case-insensitive; this was tolerable on NT but
178;; not on Unix. Instead, file-cache-minibuffer-complete checks to see if the
179;; last command was itself, and if the same string is in the minibuffer. If so,
180;; this string is used for completion.
181;;
182;; Added some functions to delete from the file-cache
183;;
184;; Completing-read of directories requires temporary binding of
185;; enable-recursive-minibuffers variable.
186;;
187;; Revision 1.8 1997/01/17 14:01:08 pbreton
188;; Changed file-cache-minibuffer-complete so that it operates in the
189;; minibuffer instead of as a recursive minibuffer call.
190;;
191;; File-cache-alist now expects a filename and a list of directories (there
192;; should be at least one). If the list has only one element, that element
193;; is used; if it has multiple directories, the user is prompted to choose
194;; one.
195;;
196;; File names in the cache are now canonicalized to lowercase, to resolve a
197;; problem which occurs when the cache has files like README and readme.
198;;
199;; Removed a lot of the extra completion functions which weren't used.
200;;
201;; Revision 1.7 1996/12/29 15:48:28 pbreton
202;; Added functions:
203;; `file-cache-minibuffer-complete-using-suffix'
204;; `file-cache-minibuffer-complete-with-directory-filter'
205;; `file-cache-minibuffer-complete-with-filename-filter'
206;; Added documentation for these functions
207;;
208;; Revision 1.6 1996/12/24 20:27:56 pbreton
209;; Added predicate functions to `file-cache-minibuffer-complete'
210;;
211;; Revision 1.5 1996/12/14 18:05:11 pbreton
212;; Fixed uniquify bug by using `member' instead of `memq'
213;; Made file-cache-add-* prompts more descriptive
214;; More documentation
215;;
216;; Revision 1.4 1996/12/13 14:42:37 pbreton
217;; Removed `file-cache-top-directory' variable
218;; Changed file-cache-initialize to file-cache-add-from-file-cache-buffer
219;; Regexp to match files in file-cache-buffer is now a variable
220;;
221;; Revision 1.3 1996/12/12 06:01:27 peter
222;; Added `file-cache-add-file' and `file-cache-add-file-list' functions
223;;
224;; Revision 1.2 1996/12/12 05:47:49 peter
225;; Fixed uniquifying bug
226;; Added directory functions
227;; `file-cache-find-file' now uses file-cache-file-name
228;; `file-cache-minibuffer-complete' handles string completion correctly.
229;; It also prepends `file-cache-minibuffer-prompt' to the normal prompt
230;;
231;; Revision 1.1 1996/11/26 12:12:43 peter
232;; Initial revision
233;;
234;;; Code: 143;;; Code:
235 144
236;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 145;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -512,21 +421,46 @@ or the optional REGEXP argument."
512;; Minibuffer functions 421;; Minibuffer functions
513;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 422;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
514 423
424;; The prefix argument works around a bug in the minibuffer completion.
425;; The completion function doesn't distinguish between the states:
426;;
427;; "Multiple completions of name" (eg, Makefile, Makefile.in)
428;; "Name available in multiple directories" (/tmp/Makefile, ~me/Makefile)
429;;
430;; The default is to do the former; a prefix arg forces the latter.
431
515;;;###autoload 432;;;###autoload
516(defun file-cache-minibuffer-complete () 433(defun file-cache-minibuffer-complete (arg)
517 "Complete a filename in the minibuffer using a preloaded cache." 434 "Complete a filename in the minibuffer using a preloaded cache.
518 (interactive) 435Filecache does two kinds of substitution: it completes on names in
436the cache, and, once it has found a unique name, it cycles through
437the directories that the name is available in. With a prefix argument,
438the name is considered already unique; only the second substitution
439\(directories) is done."
440 (interactive "P")
519 (let* 441 (let*
520 ( 442 (
521 (completion-ignore-case nil) 443 (completion-ignore-case nil)
522 (case-fold-search nil) 444 (case-fold-search nil)
523 (string (file-name-nondirectory (buffer-string))) 445 (string (file-name-nondirectory (buffer-string)))
524 (completion-string (try-completion string file-cache-alist)) 446 (completion-string (try-completion string file-cache-alist))
525 (completion-list) 447 (completion-list)
526 (len) 448 (len)
527 (file-cache-string) 449 (file-cache-string)
528 ) 450 )
529 (cond 451 (cond
452 ;; If it's the only match, replace the original contents
453 ((or arg (eq completion-string t))
454 (setq file-cache-string (file-cache-file-name string))
455 (if (string= file-cache-string (buffer-string))
456 (file-cache-temp-minibuffer-message file-cache-sole-match-message)
457 (erase-buffer)
458 (insert-string file-cache-string)
459 (if file-cache-multiple-directory-message
460 (file-cache-temp-minibuffer-message
461 file-cache-multiple-directory-message))
462 ))
463
530 ;; If it's the longest match, insert it 464 ;; If it's the longest match, insert it
531 ((stringp completion-string) 465 ((stringp completion-string)
532 ;; If we've already inserted a unique string, see if the user 466 ;; If we've already inserted a unique string, see if the user
@@ -563,26 +497,15 @@ or the optional REGEXP argument."
563 ) 497 )
564 (setq file-cache-string (file-cache-file-name completion-string)) 498 (setq file-cache-string (file-cache-file-name completion-string))
565 (if (string= file-cache-string (buffer-string)) 499 (if (string= file-cache-string (buffer-string))
566 (file-cache-temp-minibuffer-message file-cache-sole-match-message) 500 (file-cache-temp-minibuffer-message
501 file-cache-sole-match-message)
567 (erase-buffer) 502 (erase-buffer)
568 (insert-string file-cache-string) 503 (insert-string file-cache-string)
569 (if file-cache-multiple-directory-message 504 (if file-cache-multiple-directory-message
570 (file-cache-temp-minibuffer-message 505 (file-cache-temp-minibuffer-message
571 file-cache-multiple-directory-message))) 506 file-cache-multiple-directory-message)))
572 ))) 507 )))
573 508
574 ;; If it's the only match, replace the original contents
575 ((eq completion-string t)
576 (setq file-cache-string (file-cache-file-name string))
577 (if (string= file-cache-string (buffer-string))
578 (file-cache-temp-minibuffer-message file-cache-sole-match-message)
579 (erase-buffer)
580 (insert-string file-cache-string)
581 (if file-cache-multiple-directory-message
582 (file-cache-temp-minibuffer-message
583 file-cache-multiple-directory-message))
584 ))
585
586 ;; No match 509 ;; No match
587 ((eq completion-string nil) 510 ((eq completion-string nil)
588 (file-cache-temp-minibuffer-message file-cache-no-match-message)) 511 (file-cache-temp-minibuffer-message file-cache-no-match-message))
@@ -628,7 +551,7 @@ or the optional REGEXP argument."
628 (let ((completion-no-auto-exit t)) 551 (let ((completion-no-auto-exit t))
629 (choose-completion) 552 (choose-completion)
630 (select-window (active-minibuffer-window)) 553 (select-window (active-minibuffer-window))
631 (file-cache-minibuffer-complete) 554 (file-cache-minibuffer-complete nil)
632 ) 555 )
633 ) 556 )
634 557
@@ -638,7 +561,7 @@ or the optional REGEXP argument."
638 (let ((completion-no-auto-exit t)) 561 (let ((completion-no-auto-exit t))
639 (mouse-choose-completion event) 562 (mouse-choose-completion event)
640 (select-window (active-minibuffer-window)) 563 (select-window (active-minibuffer-window))
641 (file-cache-minibuffer-complete) 564 (file-cache-minibuffer-complete nil)
642 ) 565 )
643 ) 566 )
644 567