[Top][All Lists]

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

Re: How to determine encoding for file?

From: Thien-Thi Nguyen
Subject: Re: How to determine encoding for file?
Date: Tue, 26 Jan 2010 10:01:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux)

() kj <address@hidden>
() 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."
   (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"

Emacs does have `select-safe-coding-system', but it is not interactive.


reply via email to

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