[Top][All Lists]

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

Re: configuring coding systems for loading/saving

From: Eli Zaretskii
Subject: Re: configuring coding systems for loading/saving
Date: Fri, 07 May 2010 11:49:24 +0300

> From: Kevin Rodgers <>
> Date: Thu, 06 May 2010 17:23:21 -0600
> David Madore wrote:
> > I also tried this:
> > 
> > (setq select-safe-coding-system-accept-default-p
> >       '(lambda (coding) (string= coding buffer-file-coding-system)))
> > 
> > which I think should do more or less what I want (accept an encoding
> > as safe only if it matches exactly the buffer-file-coding-system), but
> > it fails for a stupid reason: coding is typically something like
> > "iso-8859-1" whereas buffer-file-coding-system is typically something
> > like "iso-8859-1-unix" - and I don't know how to test more
> > intelligently than with string-equal.
> How about:
> (equal (coding-system-get coding 'mime-charset)
>         (coding-system-get buffer-file-coding-system 'mime-charset)
> or
> (equal (coding-system-change-eol-conversion coding 'unix)
>         (coding-system-change-eol-conversion buffer-file-coding-system 'unix))

I think this is better:

  (coding-system-equal coding
                       (coding-system-base buffer-file-coding-system))

This is better, because it will also handle aliases to coding systems,
such as `latin-1'.

> Can someone explain why
> (coding-system-change-eol-conversion 'iso-8859-1 nil)
> ⇒ iso-8859-1
> (coding-system-change-eol-conversion 'iso-8859-1-unix nil)
> ⇒ iso-latin-1

What did you expect it to do?  The doc string says

    If EOL-TYPE is nil, the returned coding system detects
    how end-of-line is formatted automatically while decoding.

and that's what you are getting.

> > Also, I'm afraid overriding
> > select-safe-coding-system-accept-default-p could have unpleasant
> > effects (e.g., if some Emacs application wishes to suggest that the
> > previously chosen file encoding is inadequate).

To the OP: I suggest to try using the overriden
select-safe-coding-system-accept-default-p and see if you have any
trouble.  If you do, please report them, as they are most probably

reply via email to

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