all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: configuring coding systems for loading/saving
Date: Fri, 07 May 2010 11:49:24 +0300	[thread overview]
Message-ID: <83iq70jduz.fsf@gnu.org> (raw)
In-Reply-To: <hrvj11$n44$1@dough.gmane.org>

> From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
> 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
bugs.





      reply	other threads:[~2010-05-07  8:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-20 14:16 configuring coding systems for loading/saving David Madore
2010-05-06 23:23 ` Kevin Rodgers
2010-05-07  8:49   ` Eli Zaretskii [this message]

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=83iq70jduz.fsf@gnu.org \
    --to=eliz@gnu.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.
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.