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: Andrea Cardaci
Subject: Re: Detecting the coding system of a file programmatically
Date: Fri, 17 Aug 2018 13:33:54 +0200

HI Juri,

But in this way the extra operations executed by
`insert-file-contents' are performed anyway, albeit on a smaller
portion of the buffer. I'm not sure if the slow part (decoding
excluded) is proportional to the size of the input file.

I'll keep that in mind as an alternative solution, thanks.

I ended up using:

(with-temp-buffer
  (insert-file-contents-literally path)
  (decode-coding-region (point-min) (point-max) 'undecided)
  (... do suff with the buffer ...))

But take a look at the gotchas mentioned by Eli.
On Thu, 16 Aug 2018 at 23:40, Juri Linkov <address@hidden> wrote:
>
> > I use `insert-file-contents-literally' because the non-literally
> > counterpart is too slow (about twice as much apparently) as it does a
> > bunch of stuff in addition to simply populate the buffer.
> > Unfortunately, one of these things is to decode the buffer.
>
> For better performance I restrict the size of inserted file by giving to
> `insert-file-contents' a small value of args BEG and END.  For example,
> to automatically detect encodings of files for diff I use such customization:
>



reply via email to

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