45
45
(require 'timer )
46
46
(require 'ucs-normalize )
47
47
48
+ (declare-function tramp-compat-file-local-name 'tramp-compat )
49
+ (declare-function tramp-compat-file-name-quoted-p 'tramp-compat )
50
+
48
51
; ; For not existing functions, obsolete functions, or functions with a
49
52
; ; changed argument list, there are compiler warnings. We want to
50
53
; ; avoid them in cases we know what we do.
@@ -187,43 +190,45 @@ This is a string of ten letters or dashes as in ls -l."
187
190
188
191
; ; `file-local-name' , `file-name-quoted-p' , `file-name-quote' and
189
192
; ; `file-name-unquote' are introduced in Emacs 26.
190
- (eval-and-compile
191
- (if (fboundp 'file-local-name )
192
- (defalias 'tramp-compat-file-local-name #'file-local-name )
193
- (defsubst tramp-compat-file-local-name (name )
194
- " Return the local name component of NAME.
193
+ (if (fboundp 'file-local-name )
194
+ (defalias 'tramp-compat-file-local-name #'file-local-name )
195
+ (defsubst tramp-compat-file-local-name (name )
196
+ " Return the local name component of NAME.
195
197
It returns a file name which can be used directly as argument of
196
198
`process-file' , `start-file-process' , or `shell-command' ."
197
- (or (file-remote-p name 'localname ) name)))
198
-
199
- (if (fboundp 'file-name-quoted-p )
200
- (defalias 'tramp-compat-file-name-quoted-p #'file-name-quoted-p )
201
- (defsubst tramp-compat-file-name-quoted-p (name &optional top )
202
- " Whether NAME is quoted with prefix \" /:\" .
199
+ (or (file-remote-p name 'localname ) name)))
200
+
201
+ ; ; `file-name-quoted-p' got a second argument in Emacs 27.1.
202
+ (if (and
203
+ (fboundp 'file-name-quoted-p )
204
+ (equal (tramp-compat-funcall 'func-arity #'file-name-quoted-p ) '(1 . 2 )))
205
+ (defalias 'tramp-compat-file-name-quoted-p #'file-name-quoted-p )
206
+ (defsubst tramp-compat-file-name-quoted-p (name &optional top )
207
+ " Whether NAME is quoted with prefix \" /:\" .
203
208
If NAME is a remote file name and TOP is nil, check the local part of NAME."
204
- (let ((file-name-handler-alist (unless top file-name-handler-alist)))
205
- (string-prefix-p " /:" (tramp-compat-file-local-name name)))))
209
+ (let ((file-name-handler-alist (unless top file-name-handler-alist)))
210
+ (string-prefix-p " /:" (tramp-compat-file-local-name name)))))
206
211
207
- (if (fboundp 'file-name-quote )
208
- (defalias 'tramp-compat-file-name-quote #'file-name-quote )
209
- (defsubst tramp-compat-file-name-quote (name )
210
- " Add the quotation prefix \" /:\" to file NAME.
212
+ (if (fboundp 'file-name-quote )
213
+ (defalias 'tramp-compat-file-name-quote #'file-name-quote )
214
+ (defsubst tramp-compat-file-name-quote (name )
215
+ " Add the quotation prefix \" /:\" to file NAME.
211
216
If NAME is a remote file name, the local part of NAME is quoted."
212
- (if (tramp-compat-file-name-quoted-p name)
213
- name
214
- (concat
215
- (file-remote-p name) " /:" (tramp-compat-file-local-name name)))))
216
-
217
- (if (fboundp 'file-name-unquote )
218
- (defalias 'tramp-compat-file-name-unquote #'file-name-unquote )
219
- (defsubst tramp-compat-file-name-unquote (name )
220
- " Remove quotation prefix \" /:\" from file NAME.
217
+ (if (tramp-compat-file-name-quoted-p name)
218
+ name
219
+ (concat
220
+ (file-remote-p name) " /:" (tramp-compat-file-local-name name)))))
221
+
222
+ (if (fboundp 'file-name-unquote )
223
+ (defalias 'tramp-compat-file-name-unquote #'file-name-unquote )
224
+ (defsubst tramp-compat-file-name-unquote (name )
225
+ " Remove quotation prefix \" /:\" from file NAME.
221
226
If NAME is a remote file name, the local part of NAME is unquoted."
222
- (let ((localname (tramp-compat-file-local-name name)))
223
- (when (tramp-compat-file-name-quoted-p localname)
224
- (setq
225
- localname (if (= (length localname) 2 ) " /" (substring localname 2 ))))
226
- (concat (file-remote-p name) localname) ))))
227
+ (let ((localname (tramp-compat-file-local-name name)))
228
+ (when (tramp-compat-file-name-quoted-p localname)
229
+ (setq
230
+ localname (if (= (length localname) 2 ) " /" (substring localname 2 ))))
231
+ (concat (file-remote-p name) localname))))
227
232
228
233
; ; `tramp-syntax' has changed its meaning in Emacs 26. We still
229
234
; ; support old settings.
@@ -241,7 +246,7 @@ If NAME is a remote file name, the local part of NAME is unquoted."
241
246
'(cdr (mapcar #'car (get 'tramp-file-name 'cl-struct-slots )))))
242
247
243
248
; ; The signature of `tramp-make-tramp-file-name' has been changed.
244
- ; ; Therefore, we cannot us `url-tramp-convert-url-to-tramp' prior
249
+ ; ; Therefore, we cannot use `url-tramp-convert-url-to-tramp' prior
245
250
; ; Emacs 26.1. We use `temporary-file-directory' as indicator.
246
251
(defconst tramp-compat-use-url-tramp-p (fboundp 'temporary-file-directory )
247
252
" Whether to use url-tramp.el." )
0 commit comments