From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Font lock question Date: Wed, 17 Mar 2021 10:40:32 +0100 Message-ID: <87a6r29hkl.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4152"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.8; emacs 27.1.91 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 17 11:54:31 2021 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 1lMTos-0000xl-A0 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Mar 2021 11:54:30 +0100 Original-Received: from localhost ([::1]:34972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMTor-0003QD-A8 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Mar 2021 06:54:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMToW-0003Q1-JV for help-gnu-emacs@gnu.org; Wed, 17 Mar 2021 06:54:08 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:36037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMToU-00016L-Qc for help-gnu-emacs@gnu.org; Wed, 17 Mar 2021 06:54:08 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id BBFCF5C0115 for ; Wed, 17 Mar 2021 06:54:04 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 17 Mar 2021 06:54:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:subject:date:message-id:mime-version:content-type; s= fm2; bh=hZ/Emrtcj3gh4cKEqWMb0BTPgcleyonMKp6FF+QJE7o=; b=UeJaXwbs M6zFFbK+wdT5haU4n6I16PwZYGLb1tGcNtFJX5K9EIWHsrhXUyZeWe42HcABj92w 7ti749suILowOgR0okBy9eAqhfn6Ucn8YqrbeZKYK0VaVxGSEuBctWJ9Kov0ClkC xQpFFoqrqsqYBuKELtCWeprNL63oIhoKmKV+UqRQY1n6qG3Y63ayaQTNk0q5OTXI WkoZRzeArI/5JODu8pXQ+VrXdqVxYFCMwVJxTTTQjvOuWMT7ERRmwo2SrboitzzM uZu6LkNVU9Xf2LrpFJZEvnkLYfhMLpJctY0Si8FgTB+8ao/fhCKfQAXvH/MIbMTJ 3HTMvkVxkiNZ4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=hZ/Emrtcj3gh4cKEqWMb0BTPgcley onMKp6FF+QJE7o=; b=ROEcmgDesPM+CBdlZK88VKt+QfNh6xrePMDA6RxfNQYM3 BAXeveqHq5hFy0583+OPxSC/Q6/wKgfmcdOrQR88NaYYvZsfhgIN0uSr2qNPSe1u OwemqBksKcEoMulB9C3XZ6tpIA/wfhd+tiKvsRVD4exvbqdkHZ0P82nFmA7G8/zh Hca2KiEgYtDKsCz8NPi3CAPzsJgiwV0m3F9QcKfxinhCi/jsNBj+y7E3escCpdSH ++9CXQRrAxx28vAv+qGj8Hr0ryzLoN49/irUOvZLIGheB8YY0HsYhq9eNICGkg52 M/febHoFo6SLlPbbW76fOUMYWB+zEKUtqGSXqRS5w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefgedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpegfhffvufffkfggtgesthdtredttd ertdenucfhrhhomheplfhoohhsthcumfhrvghmvghrshcuoehjohhoshhtkhhrvghmvghr shesfhgrshhtmhgrihhlrdhfmheqnecuggftrfgrthhtvghrnhepudeufedttefgleekhe eihfegtdelvdeutddvvedukedtieffiefhgfdvhfdtudefnecukfhppeelhedrledurddu leejrdehjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: from Lenovo.fastmail.com (ip5f5bc539.dynamic.kabel-deutschland.de [95.91.197.57]) by mail.messagingengine.com (Postfix) with ESMTPA id EFB871080066 for ; Wed, 17 Mar 2021 06:54:03 -0400 (EDT) Received-SPF: pass client-ip=66.111.4.28; envelope-from=joostkremers@fastmail.fm; helo=out4-smtp.messagingengine.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 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" Xref: news.gmane.io gmane.emacs.help:128428 Archived-At: Hi list, I'm trying to add font lock rules to a package of mine and I'm running into an issue that I can't figure out how to solve. Schematically, I'm trying to match instances of the following type: [aBc] Here, the square brackets are obligatory and so is the `B`. `a` and `c` are optional. `B` can be recognised by its form, `a` and `c` can only be recognised by the fact that they are in between the opening/closing bracket and `B`. So far, so good. But the complication is that this pattern of `aBc` can be repeated *within the brackets*, where each instance is separated by a semicolon: [aBc; aBc; aBc] There is no (theoretical) limit to the number of repetitions. I have no trouble composing a regex that matches this entire thing. I'd add a shy group that includes an optional semicolon and that is repeated at least once: \[\(?:\(?1:.*?\)B\(?2:.*?\);?\)+\] However, this does not work for font-lock, it seems. At this point, I'm unsure what to try next. Is there a way to deal with such patterns? TIA Joost -- Joost Kremers Life has its moments