From: Juri Linkov Date: Wed, 12 Dec 2018 23:17:05 +0000 (+0200) Subject: * lisp/vc/vc.el (vc-find-revision-no-save): Use decode-coding-inserted-region X-Git-Tag: emacs-27.0.90~4000^2~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fcccd52ab086f94fe56900cf15fbdc0ea11b428b;p=emacs.git * lisp/vc/vc.el (vc-find-revision-no-save): Use decode-coding-inserted-region and after-insert-file-set-coding. Don't let-bind coding-system-for-read and coding-system-for-write. For non-interactive use, let-bind enable-local-variables to :safe and ignore errors from set-auto-mode call. (Bug#33567) --- diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 5ff9f4d5be6..48b7c98dfac 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2033,20 +2033,25 @@ Unlike `vc-find-revision-save', doesn't save the buffer to the file." (with-current-buffer filebuf (let ((failed t)) (unwind-protect - (let ((coding-system-for-read 'no-conversion) - (coding-system-for-write 'no-conversion)) - (with-current-buffer (or buffer (create-file-buffer filename)) - (unless buffer (setq buffer-file-name filename)) - (let ((outbuf (current-buffer))) - (with-current-buffer filebuf - (if backend - (vc-call-backend backend 'find-revision file revision outbuf) - (vc-call find-revision file revision outbuf)))) - (goto-char (point-min)) - (if buffer (let ((buffer-file-name file)) (normal-mode)) (normal-mode)) - (set-buffer-modified-p nil) - (setq buffer-read-only t)) - (setq failed nil)) + (with-current-buffer (or buffer (create-file-buffer filename)) + (unless buffer (setq buffer-file-name filename)) + (let ((outbuf (current-buffer))) + (with-current-buffer filebuf + (if backend + (vc-call-backend backend 'find-revision file revision outbuf) + (vc-call find-revision file revision outbuf)))) + (decode-coding-inserted-region (point-min) (point-max) file) + (after-insert-file-set-coding (- (point-max) (point-min))) + (goto-char (point-min)) + (if buffer + ;; For non-interactive, skip any questions + (let ((enable-local-variables :safe) ;; to find `mode:' + (buffer-file-name file)) + (ignore-errors (set-auto-mode))) + (normal-mode)) + (set-buffer-modified-p nil) + (setq buffer-read-only t)) + (setq failed nil) (when (and failed (unless buffer (get-file-buffer filename))) (with-current-buffer (get-file-buffer filename) (set-buffer-modified-p nil))