Fix Bug#24947 (Tramp + ido)

* lisp/ido.el (ido-read-internal): Prevent eager Tramp connection.

* lisp/net/tramp.el (tramp-handle-file-name-case-insensitive-p):
Run remote tests only if a connection is established only.  (Bug#24947)
This commit is contained in:
Michael Albinus 2016-11-17 12:38:58 +01:00
parent cf897a70b7
commit 6653bb45d3
2 changed files with 34 additions and 29 deletions

View file

@ -1882,6 +1882,7 @@ If INITIAL is non-nil, it specifies the initial input string."
ido-selected ido-selected
ido-final-text ido-final-text
(done nil) (done nil)
(non-essential t) ;; prevent eager Tramp connection
(icomplete-mode nil) ;; prevent icomplete starting up (icomplete-mode nil) ;; prevent icomplete starting up
;; Exported dynamic variables: ;; Exported dynamic variables:
ido-cur-list ido-cur-list

View file

@ -2905,35 +2905,39 @@ User is always nil."
(or ;; Maybe there is a default value. (or ;; Maybe there is a default value.
(tramp-get-method-parameter v 'tramp-case-insensitive) (tramp-get-method-parameter v 'tramp-case-insensitive)
;; There isn't. So we must check. ;; There isn't. So we must check, in case there's a connection already.
(with-tramp-connection-property v "case-insensitive" (and (tramp-connectable-p filename)
;; The idea is to compare a file with lower case letters with (with-tramp-connection-property v "case-insensitive"
;; the same file with upper case letters. ;; The idea is to compare a file with lower case letters
(let ((candidate (directory-file-name filename)) ;; with the same file with upper case letters.
tmpfile) (let ((candidate (directory-file-name filename))
;; Check, whether we find an existing file with lower case tmpfile)
;; letters. This avoids us to create a temporary file. ;; Check, whether we find an existing file with lower case
(while (and (string-match "[a-z]" (file-remote-p candidate 'localname)) ;; letters. This avoids us to create a temporary file.
(not (file-exists-p candidate))) (while (and (string-match
(setq candidate "[a-z]" (file-remote-p candidate 'localname))
(directory-file-name (file-name-directory candidate)))) (not (file-exists-p candidate)))
;; Nothing found, so we must use a temporary file for (setq candidate
;; comparision. `make-nearby-temp-file' is added to Emacs (directory-file-name (file-name-directory candidate))))
;; 26+ like `file-name-case-insensitive-p', so there is no ;; Nothing found, so we must use a temporary file for
;; compatibility problem calling it. ;; comparision. `make-nearby-temp-file' is added to
(unless (string-match "[a-z]" (file-remote-p candidate 'localname)) ;; Emacs 26+ like `file-name-case-insensitive-p', so
(setq tmpfile ;; there is no compatibility problem calling it.
(let ((default-directory (file-name-directory filename))) (unless
(tramp-compat-funcall 'make-nearby-temp-file "tramp.")) (string-match "[a-z]" (file-remote-p candidate 'localname))
candidate tmpfile)) (setq tmpfile
;; Check for the existence of the same file with upper case letters. (let ((default-directory (file-name-directory filename)))
(unwind-protect (tramp-compat-funcall 'make-nearby-temp-file "tramp."))
(file-exists-p candidate tmpfile))
(concat ;; Check for the existence of the same file with upper
(file-remote-p candidate) ;; case letters.
(upcase (file-remote-p candidate 'localname)))) (unwind-protect
;; Cleanup. (file-exists-p
(when tmpfile (delete-file tmpfile)))))))) (concat
(file-remote-p candidate)
(upcase (file-remote-p candidate 'localname))))
;; Cleanup.
(when tmpfile (delete-file tmpfile)))))))))
(defun tramp-handle-file-name-completion (defun tramp-handle-file-name-completion
(filename directory &optional predicate) (filename directory &optional predicate)