From: Andrea Cardaci <cyrus.and@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Detecting the coding system of a file programmatically
Date: Fri, 10 Aug 2018 15:37:08 +0200 [thread overview]
Message-ID: <CACMsj9OYwft+WcUP8ez5v+MbS8cAWd2FN=_fmiPR4Z_=01jAzA@mail.gmail.com> (raw)
In-Reply-To: <83ftzmof3s.fsf@gnu.org>
Hi Eli,
Thanks for the thorough reply.
> That's the wrong function to use in this case; you want
> decode-coding-inserted-region instead.
Yes, that works!
> Thus, I expect this to work for you:
>
> (with-temp-buffer
> (insert-file-contents-literally path)
> (decode-coding-region (point-min) (point-max)
> (find-operation-coding-system
> 'insert-file-contents
> (cons path (current-buffer)))))
Yes, except that it accepts a single symbol. I also tried directly with:
(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.
Andrea
next prev parent reply other threads:[~2018-08-10 13:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 1:02 Detecting the coding system of a file programmatically Andrea Cardaci
2018-08-10 7:28 ` Eli Zaretskii
2018-08-10 13:37 ` Andrea Cardaci [this message]
2018-08-10 13:54 ` Eli Zaretskii
2018-08-10 14:47 ` Andrea Cardaci
2018-08-10 15:26 ` Stefan Monnier
2018-08-16 21:27 ` Juri Linkov
2018-08-17 11:33 ` Andrea Cardaci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACMsj9OYwft+WcUP8ez5v+MbS8cAWd2FN=_fmiPR4Z_=01jAzA@mail.gmail.com' \
--to=cyrus.and@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.