(defun tramp-vc-file-name-handler (operation &rest args)
"Invoke special file name handler, which collects files to be handled."
(save-match-data
- (let ((filename
- (tramp-replace-environment-variables
- (apply #'tramp-file-name-for-operation operation args)))
- (fn (assoc operation tramp-sh-file-name-handler-alist)))
- (if (tramp-tramp-file-p filename)
- (with-parsed-tramp-file-name filename nil
- (cond
- ;; That's what we want: file names, for which checks are
- ;; applied. We assume that VC uses only `file-exists-p'
- ;; `file-readable-p' and `file-directory-p' checks;
- ;; otherwise we must extend the list. We do not perform
- ;; any action, but return nil, in order to keep
- ;; `vc-registered' running.
- ((and fn (memq operation
- '(file-exists-p file-readable-p file-directory-p)))
- (add-to-list 'tramp-vc-registered-file-names localname 'append)
- nil)
- ;; `process-file' and `start-file-process' shall be ignored.
- ((and fn (eq operation 'process-file) 0))
- ((and fn (eq operation 'start-file-process) nil))
- ;; Tramp file name handlers like `expand-file-name'. They
- ;; must still work.
- (fn (save-match-data (apply (cdr fn) args)))
- ;; Default file name handlers, we don't care.
- (t (tramp-run-real-handler operation args))))
+ (if-let* ((filename
+ (tramp-replace-environment-variables
+ (apply #'tramp-file-name-for-operation operation args)))
+ ((tramp-tramp-file-p filename))
+ (fn (assoc operation tramp-sh-file-name-handler-alist)))
+ (with-parsed-tramp-file-name filename nil
+ (cond
+ ;; That's what we want: file names, for which checks are
+ ;; applied. We assume that VC uses only `file-exists-p',
+ ;; `file-readable-p' and `file-directory-p' checks;
+ ;; otherwise we must extend the list. The respective cache
+ ;; value must be set for these functions in
+ ;; `tramp-bundle-read-file-names'.
+ ;; We do not perform any action, but return nil, in order
+ ;; to keep `vc-registered' running.
+ ((memq operation '(file-exists-p file-readable-p file-directory-p))
+ (add-to-list 'tramp-vc-registered-file-names localname 'append)
+ nil)
+ ;; `process-file' and `start-file-process' shall be ignored.
+ ((eq operation 'process-file) 0)
+ ((eq operation 'start-file-process) nil)
+ ;; Tramp file name handlers like `expand-file-name'. They
+ ;; must still work.
+ (t (save-match-data (apply (cdr fn) args)))))
;; When `tramp-mode' is not enabled, or the file name is not a
;; remote file name, we don't do anything. Same for default