emacs-devel
[Top][All Lists]
Advanced

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

Re: ielm automatic saving of history -- bug 67000


From: Eli Zaretskii
Subject: Re: ielm automatic saving of history -- bug 67000
Date: Tue, 15 Oct 2024 21:23:10 +0300

> Date: Tue, 15 Oct 2024 23:00:11 +0530 (IST)
> Cc: arstoffel@gmail.com, simenheg@runbox.com, emacs-devel@gnu.org
> From: Madhu <enometh@meer.net>
> 
> *  Eli Zaretskii <eliz@gnu.org> <864j5dsgot.fsf@gnu.org>
> Wrote on Tue, 15 Oct 2024 15:18:10 +0300
> >> Date: Tue, 15 Oct 2024 10:16:33 +0530 (IST)
> >> From: Madhu <enometh@meer.net>
> [re:  savehist for ielm history]
> 
> > The problem, AFAIU, is not the specification of the encoding when the
> > file is written, the problem is to select the right encoding to begin
> > with.  utf-8-emacs-unix is how characters are represented in Emacs
> > internally, so it by definition can encode any character in the
> > history; this is not true for any other encoding.  I believe this
> > issue was what prevented you from existing Emacs, the issue you
> > described in your original post.  Apologies if I misunderstood.
> 
> 
> The point I wanted to make was that savehist-save binds
> coding-system-for-write (to 'utf-8-unix) and this seems to work
> without throwing a "coding system error".

utf-8-unix cannot save some raw bytes, which could happen in the
history of interactive commands such as IELM and other clients of
comint.

> my ~/.ielm-history (which gets read into comint-input-ring) has this
> line (but with raw characters)
> 
> ```
> (rfc2047-encode-string "foo \303\200 bar")
> ```
> 
> (funcall ielm--exit) in the ielm buffer causes the coding system warning:
> 
> "These default coding systems were tried to encode the
> following[...].. utf-8-unix"
> 
> However
> 
> ```
> (let ((coding-system-for-write 'utf-8-unix)) (funcall ielm--exit))
> ```
> 
> saves the history according to the code in ielm--exit without the
> coding system error.

And loses some of those bytes as part of that.  This is exactly why I
suggest to use utf-8-emacs-unix.

> but coding-system-for-write is still 'utf-8-unix and not
> 'utf-8-emacs-unix so I think I still need an explanation, please.

I'm not sure what to explain.  utf-8-unix will not correctly write out
raw bytes and some other characters outside of the Unicode range,
whereas utf-8-emacs-unix will correctly write all of them, because it
uses the same encoding as the internal representation of characters
within Emacs.

If this is still not clear, please ask specific questions.



reply via email to

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