From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: `message' not outputting the newline "atomically" Date: Thu, 27 Jun 2019 05:34:25 +0300 Message-ID: <838stnkb7y.fsf@gnu.org> References: <07619925-e367-fb88-2dd8-27addb2e9052@grinta.net> <68b398b1-3790-b32f-535d-6ea2518f79b8@cs.ucla.edu> <83r27hlkix.fsf@gnu.org> <1d550142-8d66-485b-6796-981351718b53@cs.ucla.edu> <83blykjijy.fsf@gnu.org> <65c60a70-311d-bf9f-b509-d3dd80ddc511@cs.ucla.edu> <83a7e4jh5d.fsf@gnu.org> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="24038"; mail-complaints-to="usenet@blaine.gmane.org" Cc: larsi@gnus.org, eggert@cs.ucla.edu, emacs-devel@gnu.org To: Daniele Nicolodi Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 27 04:34:50 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hgKFO-00068j-55 for ged-emacs-devel@m.gmane.org; Thu, 27 Jun 2019 04:34:50 +0200 Original-Received: from localhost ([::1]:45878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgKFN-0005f6-6G for ged-emacs-devel@m.gmane.org; Wed, 26 Jun 2019 22:34:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56229) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgKFH-0005em-Ml for emacs-devel@gnu.org; Wed, 26 Jun 2019 22:34:44 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:38848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hgKFF-0004jn-U4; Wed, 26 Jun 2019 22:34:41 -0400 Original-Received: from [176.228.60.248] (port=4502 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hgKFF-0002jR-CS; Wed, 26 Jun 2019 22:34:41 -0400 In-reply-to: (message from Daniele Nicolodi on Wed, 26 Jun 2019 13:36:54 -0600) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238181 Archived-At: > Cc: larsi@gnus.org, emacs-devel@gnu.org > From: Daniele Nicolodi > Date: Wed, 26 Jun 2019 13:36:54 -0600 > > Not that I care much about this, I feel that defending the use case of > debugging Emacs through printf() statements is rooted in believes akin > to religious ones, and religious arguments cannot be won with logic. It isn't religious at all. We have built-in debugging capabilities that use stderr, see the trace-redisplay feature as one example. This particular feature is very valuable for me, as it happens. > > Can't we also fix that by replacing the above with 'sprintf' followed > > by 'write'? > > Why is re-implementing line buffering in Emacs any better than using > libc line buffering? Because we can apply that on a per-case basis, whereas setvbuf is global and irreversible. > For your main argument in the thread, we would be loosing crucial > debug information if something goes irreparably wrong between the > string preparation and the write(). And given how error-prone is > string manipulation in C, there are much higher chances that this > will happen if we start doing that for every function that want to > print something on stderr. My main argument is actually that the issue this thread is trying to fix is minor, even insignificant. But given that some people pressure to find a solution, I propose various compromises. As any compromise, they are somewhat ugly. My personal preference would be to leave things as they are. > Any solution requires buffering of the output till the first newline. > And you are opposed to buffering. I'm opposed to buffering stderr globally, yes. But I can agree to that in specific cases. The problem is, setvbuf doesn't allow selective buffering. > Are you proposing that we selectively apply buffering in some occasions > but not others? YES! > However, if that is the route you are suggesting, it is much easier to > enable line buffering unconditionally ad place fflush() calls where it > matters, than the other way around. You are suggesting fflush after every character written? That's impractical, and we usually use something other than fputc to output the messages.