From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: newline-and-indent vs. electric-indent-mode Date: Fri, 22 Jan 2021 09:49:14 -0500 Message-ID: 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="31309"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Emacs Developer List To: haj@posteo.de (Harald =?windows-1252?Q?J=F6rg?=) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 22 15:50:14 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 1l2xlO-00082K-9p for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Jan 2021 15:50:14 +0100 Original-Received: from localhost ([::1]:47012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2xlN-0007dx-Cp for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Jan 2021 09:50:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2xkf-0006lO-Vb for emacs-devel@gnu.org; Fri, 22 Jan 2021 09:49:30 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:17145) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2xkU-0006vd-Ii for emacs-devel@gnu.org; Fri, 22 Jan 2021 09:49:27 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0DD07440516; Fri, 22 Jan 2021 09:49:17 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A98984404FF; Fri, 22 Jan 2021 09:49:15 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1611326955; bh=VlP5ydXr1LGBxUMZhITT7P2iZy79LVg24GAdQwDdwH4=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Z3x7z8iDRl6vbZJNSJ41tXM0nrz0SM+SEWDiuOJLE0+LipxhVZLRG5pnD413OMIaf 5m+JRvCht0glBjyJOTOr9FJFLVFzOTzJfkpTqR6E+GbthDMnkHXM8UVwATw8W+tKBe /3WkS7B/k/700H55NPe7EHhRmlqkU41GmvR2S3xhp4T1MhU0f+UHLMVNvPcRhOBCGt z6mHXMI39ZoVQ+jF348VKCfErJ/YrLrSjNlc3xa6mKvEVncQ0kCoMcSrpJROcvE8SQ qdtr+UCCNgQnM1woGqIiV1mzmIkvVaeJJJ655zu7IJbXMecZJMb/7fzM0rieABbJ1m QhseqCvyiTUEQ== Original-Received: from alfajor (65-110-220-188.cpe.pppoe.ca [65.110.220.188]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 63E4612047F; Fri, 22 Jan 2021 09:49:15 -0500 (EST) In-Reply-To: <87wnw5yt58.fsf@hajtower> ("Harald =?windows-1252?Q?J=F6rg=22?= =?windows-1252?Q?'s?= message of "Fri, 22 Jan 2021 14:53:55 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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:263277 Archived-At: > Many (almost all?) modes bind RET to newline-and-indent, Any mode which does that should be fixed. Whether RET indents or not is a user preference, not something that should depend on the kind of language you're editing. > So, whenever a newline is entered, By that I assume you simply mean whenever `newline-and-indent` is executed? > there are three calls to the mode-specific indenting function: > > - one call for the current line, caused by electric-indent-mode. This > makes some sense because the line's content might suggest a different > indentation than what could be guessed when the line started out as a > new empty line. It is annoying, however, when the mode gets the > indentation wrong (which occasionally happens). It is also > superfluous if the character which causes a change in indentation > (for example "}") is either itself in electric-indent-chars (as in > perl-mode) or handled by the mode's keymap (as in cperl-mode), both > resulting in a call to the indenting function. > > - 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. > 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). But that doesn't change the fact that `newline-and-indent` should work right, including not calling the indent function redundantly. Stefan