From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: ielm automatic saving of history -- bug 67000 Date: Tue, 15 Oct 2024 21:23:10 +0300 Message-ID: <86jze9ql81.fsf@gnu.org> References: <86r08isrtg.fsf@gnu.org> <20241015.101633.2219948655969771381.enometh@meer.net> <864j5dsgot.fsf@gnu.org> <20241015.230011.595343732756221115.enometh@meer.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35212"; mail-complaints-to="usenet@ciao.gmane.io" Cc: arstoffel@gmail.com, simenheg@runbox.com, emacs-devel@gnu.org To: Madhu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 15 20:24:31 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t0mDf-0008yX-0J for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Oct 2024 20:24:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0mCu-0004eH-44; Tue, 15 Oct 2024 14:23:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0mCm-0004cZ-Fd for emacs-devel@gnu.org; Tue, 15 Oct 2024 14:23:37 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0mCk-0003mH-Tg; Tue, 15 Oct 2024 14:23:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=EcDCmlWSAiMTPyU8cCY3FUTkmp/WsjW967iLoSyEsQk=; b=hY2QdhPA3OIg IEjd/FGzL6k1WQ/tqZw2SzUAWgmWlWWXhQNnuHGbnKQz1pNPvX02frbKKXzBG9w4UT1Nu1fy99Sf3 5DYzcp4ko1uQ2WeUP25rpGjLa6EtFsAnX0Wk/T2Qdq9pwQMjePID0ljR2ZnVPNxT/WjD1DpStVnAU puBUCgyUZRE8N0FOc8dsIc0aGK8kVbAGrabnnQJF0Z3ObDwWNojbKiW8H9y1zYwm4XxQ8L36idt9a Xvk6zKh8+IdzXBh6lBb2u4Mc7PkCkwVUYBRAuI0UQnEFvIVsByxL6ye0r+C19j7SiRk0dRq6J6yjR pL8u/NVMe1ZmCZUIN9y1pg==; In-Reply-To: <20241015.230011.595343732756221115.enometh@meer.net> (message from Madhu on Tue, 15 Oct 2024 23:00:11 +0530 (IST)) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:324605 Archived-At: > Date: Tue, 15 Oct 2024 23:00:11 +0530 (IST) > Cc: arstoffel@gmail.com, simenheg@runbox.com, emacs-devel@gnu.org > From: Madhu > > * Eli Zaretskii <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 > [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.