From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thibaut Verron Newsgroups: gmane.emacs.help Subject: Re: Introducing face in comments for various modes Date: Tue, 13 Dec 2022 11:45:19 +0100 Message-ID: <4c2ec873-8ca6-34b3-dc6b-dab47c03291d@gmail.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12038"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: Jean Louis , help-gnu-emacs@gnu.org To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 13 11:46:47 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 1p52oA-0002sp-VK for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 13 Dec 2022 11:46:47 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p52mt-0003hb-GJ; Tue, 13 Dec 2022 05:45:27 -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 1p52mq-0003hG-PA for help-gnu-emacs@gnu.org; Tue, 13 Dec 2022 05:45:25 -0500 Original-Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p52mo-00008Q-HS for help-gnu-emacs@gnu.org; Tue, 13 Dec 2022 05:45:24 -0500 Original-Received: by mail-wm1-x332.google.com with SMTP id n9-20020a05600c3b8900b003d0944dba41so7599760wms.4 for ; Tue, 13 Dec 2022 02:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=L09f2vooMtywhygsi/DOf63WDdaRBbDl4wPF5qtluJo=; b=A0KWDRM47tKfqvCIBk7lzsR4N2osIjz5pr/iC75QwKDOa8cmXkwJPsVK83Ls8gf9sW 3gq/8TtVPa1H3wfXi6KicjWscgG9/c7g85tCOokhDt0yF+vpDDAwVfKV3LLxAMzXA3/3 KK2rl9EAOR3T6dmRwTpJPixiiomcn0ZuhbI1uTzfF1DFiztbGO6XZsfLWK62SCcJ+RD3 09Cp3Rnkk1Ygo4X/NXL+f7Cby1u1DbVTN621h9MTbBlKtZ4wQaOoz2BlwON4d6SpzQL1 CmPv0asdnof6EHf92j4zXzKgoaPw2RbYSQsouK0Z6JQ+xCrEmtotsO7ba1VymaAFcUQC kXzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L09f2vooMtywhygsi/DOf63WDdaRBbDl4wPF5qtluJo=; b=rLsLHjY0uUzqjD4AE/7Yxf50XUsHncUt0L+VzfOAv+i/x6x637rwPecyrfcbz2ykx2 tF/+n2iYchYk6uAcqRDKY8E8iq0ZRoqrZlRNZuLBpBC/UPsenIHHrlQRYAOfCy6valAC BdAVttINk5cEhGTppheA6h7Pt4Ejq5Zjuy/NEqKeGOPR8a1J3A/9o3puyzW3iq7cyb/A dW2/RCUM5hnFVQSdGluNFo3mAvFovveyj/5wYafcrEMQ2sreX9NepzmQh53KAMQhgYwD +VOmGDnMrTQlW+q0KXUjuI4cbz9goTnEDFa02oJWi88vSxeOQiEcul6C3nUXisIgzM1K dhpw== X-Gm-Message-State: ANoB5pnv9EC27+s1/DT9P5nyhOg8i1ctIMI1rzDevduvTWkcWTMwwhfx GE2+1AgqFz4siHPFJHaYNto= X-Google-Smtp-Source: AA0mqf521xc9nQa221yUB2tdX+RLOtfl6nIv3c09a+xkU3Z7inOS8tbsBhxUUB1uwS48oIiM//dx9Q== X-Received: by 2002:a05:600c:991:b0:3cf:ab99:6b46 with SMTP id w17-20020a05600c099100b003cfab996b46mr14494213wmp.35.1670928320848; Tue, 13 Dec 2022 02:45:20 -0800 (PST) Original-Received: from ?IPV6:2001:628:2010:4094:4818:8cf9:4bb1:650a? ([2001:628:2010:4094:4818:8cf9:4bb1:650a]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c4f8800b003d1e90717ccsm14063048wmq.30.2022.12.13.02.45.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Dec 2022 02:45:20 -0800 (PST) Content-Language: en-US In-Reply-To: <8l_TxrZOWrU4Lai_1kR-ks_IsA7skXlXEhi0pXQv1jQV_cDRKh6OrDbftOZoHRSK_rfcnzJjrRoasKPrViumWk51OaMFeSEFT_SIamfFXQY=@protonmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=thibaut.verron@gmail.com; helo=mail-wm1-x332.google.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, NICE_REPLY_A=-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-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:141706 Archived-At: On 13/12/2022 11:40, Heime wrote: > ------- Original Message ------- > On Tuesday, December 13th, 2022 at 10:05 AM, Thibaut Verron wrote: > > >> On 13/12/2022 10:46, Heime wrote: >> >>> ------- Original Message ------- >>> On Tuesday, December 13th, 2022 at 9:35 AM, Thibaut Verron thibaut.verron@gmail.com wrote: >>> >>>> On 13/12/2022 09:30, Heime wrote: >>>> >>>>> ------- Original Message ------- >>>>> On Tuesday, December 13th, 2022 at 8:04 AM, Heime heimeborgia@protonmail.com wrote: >>>>> >>>>>> ------- Original Message ------- >>>>>> On Tuesday, December 13th, 2022 at 7:52 AM, Jean Louis bugs@gnu.support wrote: >>>>>> >>>>>>> Heime, I like the idea of highlighting comments, though I do it this >>>>>>> way to specify (syntax comment-start) as that works for multiple >>>>>>> modes. >>>>>>> >>>>>>> ; one >>>>>>> ;; two >>>>>>> ;;; three >>>>>>> ;;;; and more >>>>>>> >>>>>>> ;;; Highlighting comments >>>>>>> >>>>>>> (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)) >>>>>>> >>>>>>> ;; (highlight-regexp regexp nil 1) >>>>>>> ;; (unhighlight-regexp regexp) >>>>>>> >>>>>>> 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 only makes >>>> sense within the context of a regexp built with rx: >>>> https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Notation.html >>>> >>>> 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. >>>> >>>> Otherwise, as an approximation of that feature, you could built your >>>> 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? >> >> Using the variable, the same way you would normally do for a regexp, by >> putting \{2\} after the matched regexp. >> >> E.g. >> >> ELISP> (format "\\(%s\\)\\{2\\}" comment-start) >> >> "\\(;\\)\\{2\\}" >> >> (don't trust me for the number of escape characters) >> >> 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. > Even then, avoiding the need to carefully count string expansions for backslashes would be enough reason to use syntax tables for me. >> Using the syntax table is better here, as the character # alone has the >> syntax of a comment-start. >> >> I had forgotten about the simplest option, that is the regexp equivalent >> of the rx syntax: \s< in a regexp will match exactly a character with >> the syntax of a comment-start. >> >> So: "\s<\{2\}" should be exactly what you want (at least in languages >> where comments start with a single character).