From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime Newsgroups: gmane.emacs.help Subject: Re: Introducing face in comments for various modes Date: Tue, 13 Dec 2022 15:00:54 +0000 Message-ID: References: <9ZK1Solghrmps4AarUsz2E6-mAdkrTZoXPs4RTRTd9sZ0Cd8DGhK955im1kuug-EZXU3tc5rgDDd16vQexxpFnMvMFjFqnNnh0noashyLdE=@protonmail.com> <0icp58GJsK8dY-4h0rYl1g47IKcUW6zTIdHTpT6gRBXa24dgtBv86Vw2KlQPzBMBtEsHJBM6T1S-JX_xg8xrmQ8vXI1k7_OsdXnTX-_iNZE=@protonmail.com> <0413ccbf-68dd-a9f2-7541-1df84853cfd0@gmail.com> <3d77f749-9a47-3a87-40d0-7c7de73b64e7@gmail.com> <8l_TxrZOWrU4Lai_1kR-ks_IsA7skXlXEhi0pXQv1jQV_cDRKh6OrDbftOZoHRSK_rfcnzJjrRoasKPrViumWk51OaMFeSEFT_SIamfFXQY=@protonmail.com> <4c2ec873-8ca6-34b3-dc6b-dab47c03291d@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10416"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jean Louis , help-gnu-emacs@gnu.org To: Thibaut Verron Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 13 16:01:48 2022 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 1p56mx-0002T9-QC for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 13 Dec 2022 16:01:47 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p56mX-0004S7-A8; Tue, 13 Dec 2022 10:01:21 -0500 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 1p56mS-0004Qu-UE for help-gnu-emacs@gnu.org; Tue, 13 Dec 2022 10:01:17 -0500 Original-Received: from mail-4325.protonmail.ch ([185.70.43.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p56mO-0006uP-GP for help-gnu-emacs@gnu.org; Tue, 13 Dec 2022 10:01:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1670943663; x=1671202863; bh=nllFem17gIJ0BXKEYvnCH1iFUT6LCgByCwp/2faMQDQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=rvkd1Vfuh54oJCXIFDV1wNEhTqqKxX0LH5dNeokfneTlQOhwWTjRYXdm5oRWw6F2I xUaHgDDQyykhVPcDHptcNrW+hxwoKx9XatMv+qvn15oem8zOdyY1WO3UwMDoUAlmcE mEjBeHI+S194VMe/KxVQAhTThcZmDkj2ZOs0fG8G+eemrswivU3sqz2eTfIYt9DrOf Xx2hOefVJb63v3FDx5Qmy9ioEsrkgKaqq0+gT+LrE3oecdZs8G4E68o9hOHTaDMsg7 BQpzgkBX9a97bSrrlIfFXkqSGiG0uXRicpM+J+f6IEgX1Mop/liORdouGb4RxAfm+I +t+kjzpnF1VYg== In-Reply-To: <4c2ec873-8ca6-34b3-dc6b-dab47c03291d@gmail.com> Feedback-ID: 57735886:user:proton Received-SPF: pass client-ip=185.70.43.25; envelope-from=heimeborgia@protonmail.com; helo=mail-4325.protonmail.ch 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_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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:141719 Archived-At: ------- Original Message ------- On Tuesday, December 13th, 2022 at 10:45 AM, Thibaut Verron wrote: > On 13/12/2022 11:40, Heime wrote: >=20 > > ------- Original Message ------- > > On Tuesday, December 13th, 2022 at 10:05 AM, Thibaut Verron thibaut.ver= ron@gmail.com wrote: > >=20 > > > On 13/12/2022 10:46, Heime wrote: > > >=20 > > > > ------- Original Message ------- > > > > On Tuesday, December 13th, 2022 at 9:35 AM, Thibaut Verron thibaut.= verron@gmail.com wrote: > > > >=20 > > > > > On 13/12/2022 09:30, Heime wrote: > > > > >=20 > > > > > > ------- Original Message ------- > > > > > > On Tuesday, December 13th, 2022 at 8:04 AM, Heime heimeborgia@p= rotonmail.com wrote: > > > > > >=20 > > > > > > > ------- Original Message ------- > > > > > > > On Tuesday, December 13th, 2022 at 7:52 AM, Jean Louis bugs@g= nu.support wrote: > > > > > > >=20 > > > > > > > > Heime, I like the idea of highlighting comments, though I d= o it this > > > > > > > > way to specify (syntax comment-start) as that works for mul= tiple > > > > > > > > modes. > > > > > > > >=20 > > > > > > > > ; one > > > > > > > > ;; two > > > > > > > > ;;; three > > > > > > > > ;;;; and more > > > > > > > >=20 > > > > > > > > ;;; Highlighting comments > > > > > > > >=20 > > > > > > > > (setq rcd-regexp-comment (rx line-start > > > > > > > > (one-or-more (syntax comment-start)) > > > > > > > > (one-or-more space) > > > > > > > > (group (one-or-more not-newline)) > > > > > > > > line-end)) > > > > > > > >=20 > > > > > > > > ;; (highlight-regexp regexp nil 1) > > > > > > > > ;; (unhighlight-regexp regexp) > > > > > > > >=20 > > > > > > > > Jean > > > > > > > > I would like to introduce (syntax comment-start) in place > > > > > > > > of ";;" in "^;;\s+\\[.+\\].*$". > > > > > > > > It's not something you can "introduce" in your regexp, it o= nly makes > > > > > > > > sense within the context of a regexp built with rx: > > > > > > > > https://www.gnu.org/software/emacs/manual/html_node/elisp/R= x-Notation.html > > > > >=20 > > > > > Rewriting your regexp as an rx regexp would not be too difficult = if you > > > > > want to go that route, Jean's example is a good template. > > > > >=20 > > > > > Otherwise, as an approximation of that feature, you could built y= our > > > > > regex string using the value of the variable comment-start ( ";" = in > > > > > emacs-lisp-mode) instead of hardcoding ;; . > > > > > How can one specify two comment characters next to each other? > > >=20 > > > Using the variable, the same way you would normally do for a regexp, = by > > > putting \{2\} after the matched regexp. > > >=20 > > > E.g. > > >=20 > > > ELISP> (format "\\(%s\\)\\{2\\}" comment-start) > > >=20 > > > "\\(;\\)\\{2\\}" > > >=20 > > > (don't trust me for the number of escape characters) > > >=20 > > > But I don't think it's really what you want: for example, in a mode > > > where comment-start is "# " (e.g. org or python), this will match "# = # " > > > but not "##". > > > Let's disregard org and python at this time. =20 I do not think "python" comment character should be "# ", it is "#". At le= ast from what I have read about python.=20 =20 > Even then, avoiding the need to carefully count string expansions for > backslashes would be enough reason to use syntax tables for me. >=20 > > > Using the syntax table is better here, as the character # alone has t= he > > > syntax of a comment-start. > > >=20 > > > I had forgotten about the simplest option, that is the regexp equival= ent > > > of the rx syntax: \s< in a regexp will match exactly a character with > > > the syntax of a comment-start. > > >=20 > > > So: "\s<\{2\}" should be exactly what you want (at least in languages > > > where comments start with a single character).