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: newline-and-indent vs. electric-indent-mode Date: Fri, 22 Jan 2021 14:53:55 +0100 Message-ID: <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="19622"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: Emacs Developer List Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 22 14:56:11 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 1l2wv3-0004x4-8a for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Jan 2021 14:56:09 +0100 Original-Received: from localhost ([::1]:44074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2wv2-00021x-90 for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Jan 2021 08:56:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2wt8-0008EC-DV for emacs-devel@gnu.org; Fri, 22 Jan 2021 08:54:11 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:44594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2wsz-00078C-Qv for emacs-devel@gnu.org; Fri, 22 Jan 2021 08:54:09 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 5BF4F160060 for ; Fri, 22 Jan 2021 14:53:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1611323637; bh=RnMqDGJKcqBVCPqWI6BWX4IMmTNixsiQvq5WmGl0aTs=; h=From:To:Subject:Date:From; b=rayrAzWjtbk6wcptntGnDDU6Tu27S19oCPuJSfMUEwyp6EkalkWkFUSz8WTyn9O3M 4/tprANV7WPQFpzYdWucktHqRk8PBlLQpn8vzFIjJyDJOR2/ODu09Vj9P0IdB3vyRo LVlVa5Aab++gwcDQz7glr1/nd5Y6bp1/fVChrARlIgEwckbqsXNZyKVYYV7WywQWqM dBt7f8YqAEqpP782NR9Q/hGG9NyTJOPrCVdISYbkjd3O8qomwjygILqMCauBtm0xoy B0j5zAX6R6zt9JtJ1kq3ccrvsvQGvm8jfmKBd5xNpD2LCNf7C0WOJHZ8FtakkIqurg FCFgCbjWIv+eQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DMgj02tzgz6tmZ for ; Fri, 22 Jan 2021 14:53:56 +0100 (CET) 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:263273 Archived-At: Hi all, in a debugging session for some indenting bugs I noticed with some surprise how often the mode-specific indenting function is called. There seems to be a systematic overlap between the keybinding of RET and electric-indent-mode. Many (almost all?) modes bind RET to newline-and-indent, but '(?\n) is also the default value of electric-indent-chars. So, whenever a newline is entered, 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. Should electric-indent-mode be switched off by modes which map RET to newline-and-indent? Or should the modes refrain from mapping RET? -- Cheers, haj