]> code.delx.au - gnu-emacs/commitdiff
Fix OS X specific settings in tramp-tests
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 31 Mar 2016 09:45:45 +0000 (11:45 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 31 Mar 2016 09:45:45 +0000 (11:45 +0200)
* lisp/net/tramp-sh.el (tramp-maybe-open-connection): Use it.

* lisp/net/tramp.el (tramp-get-local-locale): New defun.

* test/automated/tramp-tests.el (tramp--test-darwin-p): Remove.
(tramp--test-utf8): Improve settings of coding systems.
Do not use `tramp--test-darwin-p' anymore.  (Bug#22145)

lisp/net/tramp-sh.el
lisp/net/tramp.el
test/automated/tramp-tests.el

index 9fa46109a5a1c852fa8436db83648ab8114fcd12..5b9083203b572a73bcc40a3ccf646e0175af9976 100644 (file)
@@ -2865,7 +2865,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
          (narrow-to-region (point) (point))
          ;; We cannot use `insert-buffer-substring' because the Tramp
          ;; buffer changes its contents before insertion due to calling
-         ;; `expand-file' and alike.
+         ;; `expand-file-name' and alike.
          (insert
           (with-current-buffer (tramp-get-buffer v)
             (buffer-string)))
@@ -4865,7 +4865,7 @@ connection if a previous connection has died for some reason."
              (when (and p (processp p))
                (delete-process p))
              (setenv "TERM" tramp-terminal-type)
-             (setenv "LC_ALL" "en_US.utf8")
+             (setenv "LC_ALL" (tramp-get-local-locale vec))
              (if (stringp tramp-histfile-override)
                  (setenv "HISTFILE" tramp-histfile-override)
                (if tramp-histfile-override
index 43962169d5a6b8c56f7cc32f7c022292cd081e26..19dced6c2f32a4a81a6e1119c89467f2306b9f7a 100644 (file)
@@ -3939,6 +3939,26 @@ This is used internally by `tramp-file-mode-from-int'."
       (tramp-compat-funcall 'group-gid)
     (nth 3 (tramp-compat-file-attributes "~/" id-format))))
 
+(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.
index d9563ec91745f78febf42c41af3a7c4617199a7e..a12ee387576c4d70c7a4a7216051352dcbc8e9b5 100644 (file)
@@ -1785,14 +1785,6 @@ Several special characters do not work properly there."
       (file-truename tramp-test-temporary-file-directory) nil
     (string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
 
-(defun tramp--test-darwin-p ()
-  "Check, whether the remote host runs Mac OS X.
-Several special characters do not work properly there."
-  ;; We must refill the cache.  `file-truename' does it.
-  (with-parsed-tramp-file-name
-      (file-truename tramp-test-temporary-file-directory) nil
-    (string-match "^Darwin" (tramp-get-connection-property v "uname" ""))))
-
 (defun tramp--test-check-files (&rest files)
   "Run a simple but comprehensive test over every file in FILES."
   ;; We must use `file-truename' for the temporary directory, because
@@ -2041,15 +2033,17 @@ Use the `ls' command."
 
 (defun tramp--test-utf8 ()
   "Perform the test in `tramp-test32-utf8*'."
-  (let ((coding-system-for-read 'utf-8)
-       (coding-system-for-write 'utf-8)
-       (file-name-coding-system 'utf-8))
+  (let* ((utf8 (if (and (eq system-type 'darwin)
+                       (memq 'utf-8-hfs (coding-system-list)))
+                  'utf-8-hfs 'utf-8))
+        (coding-system-for-read utf8)
+        (coding-system-for-write utf8)
+        (file-name-coding-system utf8))
     (tramp--test-check-files
      (unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
-     (unless (or (tramp--test-hpux-p) (tramp--test-darwin-p))
+     (unless (tramp--test-hpux-p)
        "أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت")
-     (unless (tramp--test-darwin-p)
-       "银河系漫游指南系列")
+     "银河系漫游指南系列"
      "Автостопом по гала́ктике")))
 
 (ert-deftest tramp-test32-utf8 ()