emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting the coding system of a file programmatically


From: Eli Zaretskii
Subject: Re: Detecting the coding system of a file programmatically
Date: Fri, 10 Aug 2018 16:54:12 +0300

> From: Andrea Cardaci <address@hidden>
> Date: Fri, 10 Aug 2018 15:37:08 +0200
> Cc: Emacs developers <address@hidden>
> 
> (decode-coding-region (point-min) (point-max) 'undecided)
> 
> which in my use case it resulted in a more snappy performance.
> Basically this latter `decode-coding-region' doesn't introduce a
> noticeable slowing to the `insert-file-contents-literally', instead
> using `decode-coding-inserted-region' is more or less as slow as using
> `insert-file-contents' alone. I guess I'll go with the former.

Suit yourself, but you need to be aware that while speeding up the
code, you lose some features, which may or may not be important, such
as setting the default coding-system based on the file's name.  If
this code ever needs to handle a file whose contents fools the Emacs
guesswork (which is based on a small part of the buffer contents),
your shortcut might misfire.  E.g., UTF-8 encoded files sometimes dupe
Emacs into thinking they are encoded in some Windows codepage, if that
codepage is the default encoding under the user's locale, so
processing XML or LaTeX files might use a wrong encoding.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]