Received: (at 77081) by debbugs.gnu.org; 17 Mar 2025 19:51:58 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 17 15:51:58 2025 Received: from localhost ([127.0.0.1]:32839 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tuGVC-0004bJ-Ai for submit <at> debbugs.gnu.org; Mon, 17 Mar 2025 15:51:58 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:49436) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <eg642616@HIDDEN>) id 1tuGVA-0004aC-4D for 77081 <at> debbugs.gnu.org; Mon, 17 Mar 2025 15:51:56 -0400 Received: by mail-ot1-x344.google.com with SMTP id 46e09a7af769-72bd78e695dso370369a34.3 for <77081 <at> debbugs.gnu.org>; Mon, 17 Mar 2025 12:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742241110; x=1742845910; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=XTqIGqJB/o6hTmju1mrjTe3i3B8iairN4FOn2kIU8NM=; b=mVjsUe77XuRIAyx/5dDDXlTmZIg6wjS6oY/vyBPd7VuPzmNyac1FuOnHEEVqsV2SUc ZHUvd4HkptAVMQ3gj9og/e0CHxJkUijySuxy59eIlCCqE4DJMwk71GqEQxfuCC4L84Sn lDZnklaxTjbDXfowAnEVkyQSiVIGxNLqSG6syiGWOxyzN7Tn0KmU9Gaxn0CiHBTwDHH4 2qY8eh+agj7oRU9ps2ENeKf0gZGywjOgLr6pV3kDvmck9KLegcKxRkbiF5Z67R29O/4T e2QIlrCAf8JdTBw2p8p08QLa0N22ILekKb4CfDR90HKPJ7o9H1hakoAXOFCHNnpvzHFw Zayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742241110; x=1742845910; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=XTqIGqJB/o6hTmju1mrjTe3i3B8iairN4FOn2kIU8NM=; b=cWA1QcaiP/13nYccprBimoNnIn1r4hoxQVUQ/NU4J29zJzAcW9Qu5N0rjDN7K8P3zg AG3lf+pyc0P6A6NLIOmQu1jN7/2eIirOH4zDtBHMMQuASOWskT1EhWiKc2vAes50fyVT TAIXS3D4Ns4debdXUIgJLFwi5WJpaUm+YL6y8jAxcVB8Aj4OvY0lERpMXdThhiacknSq k03Pjqf3D6bkkW0SYzNcJBe+I2eAN3XJzHh7eVvO/zwzVX30Tsy08W/VWH0hXg8y0sZa gqrsPfEBdUHymUSlKP8BoYU6X/gcpxERaBqZwdy6yoNGbVw5Xuq8MEsf/56R6m+ijANo xy6g== X-Gm-Message-State: AOJu0YyQsPErpYhZbukK10lJEOdCxwRaGUwiybSCx4cYBCF7n2tmopq9 lsNz1pAbhoSnQfhi8PRo8gykceObjQIVXovTJ86aVnPAUZY5q7y1VO1H7YH8 X-Gm-Gg: ASbGncuEkkbz6QFYPxlLlo429KUaxdhD9PcMmw66ro/5Qc7EUjLbzIgsyJ52XMFA41G jflgZOnMQONz5/WkS9hvFP/rd7ONmYQV740QMHGITfF8kOJDJVZNo6Mdd0GunV6Wi5bW4gIm5FQ IKcmkf3Xk5W4K4auxQM5uzNCs56j7lW9zwKDv6+n8IQdypKgo+DtcmzTO+jQJZAeOHThqNjdei7 Iq9X/7kpPS8/8Qo1Hy2GKLOcF1LSnC+geiNE93owqaTEsGgjEXb6yrU+qZ4yExsdQBsr5ji5wAy 5m6dlW02+0cH X-Google-Smtp-Source: AGHT+IG7gdQAw+oeslVnzguZK2TIMhpef0hxhAEPXWwqvI6+kuFYWUJ2ovsUznhiSKBJx4JKvhicog== X-Received: by 2002:a05:6830:3b07:b0:72b:9506:8db1 with SMTP id 46e09a7af769-72bee5e2adbmr506572a34.4.1742241109722; Mon, 17 Mar 2025 12:51:49 -0700 (PDT) Received: from fedora ([2806:10ae:e:622a::3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-72bb2550a7fsm1746334a34.0.2025.03.17.12.51.49 for <77081 <at> debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 12:51:49 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= <eg642616@HIDDEN> To: 77081 <at> debbugs.gnu.org Subject: Re: bug#77081: [PATCH] New minor mode: `electric-block-comment-mode' In-Reply-To: <87cyefmonr.fsf@HIDDEN> References: <87cyefmonr.fsf@HIDDEN> Date: Mon, 17 Mar 2025 13:51:48 -0600 Message-ID: <874izrmo4r.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 77081 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.7 (/) --=-=-= Content-Type: multipart/alternative; boundary="==-=-=" --==-=-= Content-Type: text/plain I'm not sure how did this mail sent a CC to emacs-devel list. I'm sorry for the inconvenience. --==-=-= Content-Type: text/html <p> I'm not sure how did this mail sent a CC to emacs-devel list. I'm sorry for the inconvenience. </p> --==-=-=-- --=-=-= Content-Type: text/plain -- - E.G via GNU Emacs and Org. --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#77081
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 17 Mar 2025 19:40:40 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 17 15:40:40 2025 Received: from localhost ([127.0.0.1]:32797 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tuGKF-00008H-GY for submit <at> debbugs.gnu.org; Mon, 17 Mar 2025 15:40:40 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56738) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eg642616@HIDDEN>) id 1tuGKC-00007h-NC for submit <at> debbugs.gnu.org; Mon, 17 Mar 2025 15:40:37 -0400 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 <eg642616@HIDDEN>) id 1tuGK7-0003kt-95 for bug-gnu-emacs@HIDDEN; Mon, 17 Mar 2025 15:40:31 -0400 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <eg642616@HIDDEN>) id 1tuGK5-0002rw-6F for bug-gnu-emacs@HIDDEN; Mon, 17 Mar 2025 15:40:30 -0400 Received: by mail-oi1-x241.google.com with SMTP id 5614622812f47-3f94b7bd964so2745879b6e.1 for <bug-gnu-emacs@HIDDEN>; Mon, 17 Mar 2025 12:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742240427; x=1742845227; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=z3b3vyVH1V8xx17Ja9iP23/sCcCbjIUssdR6KiOhCx4=; b=PaI6CgrbFZRyXmukcn/BiU90LtEYc2XrdBjYrTgmU5HtRgS3J33h9Dx9XYVda4qRSj C6cF63sCbs647p6hAZC8+AektN7EYEsVCbiHLUsyjV7tgPKW4V1gP0GHejAccGicmCZd SWCzP68XJdrJtUVfeBOw1CfyW9yy/tYl6w8Wda20xg4pL4B7IxIKP1LpcgEDGCsw/tbB I4lO4wnp5e40Y2J/JJKUPaxYhKs7ZJPQ6L3a4DBzngvgphf/Zk/svbPwPm6JfFj4P3uw 9EdK5/TufukyUSnWoHwMeKSV5rNkmd9MuxMOQSZMYU/6Uacy6qGLR684bgOgQeYpB4Ke 8Z9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742240427; x=1742845227; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=z3b3vyVH1V8xx17Ja9iP23/sCcCbjIUssdR6KiOhCx4=; b=ZUkRX9xh50sTayndfixdVXjM8PMY84tFqxEUEthcFBwkP6QsOnm223GlknBqWvKABw Lmz2XkmvT/v23EyTDE9oIACBdGZa5v8ofLNI0P4FbJDM97EFu0EXudx8bc56wEeXwtrS 6xpQTJzkbklMp/f/t1XvhZumn40Qn6NJ60UTrln6M57o3uQXtHs5/eBA1fKpjvzNRCvo fq4HbrG38LWy90Z2B2GwuBCjuCz66/eEfWpaU2d4iuix0sLW1WQHkxf/BMn5ycgQG0XI JxSk1w9h7LkX/M+pZXFcjFk67IHrozRanuMHtOnQBSDkSYD0pFFssTGKugSja+HnyzKK TTbw== X-Gm-Message-State: AOJu0YyCYpIoFJBb0wUf9qUIITDsK74oSBQ+t8KU3tj8SxWFYh6k9kqL DewBtwso5hF2OpmyfzMelTmZ8NZS28qs2Urc6CNSTzqy3l/orhz8PkoYOD7d X-Gm-Gg: ASbGncvDNHmIhF1RKUl2Dj01KvxsDOV5eOdD32OTFjmCrXfl2B15IdrNtl7CukfE9FW E+/Mt+xWjPnhw9MTtgASvi4i579OxNy+RxMh885Cw/sMBCIOTvhaZMd3OgjH8A+fEovZtsLgZ1I lR1uqp7nOTkw7tA7kyUZVCEvrtnV9MyRw81+GkqgSYSpHt3tl1LSftZFQi4douWISypsvIe1N8L 9aVnQlPfPCBxkhRlJ2ePQW2ls29tevZhqr/0HuHB9xi6LYNoQBFcgEdsQVtBe0MbnD+xBBiGfCM dgdL0hrtoYzx X-Google-Smtp-Source: AGHT+IHOM0usIiARxA5wkcXDDH7H85+Dl1gNeXlRhkkbFekS1oh42GBjLqrRmSUnl0Fy1JBKA98FxA== X-Received: by 2002:a05:6808:220b:b0:3f9:f923:cc3c with SMTP id 5614622812f47-3fdee55a3afmr8274430b6e.4.1742240427272; Mon, 17 Mar 2025 12:40:27 -0700 (PDT) Received: from fedora ([2806:10ae:e:622a::3]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3fe832ce015sm1177840b6e.7.2025.03.17.12.40.26 for <bug-gnu-emacs@HIDDEN> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 12:40:26 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= <eg642616@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: [PATCH] New minor mode: `electric-block-comment-mode' X-Debbugs-Cc: emacs-devel@HIDDEN Date: Mon, 17 Mar 2025 13:40:24 -0600 Message-ID: <87cyefmonr.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::241; envelope-from=eg642616@HIDDEN; helo=mail-oi1-x241.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello, This minor automatically lets you close block comment when typing a block comment start. Thus... #+begin_src typing /* in c-mode automatically inserts */. Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (eg642616[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (eg642616[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org] 0.0 HTML_MESSAGE BODY: HTML included in message X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.2 (/) --=-=-= Content-Type: multipart/alternative; boundary="==-=-=" --==-=-= Content-Type: text/plain Hello, This minor automatically lets you close block comment when typing a block comment start. Thus... #+begin_src typing /* in c-mode automatically inserts */. electric-block-comment-mode: on /*| ^ cursor /* | */ ^ cursor Or in lua --[[ inserts ]]--. electric-block-comment-mode: on --[[| ^ cursor --[[ | ]]-- ^ cursor #+end_src and so on. *However, there is a problem,* This minor mode uses =block-comment-start= and =block-comment-end= variables, which most of the major modes do not use or define. The reason I decided to use these variables is because are more explicit with the type of comment that is used/supported. I would like to hear your feedback. --==-=-= Content-Type: text/html <p> Hello, </p> <p> This minor automatically lets you close block comment when typing a block comment start. </p> <p> Thus… </p> <div class="org-src-container"> <pre style="color: #FCFCFA; background-color: #2D2A2E; padding: 0.5em; border-radius: 5px;" class="src src-nil">typing /* in c-mode automatically inserts */. electric-block-comment-mode: on /*| ^ cursor /* | */ ^ cursor Or in lua --[[ inserts ]]--. electric-block-comment-mode: on --[[| ^ cursor --[[ | ]]-- ^ cursor </pre> </div> <p> and so on. </p> <p> <b>However, there is a problem,</b> This minor mode uses <code>block-comment-start</code> and <code>block-comment-end</code> variables, which most of the major modes do not use or define. </p> <p> The reason I decided to use these variables is because are more explicit with the type of comment that is used/supported. </p> <p> I would like to hear your feedback. </p> --==-=-=-- --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-minor-mode-electric-block-comment-mode.patch From 45414d4b0d47ddd9300fcc24723e0aa5e4efc8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= <eg642616@HIDDEN> Date: Mon, 17 Mar 2025 12:56:52 -0600 Subject: [PATCH] New minor mode: `electric-block-comment-mode' This minor automatically lets you close block comment when typing a block comment start. Thus, typing "/*" in c-mode automatically inserts "*/". * etc/NEWS: Add minor-mode item. * lisp/electric.el (electric-block-comment-post-self-insert-function): New function. (electric-block-comment-mode): New minor mode definition. --- etc/NEWS | 4 ++++ lisp/electric.el | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index b33f7cec73f..0924e86f691 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -111,6 +111,10 @@ If you have been using these variables in Lisp code (for example, in font-lock rules), simply quote the symbol, to use the face directly instead of its now-obsolete variable. +** New minor mode 'electric-block-comment-mode' +This mode automatically close block comment typed, thus typing +"/*" in c-mode automatically inserts "*/". + ** Network Security Manager (NSM) is now more strict. *** NSM warns about TLS 1.1 by default. diff --git a/lisp/electric.el b/lisp/electric.el index 39e13e1ca0c..c561d168883 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -731,6 +731,34 @@ electric-quote-local-mode (setq-default electric-quote-mode nil) ; But keep it globally disabled. ))) +;;; Electric comment block + +(defun electric-block-comment-post-self-insert-function () + "Function that `electric-block-comment' adds to `post-self-insert-hook'. +This closes block comment when a block comment start is typed." + (when (and block-comment-start block-comment-end + ;; Check if we are exactly behind the block comment start + (save-excursion + (re-search-backward (regexp-quote block-comment-start) + (- (point) (length block-comment-start)) + t)) + ;; And if there is not anything front us + (looking-at-p (concat "[^ [:space:]]"))) + (insert " ") + (save-excursion + (insert " */")))) + + +(define-minor-mode electric-block-comment-mode + "Toggle automatic close comment blocks (Electric Comment mode). + +When enabled, typing `block-comment-start' closes it inserting their +corresponding `block-comment-end'." + :group 'electricity + (if electric-block-comment-mode + (add-hook 'post-self-insert-hook #'electric-block-comment-post-self-insert-function 10 t) + (remove-hook 'post-self-insert-hook #'electric-block-comment-post-self-insert-function t))) + (provide 'electric) ;;; electric.el ends here -- 2.48.1 --=-=-= Content-Type: text/plain -- - E.G via GNU Emacs and Org. --=-=-=--
Elijah Gabe Pérez <eg642616@HIDDEN>
:emacs-devel@HIDDEN, bug-gnu-emacs@HIDDEN
.
Full text available.emacs-devel@HIDDEN, bug-gnu-emacs@HIDDEN
:bug#77081
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.