diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 740cb23ebe..9393cfe589 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1469,21 +1469,22 @@ tramp-file-name-equal-p (equal (tramp-file-name-unify vec1) (tramp-file-name-unify vec2)))) -(defun tramp-get-method-parameter (vec param) +(defun tramp-get-method-parameter (vec param &optional default) "Return the method parameter PARAM. If VEC is a vector, check first in connection properties. Afterwards, check in `tramp-methods'. If the `tramp-methods' -entry does not exist, return nil." +entry does not exist, return DEFAULT." (let ((hash-entry (replace-regexp-in-string "^tramp-" "" (symbol-name param)))) (if (tramp-connection-property-p vec hash-entry) ;; We use the cached property. - (tramp-get-connection-property vec hash-entry nil) + (tramp-get-connection-property vec hash-entry default) ;; Use the static value from `tramp-methods'. - (when-let ((methods-entry - (assoc - param (assoc (tramp-file-name-method vec) tramp-methods)))) - (cadr methods-entry))))) + (if-let ((methods-entry + (assoc + param (assoc (tramp-file-name-method vec) tramp-methods)))) + (cadr methods-entry) + default)))) ;; The localname can be quoted with "/:". Extract this. (defun tramp-file-name-unquote-localname (vec) @@ -3482,51 +3483,57 @@ tramp-handle-file-name-case-insensitive-p ;; tests will be added in case they are needed. (setq filename (expand-file-name filename)) (with-parsed-tramp-file-name filename nil - (or ;; Maybe there is a default value. - (tramp-get-method-parameter v 'tramp-case-insensitive) - - ;; There isn't. So we must check, in case there's a connection already. - (and (file-remote-p filename nil 'connected) - (with-tramp-connection-property v "case-insensitive" - (ignore-errors - (with-tramp-progress-reporter v 5 "Checking case-insensitive" - ;; The idea is to compare a file with lower case - ;; letters with the same file with upper case letters. - (let ((candidate - (tramp-compat-file-name-unquote - (directory-file-name filename))) - case-fold-search - tmpfile) - ;; Check, whether we find an existing file with - ;; lower case letters. This avoids us to create a - ;; temporary file. - (while (and (string-match-p - "[[:lower:]]" (tramp-file-local-name candidate)) - (not (file-exists-p candidate))) - (setq candidate - (directory-file-name - (file-name-directory candidate)))) - ;; Nothing found, so we must use a temporary file - ;; for comparison. `make-nearby-temp-file' is added - ;; to Emacs 26+ like `file-name-case-insensitive-p', - ;; so there is no compatibility problem calling it. - (unless (string-match-p - "[[:lower:]]" (tramp-file-local-name candidate)) - (setq tmpfile - (let ((default-directory - (file-name-directory filename))) - (tramp-compat-funcall - 'make-nearby-temp-file "tramp.")) - candidate tmpfile)) - ;; Check for the existence of the same file with - ;; upper case letters. - (unwind-protect - (file-exists-p - (concat - (file-remote-p candidate) - (upcase (tramp-file-local-name candidate)))) - ;; Cleanup. - (when tmpfile (delete-file tmpfile))))))))))) + (let ((case-insensitive + (tramp-get-method-parameter v 'tramp-case-insensitive 'unset))) + (if (not (eq case-insensitive 'unset)) + ;; Maybe there is a default value. + case-insensitive + ;; There isn't. So we must check, in case there's a + ;; connection already. + (and (file-remote-p filename nil 'connected) + (with-tramp-connection-property v "case-insensitive" + (ignore-errors + (with-tramp-progress-reporter v 5 "Checking case-insensitive" + ;; The idea is to compare a file with lower case + ;; letters with the same file with upper case + ;; letters. + (let ((candidate + (tramp-compat-file-name-unquote + (directory-file-name filename))) + case-fold-search + tmpfile) + ;; Check, whether we find an existing file with + ;; lower case letters. This avoids us to create + ;; a temporary file. + (while (and (string-match-p + "[[:lower:]]" + (tramp-file-local-name candidate)) + (not (file-exists-p candidate))) + (setq candidate + (directory-file-name + (file-name-directory candidate)))) + ;; Nothing found, so we must use a temporary file + ;; for comparison. `make-nearby-temp-file' is + ;; added to Emacs 26+ like + ;; `file-name-case-insensitive-p', so there is no + ;; compatibility problem calling it. + (unless (string-match-p + "[[:lower:]]" (tramp-file-local-name candidate)) + (setq tmpfile + (let ((default-directory + (file-name-directory filename))) + (tramp-compat-funcall + 'make-nearby-temp-file "tramp.")) + candidate tmpfile)) + ;; Check for the existence of the same file with + ;; upper case letters. + (unwind-protect + (file-exists-p + (concat + (file-remote-p candidate) + (upcase (tramp-file-local-name candidate)))) + ;; Cleanup. + (when tmpfile (delete-file tmpfile)))))))))))) (defun tramp-handle-file-name-completion (filename directory &optional predicate)