[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 7032e03: Fix Bug#22145
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master 7032e03: Fix Bug#22145 |
Date: |
Sun, 03 Apr 2016 08:15:04 +0000 |
branch: master
commit 7032e03d60a0e3a6e1466d8c55baa00c4bfc5fea
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
Fix Bug#22145
* lisp/net/tramp-cache.el (tramp-get-connection-property)
(tramp-set-connection-property, tramp-connection-property-p)
(tramp-flush-connection-property): Improve docstring.
* 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-utf8):
Improve settings of coding systems. (Bug#22145)
---
lisp/net/tramp-cache.el | 20 ++++++++++++++------
lisp/net/tramp-sh.el | 2 +-
lisp/net/tramp.el | 20 ++++++++++++++++++++
test/lisp/net/tramp-tests.el | 9 ++++++---
4 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 92f66f4..158cfb5 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -223,8 +223,10 @@ This is suppressed for temporary buffers."
;;;###tramp-autoload
(defun tramp-get-connection-property (key property default)
"Get the named PROPERTY for the connection.
-KEY identifies the connection, it is either a process or a vector.
-If the value is not set for the connection, returns DEFAULT."
+KEY identifies the connection, it is either a process or a
+vector. A special case is nil, which is used to cache connection
+properties of the local machine. If the value is not set for the
+connection, returns DEFAULT."
;; Unify key by removing localname and hop from vector. Work with a
;; copy in order to avoid side effects.
(when (vectorp key)
@@ -241,8 +243,10 @@ If the value is not set for the connection, returns
DEFAULT."
;;;###tramp-autoload
(defun tramp-set-connection-property (key property value)
"Set the named PROPERTY of a connection to VALUE.
-KEY identifies the connection, it is either a process or a vector.
-PROPERTY is set persistent when KEY is a vector."
+KEY identifies the connection, it is either a process or a
+vector. A special case is nil, which is used to cache connection
+properties of the local machine. PROPERTY is set persistent when
+KEY is a vector."
;; Unify key by removing localname and hop from vector. Work with a
;; copy in order to avoid side effects.
(when (vectorp key)
@@ -258,13 +262,17 @@ PROPERTY is set persistent when KEY is a vector."
;;;###tramp-autoload
(defun tramp-connection-property-p (key property)
"Check whether named PROPERTY of a connection is defined.
-KEY identifies the connection, it is either a process or a vector."
+KEY identifies the connection, it is either a process or a
+vector. A special case is nil, which is used to cache connection
+properties of the local machine."
(not (eq (tramp-get-connection-property key property 'undef) 'undef)))
;;;###tramp-autoload
(defun tramp-flush-connection-property (key)
"Remove all properties identified by KEY.
-KEY identifies the connection, it is either a process or a vector."
+KEY identifies the connection, it is either a process or a
+vector. A special case is nil, which is used to cache connection
+properties of the local machine."
;; Unify key by removing localname and hop from vector. Work with a
;; copy in order to avoid side effects.
(when (vectorp key)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 7260107..dbaa73f 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -4773,7 +4773,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
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 3b8510e..f03ec55 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3747,6 +3747,26 @@ This is used internally by `tramp-file-mode-from-int'."
(tramp-compat-funcall 'group-gid)
(nth 3 (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.
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index a29e42e..a12ee38 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2033,9 +2033,12 @@ 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 (tramp--test-hpux-p)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 7032e03: Fix Bug#22145,
Michael Albinus <=