From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Fontification using a syntax tree Date: Sat, 18 Sep 2021 14:14:35 -0400 Message-ID: References: <87bl4pc2tq.fsf@hugot.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8730"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Sep 18 20:16:13 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mResm-00023d-OC for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Sep 2021 20:16:12 +0200 Original-Received: from localhost ([::1]:55050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mResk-0005xV-Kn for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Sep 2021 14:16:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRerJ-0005AF-O6 for emacs-devel@gnu.org; Sat, 18 Sep 2021 14:14:41 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:10823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRerH-0006Oj-2N for emacs-devel@gnu.org; Sat, 18 Sep 2021 14:14:40 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3AEE4441171; Sat, 18 Sep 2021 14:14:37 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id DD06244115A; Sat, 18 Sep 2021 14:14:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1631988875; bh=xz5u+BArYlzeoli/L69WdcAA6KXImw9RjYWNQ4n1HTw=; h=From:To:Subject:References:Date:In-Reply-To:From; b=HojM8L20Z8n7r9F1hXbG7kfm2A+nWnX4vgKzz/QbDQtPWj5SgxOqcjqSrw0KQNXOn voOAHqzNyrE+YEqLFP448wDEDtCPwA8N2OU+rF3tF/9XvPooulPUqWmhym/eM1ghqt Vav7aubJ3xvKEk4Kt7TcFyar8aGwUNzhyl6y2VrRznlfz2cWoJGOiI0QWaLxvTaZj6 BDsvdDzBB2Li+i5AfFLGs+utodhih+nVCB9VVMytrMY8499sIIi18txjeSqHOyk0ZR CGESqNwzEALWr9ZrcM1U3S7Ob99YA+IcVQe2wekHBHTLNajjCgT90f0xNVk43/LLAw nIk+h1S8NPFOA== Original-Received: from pastel (unknown [45.72.241.23]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9895C12044D; Sat, 18 Sep 2021 14:14:35 -0400 (EDT) In-Reply-To: <87bl4pc2tq.fsf@hugot.nl> (Hugo Thunnissen's message of "Sat, 18 Sep 2021 15:37:21 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:275024 Archived-At: > is, how should I go about doing this? From what I understand, font-lock > works with syntax tables, but if I use a syntax table for font-lock, I'm font-lock has various parts. One part uses the syntax table to highlight comments and strings. This can be disabled by setting `font-lock-keywords-only`. Another part is the one that obeys `font-lock-keywords` and these happily accept rules that consist of delegating the work to a function. IOW you can just say (defconst foo-font-lock-keywords `((,#foo--fontify-upto))) (defun foo--fontify-upto (limit) ... Fontify between point and LIMIT ... ;; Return nil to tell font-lock that you're done. nil) (define-derived-mode ... ... (setq-local font-lock-defaults '(foo-font-lock-keywords t)) ...) -- Stefn