From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: haj@posteo.de (Harald =?utf-8?Q?J=C3=B6rg?=) Newsgroups: gmane.emacs.devel Subject: Re: newline-and-indent vs. electric-indent-mode Date: Fri, 22 Jan 2021 20:33:37 +0100 Message-ID: <87o8hgzrzi.fsf@hajtower> References: <87wnw5yt58.fsf@hajtower> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32759"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: Emacs Developer List To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 22 20:34:42 2021 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 1l32Cg-0008QC-8z for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Jan 2021 20:34:42 +0100 Original-Received: from localhost ([::1]:43756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l32Cf-0008P0-AZ for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Jan 2021 14:34:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l32Bq-0007BA-M4 for emacs-devel@gnu.org; Fri, 22 Jan 2021 14:33:50 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:33850) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l32Bi-0005LW-Fs for emacs-devel@gnu.org; Fri, 22 Jan 2021 14:33:48 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id A9C3C16005F for ; Fri, 22 Jan 2021 20:33:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1611344019; bh=3a0aExa3u1d9DP/kh31Gr99x7AySWBC/8bjbq7uPZrc=; h=From:To:Cc:Subject:Date:From; b=In++JXfZ+8uoheLgMWQnUX6/IB2Is2dvePeBxMlpwFWi7iCe+wjGVdc9NSoILvWd3 avh8diJZVSIf7QIy0G4t4qtAwUP0AyZlRTFL/dz3omL+h6fpmCymk6KX/nlTMm0/vH Bjd0f9F3LUqoGN4LZl3xx0yF+5DCXA3arLLuNVqk7LZkTSkRgPoCyGBKX6PRZy3ino WR2aR3XkZNRYfPsKTpueEbnm51XXdfdAl5h3v0APjgucQiNcl4AKffbVG0Mz/KdjcC TdARo1jZuguN/R9Uvmz+3CiNvdts2+uIrWZSTFSxNcadsW4LcSxSrOfhj7ApYetvNi 1XJAcJaU7u/3Q== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DMqDz0gG7z6tmM; Fri, 22 Jan 2021 20:33:38 +0100 (CET) In-Reply-To: (Stefan Monnier's message of "Fri, 22 Jan 2021 09:49:14 -0500") Received-SPF: pass client-ip=185.67.36.65; envelope-from=haj@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:263284 Archived-At: Stefan Monnier writes: >> Many (almost all?) modes bind RET to newline-and-indent, > > Any mode which does that should be fixed. Ouch... I see now that my "observation" was plain wrong. CPerl mode does it, but only as a user preference. When I checked other modes with C-h k, I did it in an Emacs instance where I had it globally remapped. I failed to check the sources. Sorry for the confusion. > Whether RET indents or not is a user preference, not something that > should depend on the kind of language you're editing. For most programming and markup languages indenting makes sense, but less so for other modes. I understand that python-mode disables it, but was a bit surprised that c-mode disables it, too (I understand it now after following two lengthy threads on debbugs). I guess it wouldn't hurt to add a sentence to the docstring of electric-indent-mode how it should be managed for a single buffer. The method with an extra variable (electric-indent-inhibit, works only to disable a globally enabled mode) or an extra mode (electric-indent-local-mode, works both ways) is somewhat nonstandard and the question seems to pop up occasionally on various platforms. >> So, whenever a newline is entered, > > By that I assume you simply mean whenever `newline-and-indent` is executed? Yes. I thought that I meant "whenever I hit the enter key" but this was only true because I had mapped it that way. >> there are three calls to the mode-specific indenting function: >> >> - one call for the current line, caused by electric-indent-mode. [...] >> >> - two calls for the following, empty line. One is caused by '(?\n) >> being in electric-indent-chars, the other by the current command >> being newline-AND-INDENT. This doesn't make any sense. > > It sounds like a bug indeed. I think both having two calls (one for > each line) or having one call (for the new line) could arguably be > correct, but three calls is indeed an error. So... I guess newline-and-indent could suppress the call to indent-line-function for the new line if electric-indent-mode is t and electric-indent-inhibit is nil and ?\n is in electric-indent-chars? Just for the record: The results are correct, and the delay isn't noticeable even with the convoluted indenting routines of CPerl mode. It is just a bit annoying when you are tracing through the routines trying to figure out where to fix a bug. >> Or should the modes refrain from mapping RET? > > Very much so, yes (unless there's a good language-related reason why RET > should behave differently for that specific language). I now see that they actually don't do this. Sorry again. In CPerl mode, the remaining issue is actually the other way around. You can activate cperl-electric-linefeed via customize to do newline-and-indent. However, when you don't set this option, you still get newline ... and indent, thanks to electric-indent-mode. So, that customization option is futile since whenever 2013-ish electric-indent-mode became default. I take the total lack of customer protests and bug reports as a hint that Perl programmers actually are quite fine with indenting as they type. -- Cheers, haj