comparison lisp/filecache.el @ 53400:01072e418fa4

(file-cache-ignore-case): New variable. (file-cache-assoc-function): Var deleted. Use assoc-string instead.
author Richard M. Stallman <rms@gnu.org>
date Mon, 29 Dec 2003 19:12:17 +0000
parents 695cf19ef79e
children 2598e11dc4dd
comparison
equal deleted inserted replaced
53399:9a9d11c249b9 53400:01072e418fa4
210 Defaults to the value of `case-fold-search'." 210 Defaults to the value of `case-fold-search'."
211 :type 'sexp 211 :type 'sexp
212 :group 'file-cache 212 :group 'file-cache
213 ) 213 )
214 214
215 (defcustom file-cache-assoc-function 215 (defcustom file-cache-ignore-case
216 (if (memq system-type (list 'ms-dos 'windows-nt 'cygwin)) 216 (memq system-type (list 'ms-dos 'windows-nt 'cygwin))
217 'assoc-ignore-case 217 "Non-nil means ignore case when checking completions in the file cache.
218 'assoc) 218 Defaults to nil on DOS and Windows, and t on other systems."
219 "Function to use to check completions in the file cache.
220 Defaults to `assoc-ignore-case' on DOS and Windows, and `assoc' on
221 other systems."
222 :type 'sexp 219 :type 'sexp
223 :group 'file-cache 220 :group 'file-cache
224 ) 221 )
225 222
226 (defvar file-cache-multiple-directory-message nil) 223 (defvar file-cache-multiple-directory-message nil)
299 (interactive "fAdd File: ") 296 (interactive "fAdd File: ")
300 (if (not (file-exists-p file)) 297 (if (not (file-exists-p file))
301 (message "File %s does not exist" file) 298 (message "File %s does not exist" file)
302 (let* ((file-name (file-name-nondirectory file)) 299 (let* ((file-name (file-name-nondirectory file))
303 (dir-name (file-name-directory file)) 300 (dir-name (file-name-directory file))
304 (the-entry (funcall file-cache-assoc-function 301 (the-entry (assoc-string
305 file-name file-cache-alist)) 302 file-name file-cache-alist
303 file-cache-ignore-case))
306 ) 304 )
307 ;; Does the entry exist already? 305 ;; Does the entry exist already?
308 (if the-entry 306 (if the-entry
309 (if (or (and (stringp (cdr the-entry)) 307 (if (or (and (stringp (cdr the-entry))
310 (string= dir-name (cdr the-entry))) 308 (string= dir-name (cdr the-entry)))
400 (defun file-cache-delete-file (file) 398 (defun file-cache-delete-file (file)
401 "Delete FILE from the file cache." 399 "Delete FILE from the file cache."
402 (interactive 400 (interactive
403 (list (completing-read "Delete file from cache: " file-cache-alist))) 401 (list (completing-read "Delete file from cache: " file-cache-alist)))
404 (setq file-cache-alist 402 (setq file-cache-alist
405 (delq (funcall file-cache-assoc-function file file-cache-alist) 403 (delq (assoc-string file file-cache-alist file-cache-ignore-case)
406 file-cache-alist))) 404 file-cache-alist)))
407 405
408 (defun file-cache-delete-file-list (file-list) 406 (defun file-cache-delete-file-list (file-list)
409 "Delete FILE-LIST (a list of files) from the file cache." 407 "Delete FILE-LIST (a list of files) from the file cache."
410 (interactive "XFile List: ") 408 (interactive "XFile List: ")
456 ;; Utility functions 454 ;; Utility functions
457 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 455 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
458 456
459 ;; Returns the name of a directory for a file in the cache 457 ;; Returns the name of a directory for a file in the cache
460 (defun file-cache-directory-name (file) 458 (defun file-cache-directory-name (file)
461 (let* ((directory-list (cdr (funcall file-cache-assoc-function 459 (let* ((directory-list (cdr (assoc-string
462 file file-cache-alist))) 460 file file-cache-alist
461 file-cache-ignore-case)))
463 (len (length directory-list)) 462 (len (length directory-list))
464 (directory) 463 (directory)
465 (num) 464 (num)
466 ) 465 )
467 (if (not (listp directory-list)) 466 (if (not (listp directory-list))
554 ;; If it's the longest match, insert it 553 ;; If it's the longest match, insert it
555 ((stringp completion-string) 554 ((stringp completion-string)
556 ;; If we've already inserted a unique string, see if the user 555 ;; If we've already inserted a unique string, see if the user
557 ;; wants to use that one 556 ;; wants to use that one
558 (if (and (string= string completion-string) 557 (if (and (string= string completion-string)
559 (funcall file-cache-assoc-function string file-cache-alist)) 558 (assoc-string string file-cache-alist
559 file-cache-ignore-case))
560 (if (and (eq last-command this-command) 560 (if (and (eq last-command this-command)
561 (string= file-cache-last-completion completion-string)) 561 (string= file-cache-last-completion completion-string))
562 (progn 562 (progn
563 (delete-minibuffer-contents) 563 (delete-minibuffer-contents)
564 (insert (file-cache-file-name completion-string)) 564 (insert (file-cache-file-name completion-string))
723 723
724 (defun file-cache-debug-read-from-minibuffer (file) 724 (defun file-cache-debug-read-from-minibuffer (file)
725 "Debugging function." 725 "Debugging function."
726 (interactive 726 (interactive
727 (list (completing-read "File Cache: " file-cache-alist))) 727 (list (completing-read "File Cache: " file-cache-alist)))
728 (message "%s" (funcall file-cache-assoc-function file file-cache-alist)) 728 (message "%s" (assoc-string file file-cache-alist
729 file-cache-ignore-case))
729 ) 730 )
730 731
731 (defun file-cache-display () 732 (defun file-cache-display ()
732 "Display the file cache." 733 "Display the file cache."
733 (interactive) 734 (interactive)