annotate lisp/efs/fn-handler.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents 8fc7fe29b841
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;; -*-Emacs-Lisp-*-
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
4 ;; File: fn-handler.el
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
5 ;; Description: enhanced file-name-handler-alist support for pre-19.23 Emacs
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
6 ;; Author: Sandy Rutherford <sandy@ibm550.sissa.it>
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7 ;; Created: Sat Mar 19 00:50:10 1994 by sandy on ibm550
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;; Modified: Tue Sep 13 20:59:19 1994 by sandy on ibm550
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9 ;; Language: Emacs-Lisp
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14 ;;; One of the problems with the file-name-handler-alist, is that when
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15 ;;; a handler gets called, and it has nothing to do for that function,
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 ;;; the usual procedure is to remove the handler from the alist, and
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 ;;; re-call the function. This is necessary to avoid an infinite
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18 ;;; recursion. However, if the function calling
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19 ;;; find-file-name-handler is not a primitive, there may be other lisp
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 ;;; functions inside of it for which the handler does have some
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21 ;;; special actions specified. They won't run, because the let-bound
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 ;;; value of file-name-handler-alist doesn't contain the handler.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23 ;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24 ;;; This problem was solved in Emacs 19.23 with the variables
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25 ;;; inhibit-file-name-handlers and inhibit-file-name-operation
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26 ;;; This file provides this solution to older versions of emacs.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 (provide 'fn-handler)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30 (require 'efs-ovwrt)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 (or (boundp 'file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 (defvar file-name-handler-alist nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 "Association list of regexps for special file names and handlers."))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 (defvar inhibit-file-name-handlers nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 "List of handlers \(symbols\) to be avoided by `find-file-name-handler'.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 (defvar inhibit-file-name-operation nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 "Defines to which operation `inhibit-file-name-handlers applies'
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 Must be a synbol.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 (defun find-file-name-handler (filename &optional operation)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44 "Return FILENAME1's handler function, if its syntax is handled specially.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 Does not return handlers in `inhibit-file-name-handlers' list.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 If there is no handler for FILENAME1, searches for one for FILENAME2.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 Returns nil, if there is no handler for either file name.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48 A file name is handles specially if one of the regular expressions in
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 `file-name-handler-alist' matches it."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 (let ((match-data (match-data)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 (unwind-protect
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52 (catch 'handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 (mapcar (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 (lambda (x)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 (and
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 (not
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 (and
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 (or (null operation)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59 (eq operation inhibit-file-name-operation))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60 (memq (cdr x) inhibit-file-name-handlers)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 (string-match (car x) filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62 (throw 'handler (cdr x)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64 nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65 (store-match-data match-data))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67 ;;; Overloads to supply the file-name-handler-alist
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69 (defun fn-handler-insert-file-contents (filename &optional visit &rest args)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72 (handler (find-file-name-handler filename 'insert-file-contents)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74 (apply handler 'insert-file-contents filename visit args)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76 (apply 'fn-handler-real-insert-file-contents filename visit args)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
78 (efs-overwrite-fn "fn-handler" 'insert-file-contents
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79 'fn-handler-insert-file-contents)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
80
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81 (defun fn-handler-directory-files (directory &optional full match &rest nosort)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83 (let ((handler (find-file-name-handler directory 'directory-files)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85 (apply handler 'directory-files directory full match nosort)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87 (apply 'fn-handler-real-directory-files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88 directory full match nosort)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 (efs-overwrite-fn "fn-handler" 'directory-files 'fn-handler-directory-files)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 (defun fn-handler-list-directory (dirname &optional verbose)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94 (interactive (let ((pfx current-prefix-arg))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95 (list (read-file-name (if pfx "List directory (verbose): "
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96 "List directory (brief): ")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 nil default-directory nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 pfx)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (let ((handler (find-file-name-handler dirname 'list-directory)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 (funcall handler 'list-directory dirname verbose)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103 (fn-handler-real-list-directory dirname verbose)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105 (efs-overwrite-fn "fn-handler" 'list-directory 'fn-handler-list-directory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107 (defun fn-handler-file-directory-p (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110 (handler (find-file-name-handler filename 'file-directory-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 (funcall handler 'file-directory-p filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114 (fn-handler-real-file-directory-p filename)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116 (efs-overwrite-fn "fn-handler" ' file-directory-p 'fn-handler-file-directory-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 (defun fn-handler-file-writable-p (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121 (handler (find-file-name-handler filename 'file-writable-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
123 (funcall handler 'file-writable-p filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
124 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
125 (fn-handler-real-file-writable-p filename)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
126
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
127 (efs-overwrite-fn "fn-handler" 'file-writable-p 'fn-handler-file-writable-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
128
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
129 (defun fn-handler-file-readable-p (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
130 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
131 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
132 (handler (find-file-name-handler filename 'file-readable-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
133 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
134 (funcall handler 'file-readable-p filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
135 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
136 (fn-handler-real-file-readable-p filename)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
137
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
138 (efs-overwrite-fn "fn-handler" 'file-readable-p 'fn-handler-file-readable-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
139
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
140 (defun fn-handler-file-symlink-p (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
141 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
142 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
143 (handler (find-file-name-handler filename 'file-symlink-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
144 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
145 (funcall handler 'file-symlink-p filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
146 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
147 (fn-handler-real-file-symlink-p filename)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
148
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
149 (efs-overwrite-fn "fn-handler" 'file-symlink-p 'fn-handler-file-symlink-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
150
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
151 (defun fn-handler-delete-file (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
152 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
153 (interactive (list (read-file-name "Delete-file: " nil nil t)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
154 (let* ((file (expand-file-name file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
155 (handler (find-file-name-handler file 'delete-file)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
156 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
157 (funcall handler 'delete-file file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
158 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
159 (fn-handler-real-delete-file file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
160
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
161 (efs-overwrite-fn "fn-handler" 'delete-file 'fn-handler-delete-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
162
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
163 (defun fn-handler-file-exists-p (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
164 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
165 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
166 (handler (find-file-name-handler filename 'file-exists-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
167 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
168 (funcall handler 'file-exists-p filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
169 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
170 (fn-handler-real-file-exists-p filename)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
171
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
172 (efs-overwrite-fn "fn-handler" 'file-exists-p 'fn-handler-file-exists-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
173
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
174 (defun fn-handler-write-region (start end filename &optional append visit)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
175 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
176 ;; Use read-file-name, rather then interactive spec,
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
177 ;; to make it easier to get decent initial contents in the minibuffer.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
178 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
179 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
180 (or (mark) (error "The mark is not set now."))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
181 (list (min (point) (mark))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
182 (max (point) (mark))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
183 (read-file-name "Write region to file: "))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
184 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
185 (handler (or (find-file-name-handler filename 'write-region)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
186 (and (stringp visit)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
187 (find-file-name-handler (expand-file-name visit)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
188 'write-region)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
189 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
190 (funcall handler 'write-region start end filename append visit)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
191 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
192 (fn-handler-real-write-region start end filename append visit)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
193
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
194 (efs-overwrite-fn "fn-handler" 'write-region
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
195 'fn-handler-write-region)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
196
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
197 (defun fn-handler-verify-visited-file-modtime (buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
198 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
199 (let* ((file (buffer-file-name buffer))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
200 (handler (and file (find-file-name-handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
201 file
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
202 'verify-visited-file-modtime))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
203 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
204 (funcall handler 'verify-visited-file-modtime buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
205 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
206 (fn-handler-real-verify-visited-file-modtime buffer)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
207
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
208 (efs-overwrite-fn "fn-handler" 'verify-visited-file-modtime
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
209 'fn-handler-verify-visited-file-modtime)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
210
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
211 (defun fn-handler-backup-buffer ()
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
212 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
213 (let ((handler (and buffer-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
214 (find-file-name-handler buffer-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
215 'backup-buffer))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
216 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
217 (funcall handler 'backup-buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
218 ;; Don't let-bind file-name-handler-alist to nil, as backup-buffer
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
219 ;; is a lisp function and I want handlers to be available inside it.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
220 (fn-handler-real-backup-buffer))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
221
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
222 (efs-overwrite-fn "fn-handler" 'backup-buffer 'fn-handler-backup-buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
223
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
224 (defun fn-handler-copy-file (filename newname &optional ok-if-already-exists
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
225 keep-date)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
226 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
227 ;; handler for filename takes precedence over the handler for newname.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
228 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
229 (let* ((from (read-file-name "Copy file: " nil nil t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
230 (to (read-file-name (format "Copy %s to: " (abbreviate-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
231 from)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
232 (list from to 0 current-prefix-arg)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
233 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
234 (newname (expand-file-name newname))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
235 (handler (or (find-file-name-handler filename 'copy-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
236 (find-file-name-handler newname 'copy-file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
237 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
238 ;; Using the NOWAIT arg is a bit risky for other users of the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
239 ;; handler-alist
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
240 (funcall handler 'copy-file filename newname ok-if-already-exists
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
241 keep-date)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
242 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
243 (fn-handler-real-copy-file filename newname ok-if-already-exists
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
244 keep-date)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
245
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
246 (efs-overwrite-fn "fn-handler" 'copy-file 'fn-handler-copy-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
247
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
248 (defun fn-handler-file-newer-than-file-p (file1 file2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
249 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
250 ;; The handler for file2 takes precedence over the handler for file1.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
251 (let* ((file1 (expand-file-name file1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
252 (file2 (expand-file-name file2))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
253 (handler (or (find-file-name-handler file2 'file-newer-than-file-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
254 (find-file-name-handler file1 'file-newer-than-file-p))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
255 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
256 (funcall handler 'file-newer-than-file-p file1 file2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
257 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
258 (fn-handler-real-file-newer-than-file-p file1 file2)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
259
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
260 (efs-overwrite-fn "fn-handler" 'file-newer-than-file-p
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
261 'fn-handler-file-newer-than-file-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
262
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
263 (defun fn-handler-file-attributes (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
264 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
265 (let* ((file (expand-file-name file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
266 (handler (find-file-name-handler file 'file-attributes)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
267 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
268 (funcall handler 'file-attributes file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
269 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
270 (fn-handler-real-file-attributes file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
271
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
272 (efs-overwrite-fn "fn-handler" 'file-attributes 'fn-handler-file-attributes)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
273
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
274 (defun fn-handler-file-name-directory (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
275 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
276 (let ((handler (find-file-name-handler file 'file-name-directory)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
277 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
278 (funcall handler 'file-name-directory file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
279 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
280 (fn-handler-real-file-name-directory file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
281
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
282 (efs-overwrite-fn "fn-handler" 'file-name-directory
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
283 'fn-handler-file-name-directory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
284
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
285 (defun fn-handler-rename-file (filename newname &optional ok-if-already-exists)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
286 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
287 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
288 (let* ((from (read-file-name "Rename file: " nil nil t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
289 (to (read-file-name (format "Rename %s to: " (abbreviate-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
290 from)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
291 (list from to 0)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
292 (let* ((filename (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
293 (newname (expand-file-name newname))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
294 (handler (or (find-file-name-handler filename 'rename-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
295 (find-file-name-handler newname 'rename-file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
296 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
297 (funcall handler 'rename-file filename newname ok-if-already-exists)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
298 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
299 (fn-handler-real-rename-file filename newname ok-if-already-exists)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
300
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
301 (efs-overwrite-fn "fn-handler" 'rename-file 'fn-handler-rename-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
302
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
303 (defun fn-handler-insert-directory (file switches
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
304 &optional wildcard full-directory-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
305 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
306 (let* ((file (expand-file-name file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
307 (handler (find-file-name-handler file 'insert-directory)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
308 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
309 (funcall handler 'insert-directory file switches wildcard
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
310 full-directory-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
311 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
312 (fn-handler-real-insert-directory file switches wildcard
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
313 full-directory-p)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
314
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
315 (efs-overwrite-fn "fn-handler" 'insert-directory 'fn-handler-insert-directory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
316
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
317 (defun fn-handler-set-visited-file-modtime (&optional time)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
318 "Sets the buffer's record of file modtime to the modtime of buffer-file-name.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
319 With optional TIME, sets the modtime to TIME. This is an emacs 19 function.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
320 In emacs 18, efs will make this work for remote files only."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
321 (if buffer-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
322 (let ((handler (find-file-name-handler buffer-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
323 'set-visited-file-modtime)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
324 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
325 (funcall handler 'set-visited-file-modtime time)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
326 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
327 (fn-handler-real-set-visited-file-modtime time))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
328
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
329 (efs-overwrite-fn "fn-handler" 'set-visited-file-modtime
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
330 'fn-handler-set-visited-file-modtime)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
331
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
332 (defun fn-handler-file-name-nondirectory (name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
333 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
334 (let ((handler (find-file-name-handler name 'file-name-nondirectory)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
335 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
336 (funcall handler 'file-name-nondirectory name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
337 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
338 (fn-handler-real-file-name-nondirectory name)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
339
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
340 (efs-overwrite-fn "fn-handler" 'file-name-nondirectory
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
341 'fn-handler-file-name-nondirectory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
342
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
343 (defun fn-handler-file-name-as-directory (name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
344 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
345 (let ((handler (find-file-name-handler name 'file-name-as-directory)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
346 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
347 (funcall handler 'file-name-as-directory name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
348 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
349 (fn-handler-real-file-name-as-directory name)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
350
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
351 (efs-overwrite-fn "fn-handler" 'file-name-as-directory
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
352 'fn-handler-file-name-as-directory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
353
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
354 (defun fn-handler-directory-file-name (directory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
355 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
356 (let ((handler (find-file-name-handler directory 'directory-file-name)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
357 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
358 (funcall handler 'directory-file-name directory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
359 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
360 (fn-handler-real-directory-file-name directory)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
361
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
362 (efs-overwrite-fn "fn-handler" 'directory-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
363 'fn-handler-directory-file-name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
364
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
365 (defun fn-handler-get-file-buffer (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
366 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
367 (let ((handler (find-file-name-handler file 'get-file-buffer)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
368 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
369 (funcall handler 'get-file-buffer file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
370 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
371 (fn-handler-real-get-file-buffer file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
372
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
373 (efs-overwrite-fn "fn-handler" 'get-file-buffer 'fn-handler-get-file-buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
374
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
375 (defun fn-handler-create-file-buffer (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
376 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
377 (let ((handler (find-file-name-handler file 'create-file-buffer)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
378 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
379 (funcall handler 'create-file-buffer file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
380 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
381 (fn-handler-real-create-file-buffer file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
382
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
383 (efs-overwrite-fn "fn-handler" 'create-file-buffer
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
384 'fn-handler-create-file-buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
385
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
386 (defun fn-handler-set-file-modes (file mode)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
387 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
388 (let* ((file (expand-file-name file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
389 (handler (find-file-name-handler file 'set-file-modes)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
390 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
391 (funcall handler 'set-file-modes file mode)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
392 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
393 (fn-handler-real-set-file-modes file mode)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
394
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
395 (efs-overwrite-fn "fn-handler" 'set-file-modes 'fn-handler-set-file-modes)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
396
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
397 (defun fn-handler-file-modes (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
398 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
399 (let* ((file (expand-file-name file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
400 (handler (find-file-name-handler file 'file-modes)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
401 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
402 (funcall handler 'file-modes file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
403 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
404 (fn-handler-real-file-modes file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
405
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
406 (efs-overwrite-fn "fn-handler" 'file-modes 'fn-handler-file-modes)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
407
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
408 (if (string-match emacs-version "Lucid")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
409
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
410 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
411 (defun fn-handler-abbreviate-file-name (filename &optional hack-homedir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
412 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
413 (let ((handler (find-file-name-handler filename
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
414 'abbreviate-file-name)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
415 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
416 (funcall handler 'abbreviate-file-name filename hack-homedir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
417 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
418 (fn-handler-real-abbreviate-file-name filename hack-homedir))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
419
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
420 (defun fn-handler-abbreviate-file-name (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
421 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
422 (let ((handler (find-file-name-handler filename 'abbreviate-file-name)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
423 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
424 (funcall handler 'abbreviate-file-name filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
425 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
426 (fn-handler-real-abbreviate-file-name filename))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
427
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
428 (efs-overwrite-fn "fn-handler" 'abbreviate-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
429 'fn-handler-abbreviate-file-name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
430
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
431 (defun fn-handler-file-name-sans-versions (filename
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
432 &optional keep-backup-version)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
433 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
434 (let ((handler (find-file-name-handler filename 'file-name-sans-versions)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
435 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
436 (funcall handler 'file-name-sans-versions filename
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
437 keep-backup-version)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
438 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
439 (fn-handler-real-file-name-sans-versions filename
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
440 keep-backup-version)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
441
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
442 (efs-overwrite-fn "fn-handler" 'file-name-sans-versions
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
443 'fn-handler-file-name-sans-versions)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
444
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
445 (if (fboundp 'make-directory-internal) ; not defined in lemacs 19.[67]
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
446 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
447 (defun fn-handler-make-directory-internal (dirname)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
448 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
449 (let* ((dirname (expand-file-name dirname))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
450 (handler (find-file-name-handler dirname
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
451 'make-directory-internal)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
452 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
453 (funcall handler 'make-directory-internal dirname)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
454 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
455 (fn-handler-real-make-directory-internal dirname)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
456
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
457 (efs-overwrite-fn "fn-handler" 'make-directory-internal
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
458 'fn-handler-make-directory-internal)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
459
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
460 (defun fn-handler-delete-directory (dirname)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
461 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
462 (let* ((dirname (expand-file-name dirname))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
463 (handler (find-file-name-handler dirname 'delete-directory)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
464 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
465 (funcall handler 'delete-directory dirname)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
466 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
467 (fn-handler-real-delete-directory dirname)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
468
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
469 (efs-overwrite-fn "fn-handler" 'delete-directory 'fn-handler-delete-directory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
470
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
471 (defun fn-handler-make-symbolic-link (target linkname
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
472 &optional ok-if-already-exists)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
473 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
474 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
475 (let (target)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
476 (list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
477 (setq target (read-string "Make symbolic link to file: "))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
478 (read-file-name (format "Make symbolic link to file %s: " target))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
479 0)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
480 (let* ((linkname (expand-file-name linkname))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
481 (handler (or (find-file-name-handler linkname 'make-symbolic-link)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
482 (find-file-name-handler target 'make-symbolic-link))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
483 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
484 (funcall handler 'make-symbolic-link
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
485 target linkname ok-if-already-exists)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
486 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
487 (fn-handler-real-make-symbolic-link target linkname
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
488 ok-if-already-exists)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
489
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
490 (efs-overwrite-fn "fn-handler" 'make-symbolic-link
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
491 'fn-handler-make-symbolic-link)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
492
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
493 (defun fn-handler-add-name-to-file (file newname &optional
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
494 ok-if-already-exists)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
495 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
496 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
497 (let (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
498 (list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
499 (setq file (read-file-name "Add name to file: " nil nil t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
500 (read-file-name (format "Name to add to %s: " file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
501 0)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
502 (let* ((file (expand-file-name file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
503 (newname (expand-file-name newname))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
504 (handler (or (find-file-name-handler newname 'add-name-to-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
505 (find-file-name-handler file 'add-name-to-file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
506 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
507 (funcall handler 'add-name-to-file file newname ok-if-already-exists)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
508 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
509 (fn-handler-real-add-name-to-file file newname
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
510 ok-if-already-exists)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
511
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
512 (efs-overwrite-fn "fn-handler" 'add-name-to-file 'fn-handler-add-name-to-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
513
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
514 (defun fn-handler-recover-file (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
515 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
516 (interactive "FRecover file: ")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
517 (let* ((file (expand-file-name file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
518 (handler (or (find-file-name-handler file 'recover-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
519 (find-file-name-handler (let ((buffer-file-name file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
520 (make-auto-save-file-name))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
521 'recover-file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
522 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
523 (funcall handler 'recover-file file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
524 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
525 (fn-handler-real-recover-file file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
526
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
527 (efs-overwrite-fn "fn-handler" 'recover-file 'fn-handler-recover-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
528
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
529 (defun fn-handler-file-name-completion (file dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
530 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
531 (let* ((dir (expand-file-name dir))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
532 (handler (find-file-name-handler dir 'file-name-completion)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
533 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
534 (funcall handler 'file-name-completion file dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
535 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
536 (fn-handler-real-file-name-completion file dir)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
537
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
538 (efs-overwrite-fn "fn-handler" 'file-name-completion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
539 'fn-handler-file-name-completion)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
540
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
541 (defun fn-handler-file-name-all-completions (file dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
542 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
543 (let* ((dir (expand-file-name dir))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
544 (handler (find-file-name-handler dir 'file-name-all-completions)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
545 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
546 (funcall handler 'file-name-all-completions file dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
547 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
548 (fn-handler-real-file-name-all-completions file dir)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
549
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
550 (efs-overwrite-fn "fn-handler" 'file-name-all-completions
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
551 'fn-handler-file-name-all-completions)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
552
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
553 (if (fboundp 'file-truename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
554 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
555 (defun fn-handler-file-truename (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
556 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
557 (let* ((fn (expand-file-name filename))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
558 (handler (find-file-name-handler filename 'file-truename)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
559 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
560 (funcall handler 'file-truename filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
561 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
562 (fn-handler-real-file-truename filename)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
563 (efs-overwrite-fn "fn-handler" 'file-truename
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
564 'fn-handler-file-truename)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
565
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
566 (if (fboundp 'unhandled-file-name-directory)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
567 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
568 (defun fn-handler-unhandled-file-name-directory (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
569 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
570 (let ((handler (find-file-name-handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
571 filename 'unhandled-file-name-directory)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
572 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
573 (funcall handler 'unhandled-file-name-directory filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
574 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
575 (fn-handler-real-unhandled-file-name-directory filename)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
576
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
577 (efs-overwrite-fn "fn-handler" 'unhandled-file-name-directory
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
578 'fn-handler-unhandled-file-name-directory)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
579
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
580
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
581 ;; We don't need the file-name-handler-alist for these. Inhibit it to
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
582 ;; avoid an infinite recursion. Hope that this doesn't step
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
583 ;; on any other packages' toes.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
584 (defun fn-handler-expand-file-name (filename &optional default)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
585 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
586 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
587 (fn-handler-real-expand-file-name filename default)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
588
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
589 (efs-overwrite-fn "fn-handler" 'expand-file-name 'fn-handler-expand-file-name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
590
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
591 (defun fn-handler-substitute-in-file-name (filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
592 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
593 (let ((handler (find-file-name-handler filename 'substitute-in-file-name)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
594 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
595 (funcall handler 'substitute-in-file-name filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
596 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
597 (fn-handler-real-substitute-in-file-name filename)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
598
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
599 (efs-overwrite-fn "fn-handler" 'substitute-in-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
600 'fn-handler-substitute-in-file-name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
601
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
602 (if (fboundp 'file-executable-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
603 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
604 (defun fn-handler-file-executable-p (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
605 (let ((handler (find-file-name-handler file 'file-executable-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
606 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
607 (funcall handler 'file-executable-p file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
608 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
609 (fn-handler-real-file-executable-p file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
610 (efs-overwrite-fn "fn-handler" 'file-executable-p
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
611 'fn-handler-file-executable-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
612
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
613 (if (fboundp 'file-accessible-directory-p)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
614 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
615 (defun fn-handler-file-accessible-directory-p (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
616 (let ((handler (find-file-name-handler file
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
617 'file-accessible-directory-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
618 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
619 (funcall handler 'file-accessible-directory-p file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
620 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
621 (fn-handler-real-file-accessible-directory-p file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
622 (efs-overwrite-fn "fn-handler" 'file-accessible-directory-p
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
623 'fn-handler-file-accessible-directory-p)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
624
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
625 (defun fn-handler-load (file &optional noerror nomessage nosuffix)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
626 (let ((handler (find-file-name-handler file 'load)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
627 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
628 (funcall handler 'load file noerror nomessage nosuffix)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
629 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
630 (fn-handler-real-load file noerror nomessage nosuffix)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
631
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
632 (efs-overwrite-fn "fn-handler" 'load 'fn-handler-load)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
633
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
634 ;; We don't need file-name-handlers for do-auto-save.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
635 ;; If it does try to access them there is a risk of an infinite recursion.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
636 (defun fn-handler-do-auto-save (&rest args)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
637 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
638 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
639 (apply 'fn-handler-real-do-auto-save args)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
640
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
641 (efs-overwrite-fn "fn-handler" 'do-auto-save 'fn-handler-do-auto-save)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
642
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
643 (if (fboundp 'vc-registered)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
644 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
645 (defun fn-handler-vc-registered (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
646 "Documented as original."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
647 (let ((handler (find-file-name-handler file 'vc-registered)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
648 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
649 (funcall handler 'vc-registered file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
650 (let (file-name-handler-alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
651 (fn-handler-real-vc-registered file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
652
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
653 (efs-overwrite-fn "fn-handler" 'vc-registered
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
654 'fn-handler-vc-registered)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
655
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
656 ;;; end of fn-handler.el