From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Serghei Newsgroups: gmane.emacs.devel Subject: Re: Font Locking issue: Need help/advice Date: Sun, 05 Apr 2020 14:37:05 +0000 Message-ID: References: <25fe76a8-025a-be67-8a28-3ac711f07766@protonmail.ch> <877dyw2o3a.fsf@randomsample> Reply-To: Serghei Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="87978"; mail-complaints-to="usenet@ciao.gmane.io" Cc: GNU Emacs Developers To: David Engster Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Apr 05 16:38:00 2020 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 1jL6PQ-000Mnf-H4 for ged-emacs-devel@m.gmane-mx.org; Sun, 05 Apr 2020 16:38:00 +0200 Original-Received: from localhost ([::1]:48458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jL6PP-0004Gu-KY for ged-emacs-devel@m.gmane-mx.org; Sun, 05 Apr 2020 10:37:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33724) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jL6Oi-0003qU-ND for emacs-devel@gnu.org; Sun, 05 Apr 2020 10:37:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jL6Og-0004Hi-H1 for emacs-devel@gnu.org; Sun, 05 Apr 2020 10:37:15 -0400 Original-Received: from mail2.protonmail.ch ([185.70.40.22]:44568) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jL6Of-0004Fg-60 for emacs-devel@gnu.org; Sun, 05 Apr 2020 10:37:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.ch; s=default; t=1586097428; bh=5ZSB2tEt574I1qaffY6M9sTYBck3XO8VJZPQPyOikGU=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=uVNltTeI/Ijf2bGbHBdtw/uAIZhzH864kN7ff0VZHBI6SP32jlY/sfPYqRILBsGsh IQtAAb614FdOBPzggWbLWbMspl7Bj2Di4GaWfdrmEdROju3Vs9gkoE51kvCUzzwwS0 D4cJNdJY78SfUa7hNvOESbwfL8PL1qFkn2o4KdEs= In-Reply-To: <877dyw2o3a.fsf@randomsample> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 185.70.40.22 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:246461 Archived-At: > > - What happens on the GIF? How I can fix this? How to avoid similar > > in the future? > > > > What happens here is that the initial font-lock goes over the whole > currently visible section, but as soon as you edit one line, font-lock > will be called only for the part of the buffer that has changed, and it > seems your font-lock rules work differently in this case because the > context has changed. Although I didn't receive answers to all my questions in this thread, your suggestion about inconsistent font-lock rules turned out as a clue. I found that even if I delete all other font-lock rules (except this one), the problem will still remain. And I decided to refactor it from scratch. After more careful refactor of this anchored font-lock matcher, I was able to optimize some of its parts [1]. Now it works as expected. Thanks for the tip! Well, parsing complex context sensitive languages with a bunch of very weak regexes is not a good idea. Anchored font-lock matchers certainly help but still seem like a complicated approach. > For better understanding how font-lock actually works, I highly > recommend using font-lock-studio > > https://github.com/Lindydancer/font-lock-studio I have heard about this package several times over the past few years. However, I still lack some simple instructions on how to find font-lock issues using this package. Perhaps a small guide with an example of finding font-lock problems would help. [1]: https://github.com/zephir-lang/zephir-mode/pull/28/commits/52ff40451b5= 65d3f4a10b30e9c71e136b7d60021 -- Serghei