From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.help Subject: New line and trailing whitespaces Date: Sat, 20 Apr 2024 14:10:34 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3701"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 20 14:11:36 2024 Return-path: Envelope-to: geh-help-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 1ry9Z7-0000nB-PR for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 20 Apr 2024 14:11:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ry9YV-0007cn-UU; Sat, 20 Apr 2024 08:10:55 -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 1ry9YS-0007Zs-BH for help-gnu-emacs@gnu.org; Sat, 20 Apr 2024 08:10:54 -0400 Original-Received: from sonic315-13.consmr.mail.bf2.yahoo.com ([74.6.134.123]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ry9YN-0006J8-HT for help-gnu-emacs@gnu.org; Sat, 20 Apr 2024 08:10:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1713615041; bh=36+49JfUWldl4NhKvvJXym9N6Jm5Cg9g1NLNi8vf2iY=; h=Date:From:To:Subject:References:From:Subject:Reply-To; b=r/wgZvQyKXhsM73OD0B1LdlVMkz90lk7n8eweNYySba8Z8++e5eZOuVuyvtCyW/LOaZRlfs+o6qbTIpWgqaKk9axcfqetnK+9h/7l1P9ea/FnCUjQ0dpCq8kGsiDh//qYVxhK9X22iaJamJo+D55DhZ8ylJgOGSB6HJfaqB30k1h+Mhgwik40nbaP404gJep5RZ3uK9n1eCKxXhR3StP+6Qlu5YEPfeBFZxzv+F+yocvps4XP+5j7te5asHpWiQH0dYwk0SjSPxYku/dHRetvrX0ERtNRhvkWBEeey9DaQxiu21LMqUQsiyXQa8ttark3Zx3HAOWwdp5vg3VvADfXg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1713615041; bh=V7DkDfXWQJo00U+rhevlSZ6ZvbsR+EXFNBxNCR1lrqC=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=GRzjsdXWvpb0SbHp+QLPyjB4qDGQW8J5Bl+tYFrDMb41/TvYD1oTnQvfXW8EwQPdCib8v9znAzKqxV7l4MWyFgOVqTRGNkhNkzcg8HjedvUFgh8WvYonwq6bE/sB/VcP7e97OqsvNQ32uAH9DQdZaAClcA2O6lt4kNt4/CslFdeDTpheOF9cMAESEEPcB4Efu08k0clh8dm0Z2OxIU2YUYf4xhq9IKSOHS1dLUlKkPj5gPVhhAWALKak0isUsQXytloTy3+vpChCTQ4HIF373DhJAqUro7W6DodhXNZGBND3kc8Z982cWiZy9Uvl8kLVWkjX6W0R5JUAR4gEm39tbw== X-YMail-OSG: KuqcCS0VM1m4Rk_LMpPJ9jlWDkkZJUB4Tt.cM.gQOfkcayDetjvxKIStJS5JGLB N6aC2MbW50jogwum_2exyaD8DdHubsS_X0.7syNzmSOLBhWyTqEw4pknMp3gr5rRkd0xPD3ZOPJE 3hXmDXrCQbf2uDjAdO.BpSKM3eyN2e2x9W.D4r14Pnbz6ss3P7gwgIf3ZpvBxIZ46vlpLkKi5MG5 vtE9So7qKO7gPnNosUTJ2zDWyZ6ivwx.RSHsXawrZOKI_oWvk1sT4LkXCAUBlE2Z.DoRrOQqd.f. j4Rc0gcYsayPNNgfwEaudh3JMUUI2.fpxaN5RiC03lwcXrYl1t.4pQgEFpTwb4ga_gEPCQQ9ifI6 YaX4Q_DKHHPR7g_ACne.3wcVX8qQ0wEIVet9tBZcVbK_z8gihikUXx0waYYGJMoIsNCevvyqeQH1 rAfaGzf0jPss8U0SoXYahlG9NYRSM2njaxXl48RONaXQsBiD0iWGE3w43HwWQSJ9969PGn0FEZK9 VrQ3fxChOWbVIGA2CCsNlroWUKwCKCQl3jwmYhA3aKxQzzzoeYhj8JnugyxFhJU7UtPcyPtkty1M Jz5Ix0KJ5q0yP5NzaCFsVjmuNhItIvRh0_jJh2M8nQUnUGcmeMYUErg5bsMZpy35vC3VwBuMA6Cf 4SW7cioR1GXyLmcRLWl02SnwddM8O.UO_LR68Ia2Wozl_dsBhiZDleF06eMNJ.i.BzNfi224UHdK 8V6lkVdYtj5LvYlcNZmjW2Tgq3tGI1UCdFyDOQORF.ZAuXD6ixpBY3J1ebCNpfWlPR4QKKyGol0a mnsqp8fZeUVgR4KUDoocHHiPiv.zgt_HgmSJv6kT9q X-Sonic-MF: X-Sonic-ID: 63bb5648-7f98-482e-ac6e-af3127d350db Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.bf2.yahoo.com with HTTP; Sat, 20 Apr 2024 12:10:41 +0000 Original-Received: by hermes--production-ir2-7b99fc9bb6-sv997 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 5d50488d336128183e96d0c8a0dfb8bb; Sat, 20 Apr 2024 12:10:37 +0000 (UTC) Content-Disposition: inline X-Mailer: WebService/1.1.22256 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.134.123; envelope-from=spacibba@aol.com; helo=sonic315-13.consmr.mail.bf2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:146400 Archived-At: Hi: Using visualstudio recently I have found a nice behavior I would like to port to emacs. When the cursor is in an empty line and I press enter, the cursor jumps to the new line and indents (similar to what emacs does) but also removes the trailing whitespaces in the previous/leaving line. I thought to implement that behavior in emacs but I figured out that the newline command is 1. much more complex that what I expected (creating a lambda on the fly that then fsets to finally only use if when non-interactive mode) 2. That non-interactive function already does something similar to the cleaning of previous line. SO the questions are... 1. Isn't there a way to simplify the code newline command at least to not create a lambda on the fly? Isn't there any penalty for doing that on every RET? 2. Isn't it better to use some pre/post hooks in order to "modularize" the newline behavior (like electric-indent-mode, auto-fill-mode) 3. What's the recommended method to implement the desired behavior then? Thanks in advance, Ergus