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.bugs Subject: bug#72879: 30.0.90; string-lines hardcoded eol Date: Fri, 30 Aug 2024 09:15:15 +0300 Message-ID: <86wmjyedu4.fsf@gnu.org> References: <8734mn5hs3.fsf@librehacker.com> <86y14fdt1t.fsf@gnu.org> <87ttf33x2t.fsf@librehacker.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2665"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72879@debbugs.gnu.org To: Christopher Howard Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 30 08:16:35 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sjuvy-0000Yo-K5 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 30 Aug 2024 08:16:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjuve-0006oj-31; Fri, 30 Aug 2024 02:16:14 -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 1sjuvX-0006mV-KH for bug-gnu-emacs@gnu.org; Fri, 30 Aug 2024 02:16:07 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjuvX-0004Si-6b for bug-gnu-emacs@gnu.org; Fri, 30 Aug 2024 02:16:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=Mu98kU0D0doNA9dd3ioKhi1nJhMCZHN05HbycLfRIC0=; b=ZC2aQIYDeHFSnHl6ye3TPiaEbhl8CtJClIZHZ3d0G7/l8627uUCyQ9WxTQf2wUSMt0tObm+H9CCsLC+bXMCnNEVXicnNFR7tlAT9JzKihP8Fyp9BFmSGB6cmX5VBUnsCTZ1SE+hgr+dyvtCQ/49NzjwzkHBvOfXFr34kM4QVrVJQPHvwsuXFbbEGFe0SllZJKCHJ1n/CroNI62ENq1N0rjKZwusFa8993NSdke3sixnYVrilu2aGCHMsMSLt3AlItucKXoS4JQR/I/98QGMtZCcURCdCDMmQTL/C719sS3xbnsJBbcnSYeibMWYNWmxB4qAypnFGFBOIwT+3BWBMqw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sjuwP-0007rE-WC for bug-gnu-emacs@gnu.org; Fri, 30 Aug 2024 02:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Aug 2024 06:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72879 X-GNU-PR-Package: emacs Original-Received: via spool by 72879-submit@debbugs.gnu.org id=B72879.172499858530023 (code B ref 72879); Fri, 30 Aug 2024 06:17:01 +0000 Original-Received: (at 72879) by debbugs.gnu.org; 30 Aug 2024 06:16:25 +0000 Original-Received: from localhost ([127.0.0.1]:52346 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sjuvp-0007oA-1W for submit@debbugs.gnu.org; Fri, 30 Aug 2024 02:16:25 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36600) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sjuvm-0007nq-6O for 72879@debbugs.gnu.org; Fri, 30 Aug 2024 02:16:23 -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 1sjuum-0004N3-0G; Fri, 30 Aug 2024 02:15:20 -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=Mu98kU0D0doNA9dd3ioKhi1nJhMCZHN05HbycLfRIC0=; b=Njvce/SveU66 PtGOZsh2JRDY7QLPl7ItmlFZec4FH9DU6ym7+d/d+LO+TxsEJXlztP7Z2jFVg/mTojPeUiusIx3us T1aQIkHy0/e8C8JUMrKzKL8y7l9L6aUA42xqiEhurSPhMmPwcwzQtxL13bNFQRtxL3ysfpuNczyU7 TVH0QgQxO69OlU/dfdKGANGBDAmezITbVPgE3EVsy+TuCFDneZ8NBUtVE6OKuXuCY+h604AvdMVKW aXJJK7ntFrFvJZRLJ5rP2w1ARVe8HLvq4ISwG2AHZJYeZwtnwLEOtXhCSewZhLgV1iXfYksuB9XzY /WdV8Sjyert1rKhxWY6SPw==; In-Reply-To: <87ttf33x2t.fsf@librehacker.com> (message from Christopher Howard on Thu, 29 Aug 2024 12:15:06 -0800) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290953 Archived-At: > X-Spam-Status: No, score=-1 tagged_above=-10 required=5 tests=[ALL_TRUSTED=-1] > autolearn=ham autolearn_force=no > From: Christopher Howard > Cc: 72879@debbugs.gnu.org > Date: Thu, 29 Aug 2024 12:15:06 -0800 > > Eli Zaretskii writes: > > > Well, "newline" is the name of the \n character, so I think the doc > > string is okay. > > So, in Emacs, \n = newline = LINEFEED by definition? Yes. And not only in Emacs, AFAIK. > I notice if I open a new buffer, set it to DOS encoding, and then run (newline), than it inserts 0d0a. But the newline docstring doesn't mention anything about making adjustments for encoding. I think you are conflating two concepts: "newline" is the \n character, whereas "end of line" (a.k.a. "EOL") is one or two characters that indicate the end of the line. The DOS-style CR-LF end-of-line format is what you are concerned about. If you want Emacs to convert CR-LF to a single newline, this must be done when the process output is read, and you should define a proper coding-system for your process. If the incoming text _always_ has the DOS-style CR-LF EOLs, the coding-system for reading from the process should be either 'dos' or SOMETHING-dos (like 'utf-8-dos') if the encoding of text is also known. If the EOL format of incoming text is not known, and could sometimes be DOS and sometimes not, then leave the EOL part of the coding-system unspecified, as in 'utf-8', and Emacs will then auto-detect the EOL format and convert if needed. (Actually, I think it is safe to always use 'dos' or SOMETHING-dos, unless you could also see the Mac-specific CR-only EOL, which is nowadays extremely rare.) The doc string of string-lines does not mention anything about EOL format decoding because it is a function for processing strings, not a function for receiving input from outside Emacs. The decoding issues are part of receiving input, and are mentioned in the relevant APIs.