]> code.delx.au - gnu-emacs/blobdiff - lisp/net/tramp.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / net / tramp.el
index e101c42a494fd77140c846e821050b010ff3e474..3da60e93b784766241055b323d1690e403e1d1a8 100644 (file)
@@ -1944,7 +1944,8 @@ ARGS are the arguments OPERATION has been called with."
    ;; Unknown file primitive.
    (t (error "unknown file I/O primitive: %s" operation))))
 
-(defun tramp-find-foreign-file-name-handler (filename)
+(defun tramp-find-foreign-file-name-handler
+    (filename &optional operation completion)
   "Return foreign file name handler if exists."
   (when (tramp-tramp-file-p filename)
     (let ((v (tramp-dissect-file-name filename t))
@@ -1952,11 +1953,17 @@ ARGS are the arguments OPERATION has been called with."
          elt res)
       ;; When we are not fully sure that filename completion is safe,
       ;; we should not return a handler.
-      (when (or (tramp-file-name-method v) (tramp-file-name-user v)
+      (when (or (not completion)
+               (tramp-file-name-method v) (tramp-file-name-user v)
                (and (tramp-file-name-host v)
                     (not (member (tramp-file-name-host v)
                                  (mapcar 'car tramp-methods))))
-               (not (tramp-completion-mode-p)))
+               ;; Some operations are safe by default.
+               (member
+                operation
+                '(file-name-as-directory
+                  file-name-directory
+                  file-name-nondirectory)))
        (while handler
          (setq elt (car handler)
                handler (cdr handler))
@@ -1984,7 +1991,9 @@ Falls back to normal file name handler if no Tramp file name handler exists."
                (tramp-replace-environment-variables
                 (apply 'tramp-file-name-for-operation operation args)))
               (completion (tramp-completion-mode-p))
-              (foreign (tramp-find-foreign-file-name-handler filename))
+              (foreign
+               (tramp-find-foreign-file-name-handler
+                filename operation completion))
               result)
          (with-parsed-tramp-file-name filename nil
            ;; Call the backend function.
@@ -3764,26 +3773,6 @@ This is used internally by `tramp-file-mode-from-int'."
       (when vec (tramp-message vec 7 "locale %s" (or locale "C")))
       (or locale "C"))))
 
-(defun tramp-get-local-locale (&optional vec)
-  ;; We use key nil for local connection properties.
-  (with-tramp-connection-property nil "locale"
-    (let ((candidates '("en_US.utf8" "C.utf8" "en_US.UTF-8"))
-         locale)
-      (with-temp-buffer
-       (unless (or (memq system-type '(windows-nt))
-                    (not (zerop (tramp-call-process
-                                 nil "locale" nil t nil "-a"))))
-         (while candidates
-           (goto-char (point-min))
-           (if (string-match (format "^%s\r?$" (regexp-quote (car candidates)))
-                             (buffer-string))
-               (setq locale (car candidates)
-                     candidates nil)
-             (setq candidates (cdr candidates))))))
-      ;; Return value.
-      (when vec (tramp-message vec 7 "locale %s" (or locale "C")))
-      (or locale "C"))))
-
 ;;;###tramp-autoload
 (defun tramp-check-cached-permissions (vec access)
   "Check `file-attributes' caches for VEC.