GNU bug report logs -
#33567
Syntactic fontification of diff hunks
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Sat, 1 Dec 2018 22:13:02 UTC
Severity: wishlist
Tags: patch
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> . it doesn't use the following facilities for determining the right
> encoding, where you use buffer-file-coding-system:
> - auto-coding-function, which is where we detect the 'coding:'
> cookies in the first line and in the local vars, and use the
> data in auto-coding-alist and auto-coding-regexp-alist, and also
> call auto-coding-functions if needed
> - find-operation-coding-system by file name, which uses the data
> in file-coding-system-alist to determine the appropriate
> encoding given the file's name
>
> The hard problem here is to determine what coding-system to use for
> decoding a region that was inserted without any conversions; once the
> encoding is determined, the rest boils down to calling
> decode-coding-region with that encoding. The method used by
> archive-set-buffer-as-visiting-file solves that very problem, whereas
> recode-region does not, because it is a command that relies on the
> caller to specify the encoding, and is otherwise nothing more than a
> thin wrapper around decode-coding-region.
Thanks for the explanation. I explored more on this subject, and found
the most suitable existing function: `decode-coding-inserted-region'.
I tested it with different codings and everything works well:
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 5ff9f4d5be..127661a039 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2042,6 +2042,8 @@ vc-find-revision-no-save
(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 (let ((buffer-file-name file)) (normal-mode)) (normal-mode))
(set-buffer-modified-p nil)
This bug report was last modified 6 years and 146 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.