diff options
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 52 |
2 files changed, 47 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ad1ce6d8bb4..d256a4043db 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2008-04-09 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp.el (tramp-find-file-name-coding-system-alist): New | ||
| 4 | defun. | ||
| 5 | (tramp-handle-insert-file-contents, tramp-handle-write-region): | ||
| 6 | Use it. | ||
| 7 | |||
| 1 | 2008-04-09 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2008-04-09 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * minibuffer.el (minibuffer): Move group from cus-edit.el. | 10 | * minibuffer.el (minibuffer): Move group from cus-edit.el. |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 52060371d12..5f8f126b4be 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3921,6 +3921,21 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 3921 | ((eq identification 'localname) localname) | 3921 | ((eq identification 'localname) localname) |
| 3922 | (t (tramp-make-tramp-file-name method user host ""))))))) | 3922 | (t (tramp-make-tramp-file-name method user host ""))))))) |
| 3923 | 3923 | ||
| 3924 | (defun tramp-find-file-name-coding-system-alist (filename tmpname) | ||
| 3925 | "Like `find-operation-coding-system' for Tramp filenames. | ||
| 3926 | Tramp's `insert-file-contents' and `write-region' work over | ||
| 3927 | temporary file names. If `file-coding-system-alist' contains an | ||
| 3928 | expression, which matches more than the file name suffix, the | ||
| 3929 | coding system might not be determined. This function repairs it." | ||
| 3930 | (let (result) | ||
| 3931 | (dolist (elt file-coding-system-alist result) | ||
| 3932 | (when (and (consp elt) (string-match (car elt) filename)) | ||
| 3933 | ;; We found a matching entry in `file-coding-system-alist'. | ||
| 3934 | ;; So we add a similar entry, but with the temporary file name | ||
| 3935 | ;; as regexp. | ||
| 3936 | (add-to-list | ||
| 3937 | 'result (cons (regexp-quote tmpname) (cdr elt)) 'append))))) | ||
| 3938 | |||
| 3924 | (defun tramp-handle-insert-file-contents | 3939 | (defun tramp-handle-insert-file-contents |
| 3925 | (filename &optional visit beg end replace) | 3940 | (filename &optional visit beg end replace) |
| 3926 | "Like `insert-file-contents' for Tramp files." | 3941 | "Like `insert-file-contents' for Tramp files." |
| @@ -3955,11 +3970,19 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 3955 | 'file-local-copy))) | 3970 | 'file-local-copy))) |
| 3956 | (file-local-copy filename)))) | 3971 | (file-local-copy filename)))) |
| 3957 | (tramp-message v 4 "Inserting local temp file `%s'..." local-copy) | 3972 | (tramp-message v 4 "Inserting local temp file `%s'..." local-copy) |
| 3958 | (setq result (insert-file-contents local-copy nil beg end replace)) | 3973 | ;; We must ensure that `file-coding-system-alist' matches |
| 3959 | ;; Now `last-coding-system-used' has right value. Remember it. | 3974 | ;; `local-copy'. |
| 3960 | (when (boundp 'last-coding-system-used) | 3975 | (let ((file-coding-system-alist |
| 3961 | (setq coding-system-used (symbol-value 'last-coding-system-used))) | 3976 | (tramp-find-file-name-coding-system-alist |
| 3962 | (tramp-message v 4 "Inserting local temp file `%s'...done" local-copy) | 3977 | filename local-copy))) |
| 3978 | (setq result | ||
| 3979 | (insert-file-contents local-copy nil beg end replace)) | ||
| 3980 | ;; Now `last-coding-system-used' has right value. Remember it. | ||
| 3981 | (when (boundp 'last-coding-system-used) | ||
| 3982 | (setq coding-system-used | ||
| 3983 | (symbol-value 'last-coding-system-used)))) | ||
| 3984 | (tramp-message | ||
| 3985 | v 4 "Inserting local temp file `%s'...done" local-copy) | ||
| 3963 | (delete-file local-copy) | 3986 | (delete-file local-copy) |
| 3964 | (when (boundp 'last-coding-system-used) | 3987 | (when (boundp 'last-coding-system-used) |
| 3965 | (set 'last-coding-system-used coding-system-used)))) | 3988 | (set 'last-coding-system-used coding-system-used)))) |
| @@ -4138,13 +4161,18 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 4138 | ;; We say `no-message' here because we don't want the | 4161 | ;; We say `no-message' here because we don't want the |
| 4139 | ;; visited file modtime data to be clobbered from the temp | 4162 | ;; visited file modtime data to be clobbered from the temp |
| 4140 | ;; file. We call `set-visited-file-modtime' ourselves later | 4163 | ;; file. We call `set-visited-file-modtime' ourselves later |
| 4141 | ;; on. | 4164 | ;; on. We must ensure that `file-coding-system-alist' |
| 4142 | (tramp-run-real-handler | 4165 | ;; matches `tmpfile'. |
| 4143 | 'write-region | 4166 | (let ((file-coding-system-alist |
| 4144 | (list start end tmpfile append 'no-message lockname confirm)) | 4167 | (tramp-find-file-name-coding-system-alist filename tmpfile))) |
| 4145 | ;; Now, `last-coding-system-used' has the right value. Remember it. | 4168 | (tramp-run-real-handler |
| 4146 | (when (boundp 'last-coding-system-used) | 4169 | 'write-region |
| 4147 | (setq coding-system-used (symbol-value 'last-coding-system-used))) | 4170 | (list start end tmpfile append 'no-message lockname confirm)) |
| 4171 | ;; Now, `last-coding-system-used' has the right value. Remember it. | ||
| 4172 | (when (boundp 'last-coding-system-used) | ||
| 4173 | (setq coding-system-used | ||
| 4174 | (symbol-value 'last-coding-system-used)))) | ||
| 4175 | |||
| 4148 | ;; The permissions of the temporary file should be set. If | 4176 | ;; The permissions of the temporary file should be set. If |
| 4149 | ;; filename does not exist (eq modes nil) it has been | 4177 | ;; filename does not exist (eq modes nil) it has been |
| 4150 | ;; renamed to the backup file. This case `save-buffer' | 4178 | ;; renamed to the backup file. This case `save-buffer' |