]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/vc.el (vc-find-revision-no-save): Use decode-coding-inserted-region
authorJuri Linkov <juri@linkov.net>
Wed, 12 Dec 2018 23:17:05 +0000 (01:17 +0200)
committerJuri Linkov <juri@linkov.net>
Wed, 12 Dec 2018 23:17:05 +0000 (01:17 +0200)
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)

lisp/vc/vc.el

index 5ff9f4d5be60d3e0a6eb0a02ccc7b506ebf49edd..48b7c98dfac3a91dce5e49d647cb2ec0701ca8f3 100644 (file)
@@ -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))