mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-05 19:59:38 +00:00
Handle last-coding-system-used in Tramp for all backends
* lisp/net/tramp.el (tramp-skeleton-write-region): Handle `last-coding-system-used'. (tramp-handle-write-region): * lisp/net/tramp-adb.el (tramp-adb-handle-write-region): * lisp/net/tramp-smb.el (tramp-smb-handle-write-region): * lisp/net/tramp-sshfs.el (tramp-sshfs-handle-write-region): Set `coding-system-used'. (Bug#65022) * lisp/net/tramp-sh.el (tramp-sh-handle-write-region): Move `last-coding-system-used' handling to `tramp-skeleton-write-region'.
This commit is contained in:
parent
ffafe38d03
commit
c42970d775
5 changed files with 37 additions and 32 deletions
|
@ -552,6 +552,8 @@ Emacs dired can't find files."
|
||||||
(set-file-modes tmpfile (logior (or (file-modes tmpfile) 0) #o0600)))
|
(set-file-modes tmpfile (logior (or (file-modes tmpfile) 0) #o0600)))
|
||||||
(let (create-lockfiles)
|
(let (create-lockfiles)
|
||||||
(write-region start end tmpfile append 'no-message))
|
(write-region start end tmpfile append 'no-message))
|
||||||
|
;; Now, `last-coding-system-used' has the right value. Remember it.
|
||||||
|
(setq coding-system-used last-coding-system-used)
|
||||||
(with-tramp-progress-reporter
|
(with-tramp-progress-reporter
|
||||||
v 3 (format-message
|
v 3 (format-message
|
||||||
"Moving tmp file `%s' to `%s'" tmpfile filename)
|
"Moving tmp file `%s' to `%s'" tmpfile filename)
|
||||||
|
|
|
@ -3446,15 +3446,6 @@ implementation will be used."
|
||||||
|
|
||||||
(let* ((modes (tramp-default-file-modes
|
(let* ((modes (tramp-default-file-modes
|
||||||
filename (and (eq mustbenew 'excl) 'nofollow)))
|
filename (and (eq mustbenew 'excl) 'nofollow)))
|
||||||
;; We use this to save the value of
|
|
||||||
;; `last-coding-system-used' after writing the tmp
|
|
||||||
;; file. At the end of the function, we set
|
|
||||||
;; `last-coding-system-used' to this saved value. This
|
|
||||||
;; way, any intermediary coding systems used while
|
|
||||||
;; talking to the remote shell or suchlike won't hose
|
|
||||||
;; this variable. This approach was snarfed from
|
|
||||||
;; ange-ftp.el.
|
|
||||||
coding-system-used
|
|
||||||
;; Write region into a tmp file. This isn't really
|
;; Write region into a tmp file. This isn't really
|
||||||
;; needed if we use an encoding function, but currently
|
;; needed if we use an encoding function, but currently
|
||||||
;; we use it always because this makes the logic
|
;; we use it always because this makes the logic
|
||||||
|
@ -3484,11 +3475,11 @@ implementation will be used."
|
||||||
((error quit)
|
((error quit)
|
||||||
(setq tramp-temp-buffer-file-name nil)
|
(setq tramp-temp-buffer-file-name nil)
|
||||||
(delete-file tmpfile)
|
(delete-file tmpfile)
|
||||||
(signal (car err) (cdr err))))
|
(signal (car err) (cdr err)))))
|
||||||
|
|
||||||
;; Now, `last-coding-system-used' has the right value.
|
;; Now, `last-coding-system-used' has the right value.
|
||||||
;; Remember it.
|
;; Remember it.
|
||||||
(setq coding-system-used last-coding-system-used))
|
(setq coding-system-used last-coding-system-used)
|
||||||
|
|
||||||
;; The permissions of the temporary file should be set. If
|
;; The permissions of the temporary file should be set. If
|
||||||
;; FILENAME does not exist (eq modes nil) it has been
|
;; FILENAME does not exist (eq modes nil) it has been
|
||||||
|
@ -3618,11 +3609,7 @@ implementation will be used."
|
||||||
v 'file-error
|
v 'file-error
|
||||||
(concat "Method `%s' should specify both encoding and "
|
(concat "Method `%s' should specify both encoding and "
|
||||||
"decoding command or an scp program")
|
"decoding command or an scp program")
|
||||||
method))))
|
method)))))))))
|
||||||
|
|
||||||
;; Make `last-coding-system-used' have the right value.
|
|
||||||
(when coding-system-used
|
|
||||||
(setq last-coding-system-used coding-system-used)))))))
|
|
||||||
|
|
||||||
(defvar tramp-vc-registered-file-names nil
|
(defvar tramp-vc-registered-file-names nil
|
||||||
"List used to collect file names, which are checked during `vc-registered'.")
|
"List used to collect file names, which are checked during `vc-registered'.")
|
||||||
|
|
|
@ -1628,6 +1628,8 @@ VEC or USER, or if there is no home directory, return nil."
|
||||||
;; `set-visited-file-modtime' ourselves later on.
|
;; `set-visited-file-modtime' ourselves later on.
|
||||||
(let (create-lockfiles)
|
(let (create-lockfiles)
|
||||||
(write-region start end tmpfile append 'no-message))
|
(write-region start end tmpfile append 'no-message))
|
||||||
|
;; Now, `last-coding-system-used' has the right value. Remember it.
|
||||||
|
(setq coding-system-used last-coding-system-used)
|
||||||
|
|
||||||
(with-tramp-progress-reporter
|
(with-tramp-progress-reporter
|
||||||
v 3 (format "Moving tmp file %s to %s" tmpfile filename)
|
v 3 (format "Moving tmp file %s to %s" tmpfile filename)
|
||||||
|
|
|
@ -379,7 +379,9 @@ arguments to pass to the OPERATION."
|
||||||
(tramp-skeleton-write-region start end filename append visit lockname mustbenew
|
(tramp-skeleton-write-region start end filename append visit lockname mustbenew
|
||||||
(let (create-lockfiles)
|
(let (create-lockfiles)
|
||||||
(write-region
|
(write-region
|
||||||
start end (tramp-fuse-local-file-name filename) append 'nomessage))))
|
start end (tramp-fuse-local-file-name filename) append 'nomessage))
|
||||||
|
;; Now, `last-coding-system-used' has the right value. Remember it.
|
||||||
|
(setq coding-system-used last-coding-system-used)))
|
||||||
|
|
||||||
|
|
||||||
;; File name conversions.
|
;; File name conversions.
|
||||||
|
|
|
@ -3726,7 +3726,15 @@ BODY is the backend specific code."
|
||||||
tramp-crypt-file-name-handler
|
tramp-crypt-file-name-handler
|
||||||
. inhibit-file-name-handlers))
|
. inhibit-file-name-handlers))
|
||||||
(inhibit-file-name-operation 'write-region))
|
(inhibit-file-name-operation 'write-region))
|
||||||
(find-file-name-handler ,visit 'write-region)))))
|
(find-file-name-handler ,visit 'write-region))))
|
||||||
|
;; We use this to save the value of
|
||||||
|
;; `last-coding-system-used' after writing the tmp file. At
|
||||||
|
;; the end of the function, we set `last-coding-system-used'
|
||||||
|
;; to this saved value. This way, any intermediary coding
|
||||||
|
;; systems used while talking to the remote shell or
|
||||||
|
;; suchlike won't hose this variable. This approach was
|
||||||
|
;; snarfed from ange-ftp.el.
|
||||||
|
coding-system-used)
|
||||||
(with-parsed-tramp-file-name filename nil
|
(with-parsed-tramp-file-name filename nil
|
||||||
(if handler
|
(if handler
|
||||||
(progn
|
(progn
|
||||||
|
@ -3773,9 +3781,7 @@ BODY is the backend specific code."
|
||||||
;; likely that it is needed shortly after `write-region'.
|
;; likely that it is needed shortly after `write-region'.
|
||||||
(tramp-set-file-property v localname "file-exists-p" t)
|
(tramp-set-file-property v localname "file-exists-p" t)
|
||||||
|
|
||||||
;; We must protect `last-coding-system-used', now we have
|
(let ((need-chown t))
|
||||||
;; set it to its correct value.
|
|
||||||
(let (last-coding-system-used (need-chown t))
|
|
||||||
;; Set file modification time.
|
;; Set file modification time.
|
||||||
(when (or (eq ,visit t) (stringp ,visit))
|
(when (or (eq ,visit t) (stringp ,visit))
|
||||||
(when-let ((file-attr (file-attributes filename 'integer)))
|
(when-let ((file-attr (file-attributes filename 'integer)))
|
||||||
|
@ -3794,7 +3800,7 @@ BODY is the backend specific code."
|
||||||
(tramp-set-file-uid-gid filename uid gid))
|
(tramp-set-file-uid-gid filename uid gid))
|
||||||
|
|
||||||
;; Set extended attributes. We ignore possible errors,
|
;; Set extended attributes. We ignore possible errors,
|
||||||
;; because ACL strings could be incompatible.
|
;; because ACL strings or SELinux contexts could be incompatible.
|
||||||
(when attributes
|
(when attributes
|
||||||
(ignore-errors
|
(ignore-errors
|
||||||
(set-file-extended-attributes filename attributes)))
|
(set-file-extended-attributes filename attributes)))
|
||||||
|
@ -3813,7 +3819,11 @@ BODY is the backend specific code."
|
||||||
(when (and (null noninteractive)
|
(when (and (null noninteractive)
|
||||||
(or (eq ,visit t) (string-or-null-p ,visit)))
|
(or (eq ,visit t) (string-or-null-p ,visit)))
|
||||||
(tramp-message v 0 "Wrote %s" filename))
|
(tramp-message v 0 "Wrote %s" filename))
|
||||||
(run-hooks 'tramp-handle-write-region-hook)))))))
|
(run-hooks 'tramp-handle-write-region-hook))))
|
||||||
|
|
||||||
|
;; Make `last-coding-system-used' have the right value.
|
||||||
|
(when coding-system-used
|
||||||
|
(setq last-coding-system-used coding-system-used)))))
|
||||||
|
|
||||||
;;; Common file name handler functions for different backends:
|
;;; Common file name handler functions for different backends:
|
||||||
|
|
||||||
|
@ -5420,6 +5430,8 @@ of."
|
||||||
;; `set-visited-file-modtime' ourselves later on.
|
;; `set-visited-file-modtime' ourselves later on.
|
||||||
(let (create-lockfiles)
|
(let (create-lockfiles)
|
||||||
(write-region start end tmpfile append 'no-message))
|
(write-region start end tmpfile append 'no-message))
|
||||||
|
;; Now, `last-coding-system-used' has the right value. Remember it.
|
||||||
|
(setq coding-system-used last-coding-system-used)
|
||||||
(condition-case nil
|
(condition-case nil
|
||||||
(rename-file tmpfile filename 'ok-if-already-exists)
|
(rename-file tmpfile filename 'ok-if-already-exists)
|
||||||
(error
|
(error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue