From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Morgan Willcock Newsgroups: gmane.emacs.devel Subject: Re: Accidental change of behaviour for electric-layout-mode? Date: Tue, 24 Sep 2024 19:59:47 +0100 Message-ID: <871q18op24.fsf@ice9.digital> References: <87wmj2dr4q.fsf@ice9.digital> <86v7yle1ma.fsf@gnu.org> <86cyktdx68.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19146"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 24 21:01:02 2024 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 1stAmU-0004kc-EY for ged-emacs-devel@m.gmane-mx.org; Tue, 24 Sep 2024 21:01:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stAlT-0002Vg-TT; Tue, 24 Sep 2024 14:59:59 -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 1stAlR-0002VY-Qa for emacs-devel@gnu.org; Tue, 24 Sep 2024 14:59:57 -0400 Original-Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1stAlO-0002pp-EM; Tue, 24 Sep 2024 14:59:57 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 522141C0003; Tue, 24 Sep 2024 18:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1727204388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p+IChlU3SxIFpqTLDLhx6rae9mVcwQULkiT9tlngZzM=; b=JUjtpSSOesOhBn36VGh/pMWRo38N3eCIQ3JGzUl4Hp4KZytiMslK6iR2LqY39tMwQ78Mav h3uaqz9bHS/axP2qFIQ4Up+Mj9qZoFBFbni/YKdhT1x6T7gGXD6Zy5tp5CM/9B8E58qrvt 59clTXtpfbwOspdEVRblkNezeAG2tfywIo/zUvFcVGQJ1igOqfmmbW1CC3e8rs0h34809U kLzQ/27LGOkd5MyMeKl+vPkY9UAWkG+5/NFeQcdDkBIQ3GvzLoczgxN1o2chJRDi/rpOnc OHImgLp8DLMi9tgFZeKN9oPeOeGc8xsl7wDLEAtoJnNSFDqMEQrTRPZMhfRTcg== In-Reply-To: <86cyktdx68.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 24 Sep 2024 15:59:59 +0300") X-GND-Sasl: morgan@ice9.digital Received-SPF: pass client-ip=2001:4b98:dc4:8::225; envelope-from=morgan@ice9.digital; helo=relay5-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_PASS=-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.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:324042 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Jo=C3=A3o T=C3=A1vora >> Date: Tue, 24 Sep 2024 13:12:24 +0100 >> Cc: Morgan Willcock , emacs-devel@gnu.org >> >> No, it wasn't. I was probably experimenting with something. >> >> You can revert it (or make it optional), etc. > > Thanks. So Morgan, please post a patch that makes this feature > opt-in. Patch is attached. --=20 Morgan Willcock --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Restore-comment-string-check-for-electric-layout-mod.patch >From 0fe0d66aff7d4969e99478469afadede7e40f4ac Mon Sep 17 00:00:00 2001 From: Morgan Willcock Date: Tue, 24 Sep 2024 19:33:11 +0100 Subject: [PATCH] Restore comment/string check for electric-layout-mode This reverts an accidental change which allowed electric-layout-mode to insert newlines inside strings and comments. The recent behavior can be restored by setting the new variable 'electric-layout-allow-in-comment-or-string' to a non-nil value. * lisp/electric.el (electric-layout-allow-in-comment-or-string): New variable to determine whether inserting newlines is permitted within comments or strings. (electric-layout-post-self-insert-function-1): Restore the previous default behavior of not inserting newlines within comments or strings. --- lisp/electric.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/electric.el b/lisp/electric.el index d02bcb4735b..d84faf5433f 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -385,6 +385,9 @@ electric-layout-rules (defvar electric-layout-allow-duplicate-newlines nil "If non-nil, allow duplication of `before' newlines.") +(defvar electric-layout-allow-in-comment-or-string nil + "If non-nil, allow inserting newlines inside a comment or string.") + (defun electric-layout-post-self-insert-function () (when electric-layout-mode (electric-layout-post-self-insert-function-1))) @@ -409,7 +412,10 @@ electric-layout-post-self-insert-function-1 (goto-char pos) (funcall probe last-command-event)))) (when res (throw 'done res)))))))))) - (when rule + (when (and rule + (or electric-layout-allow-in-comment-or-string + ;; Not in a comment or string. + (not (nth 8 (save-excursion (syntax-ppss pos)))))) (goto-char pos) (when (functionp rule) (setq rule (funcall rule))) (dolist (sym (if (symbolp rule) (list rule) rule)) -- 2.39.5 --=-=-=--