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: Madhu
Subject: Re: ielm automatic saving of history -- bug 67000
Date: Wed, 16 Oct 2024 09:55:42 +0530 (IST)

*  Eli Zaretskii <eliz@gnu.org> <86jze9ql81.fsf@gnu.org>
Wrote on Tue, 15 Oct 2024 21:23:10 +0300

>> 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.

In this case there was no loss of bytes. Apparently using utf-8-unix
is sufficient to encode the contents of the buffer beings saved
without any loss of data. The file written is identical to the file
which was read.

(let ((comint-input-ring-file-name "/dev/shm/f") (coding-system-for-write 
'utf-8-unix)) (comint-write-input-ring))

>> 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.

I think the question I wanted to ask was: does specifying
coding-system-for-write (to any non-nil acceptable value)
unconditionally suppress the "coding system warning" error?  from your
response above I think the answer is: "yes, but it may clobber it".

The second issue is that the coding system warning which is printed
when emacs prompts for a suitable coding system isn't entire accurate.
it says the default coding system which was tried, to encode ".."  is
utf-8-unix and cannot encode these characters etc. but if it is
sufficient, and if i type utf-8-unix into the prompt, the file is
encoded and saved.



reply via email to

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