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: Re: Font lock question Date: Thu, 18 Mar 2021 20:41:03 +0100 Message-ID: <875z1ow866.fsf@fastmail.fm> References: <87a6r29hkl.fsf@fastmail.fm> <87r1kdx1ge.fsf@fastmail.fm> <87o8fhwyai.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="3195"; 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 Thu Mar 18 20:53:47 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 1lMyiH-0000ex-Lj for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 18 Mar 2021 20:53:45 +0100 Original-Received: from localhost ([::1]:36976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMyiG-0001Fy-MY for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 18 Mar 2021 15:53:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMyhj-0001FD-Un for help-gnu-emacs@gnu.org; Thu, 18 Mar 2021 15:53:12 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:51589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMyhh-0002l1-RD for help-gnu-emacs@gnu.org; Thu, 18 Mar 2021 15:53:11 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 449D012C6 for ; Thu, 18 Mar 2021 15:53:08 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 18 Mar 2021 15:53:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= references:from:to:subject:date:in-reply-to:message-id :mime-version:content-type; s=fm2; bh=u4rj1Slr+Cw0+FxfTdWoy4rl0n UivWjXksbg+8tHNMg=; b=TRj2Vw7enEcVIAviroh83qFbPCFRGc5CM67SQWIULN AY6/8biSWPsvYddUp95eHXaVXkwNTaP/pe4td6CwwsNgFnllVMpyC2GXpr2H5nT8 tR6/sw7RIcB2wf6rzbH7HGePwvgTQUbY4ndNC8MJLFXashomDjndwSOYKiPx9ojk meCir2scoWuDL48WNkuOMjEP/LVXa87UoMdYM4omuMnY7YMv5CTL06SQ8LYaPFdl aS0QYv1vC+lp5jmfC+QxrAnP1IsW/mC2C+z0uHZK4LFHK4co6zCMPRp7de3w7MTX DFhPLVN/3DRfbxeZ0zCEsc2ZohHcE52oBFOnG/aU+qaQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=u4rj1S lr+Cw0+FxfTdWoy4rl0nUivWjXksbg+8tHNMg=; b=jIXXuAKXmJ4w5um5XNBryB N6GEhrJYKkgtn4KfefLIz2q5c/GTDGGcfe4tRvvGzrTIoG70AszCcC1Co8ImqOo+ Dlsr9ntSpWs2it9BxiODfUevMHnFspcOw+EaaCek0hBzXzyxGp08+QmdkoMSQXuu w4BjV8hWHEaiyqAYxXux4PJaT+TX5PZjUaP3i98W0M/DcZMp4NfnKu+MmeBoqRld 9L5LLTwbfqW6Lhsws2BrimkjHEF/k/rgh672htVeN/iFov8/NEKeYCX3dZ/lNWh3 SCbbwm63fahN6RfdM1AiOUkNdsPv+P3/if75aFaTZrLPvf/autMgTTriQh0C1LaA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefiedgudefvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfhgfhffvufffjgfkgggtsehttd ertddtredtnecuhfhrohhmpeflohhoshhtucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgv mhgvrhhssehfrghsthhmrghilhdrfhhmqeenucggtffrrghtthgvrhhnpedviefhteeuve ekudetheduieehvdelgfeijeehvdetfeegleelhefhjeduieejveenucfkphepleehrdel uddrudeljedrheejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: from Swift.fastmail.com (ip5f5bc539.dynamic.kabel-deutschland.de [95.91.197.57]) by mail.messagingengine.com (Postfix) with ESMTPA id 305411080066 for ; Thu, 18 Mar 2021 15:53:06 -0400 (EDT) In-reply-to: Received-SPF: pass client-ip=64.147.123.20; envelope-from=joostkremers@fastmail.fm; helo=wout4-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_H4=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:128446 Archived-At: On Wed, Mar 17 2021, Stefan Monnier wrote: >>> But be aware that these approaches still won't work well if the [...] >>> thing can span multiple lines. >> Hmm, I'm afraid that is indeed possible. Perhaps I'll keep it simple and only >> font-lock the `B` part, since it can't contain any spaces and is fairly easy to >> do. > > Can there be [...] without any `aBc`s in them and which need to be > font-lock differently? There are. What I'm really trying to achieve is fontifying Pandoc-style citations in Markdown files. There are several other Markdown elements that use brackets, so perhaps Harald's suggestion to use the entire `[aBc` as an anchor is probably less error-prone. > If not (and if it shouldn't span too many lines), then I think > a MATCH-ANCHORED that just matches on the opening "[" and then uses the > PRE-MATCH-FORM to return the position of the matching "]" should work > acceptably, as long as you use `font-lock-multiline`. Even if they may occasionally span two lines, I assume citations will rarely span more than that, so font-lock-multiline may be an option. (Esp. given that `markdown-mode.el` does, as well.) -- Joost Kremers Life has its moments