From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: help-gnu-emacs@gnu.org
Subject: Re: How to determine encoding for file?
Date: Tue, 26 Jan 2010 10:01:49 +0100 [thread overview]
Message-ID: <87ockhutmq.fsf@ambire.localdomain> (raw)
In-Reply-To: <hjkbca$nv9$1@reader1.panix.com> (kj's message of "Mon, 25 Jan 2010 14:55:06 +0000 (UTC)")
() kj <no.email@please.post>
() Mon, 25 Jan 2010 14:55:06 +0000 (UTC)
Dumb but effective.
Out of curiosity, how many rounds did it take?
What was the encoding found, in the end?
If such a method is unavoidable, perhaps Emacs should have:
(defun interactive-search-encoding (&optional candidates)
"Search `coding-system-priority-list' interactively.
For each encoding, do `revert-buffer-with-coding-system', and
query the user if the result is acceptable. Stop looping if so.
Optional (prefix) arg CANDIDATES is a list of encodings (symbols)
to try. Return non-nil if an acceptable encoding is found."
(interactive
(list (let ((raw (read-string "Try (space-separated) encodings: ")))
(when (stringp raw)
(mapcar 'intern (split-string raw))))))
(unless candidates (setq candidates (coding-system-priority-list)))
(let ((revert-without-query '(".*")))
(find-if (lambda (coding)
(revert-buffer-with-coding-system coding)
(when (y-or-n-p (format "%s acceptable? " coding))
(message "buffer-file-coding-system now %s"
buffer-file-coding-system)
t))
candidates)))
Emacs does have `select-safe-coding-system', but it is not interactive.
thi
next prev parent reply other threads:[~2010-01-26 9:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-24 21:29 How to determine encoding for file? kj
2010-01-24 21:59 ` Pascal J. Bourguignon
2010-01-25 5:57 ` tomas
[not found] ` <mailman.146.1264399148.14305.help-gnu-emacs@gnu.org>
2010-01-25 14:55 ` kj
2010-01-26 9:01 ` Thien-Thi Nguyen [this message]
2010-01-26 2:58 ` Kevin Rodgers
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ockhutmq.fsf@ambire.localdomain \
--to=ttn@gnuvola.org \
--cc=help-gnu-emacs@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).