From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Limits of multiline font-lock Date: Mon, 16 Sep 2019 15:00:17 -0400 Message-ID: References: <87impuu7qy.fsf@web.de> <87sgoxjgpb.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="129985"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Emacs Development To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 16 21:01:52 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i9wG0-000XYV-IQ for ged-emacs-devel@m.gmane.org; Mon, 16 Sep 2019 21:01:52 +0200 Original-Received: from localhost ([::1]:39372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9wFz-0006eM-8K for ged-emacs-devel@m.gmane.org; Mon, 16 Sep 2019 15:01:51 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43829) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9wEl-0006ZQ-M3 for emacs-devel@gnu.org; Mon, 16 Sep 2019 15:00:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9wEe-0000G6-Pi for emacs-devel@gnu.org; Mon, 16 Sep 2019 15:00:35 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19604) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i9wEd-0000Cv-TX for emacs-devel@gnu.org; Mon, 16 Sep 2019 15:00:28 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5D73183B32; Mon, 16 Sep 2019 15:00:25 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E0E0F80BD0; Mon, 16 Sep 2019 15:00:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1568660418; bh=6m1uvvP0bxPkak0amVoe0GCaVGRwv8Og15EyvikyxHo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=CRD2pmoxrM9XBUCSCAWCdO6U2LLHi6DrcdbChtYZiDOC4t/dz6dGClY4TpAvv79H8 V6FBnOVWGkNPuKQpd8q/sSfgU6QEq8ZZZpjcf59xP6iBJLOWIGcmwV2Xv1lQIbTdQZ ZQjwYSNv2PcO9WF4+m2ex0s92xg6oHN555Tn9KbXThTCVhAg94jGIOTtVAAQW58KyH F6zRyqn33GcNrB3hD9p5hAw3z6LNHmyXt9GqMN+VRij3JTUBftxIyHUWC0Jp7OEJ7z OzU4ZVOiykNu8/1qCnpiZt0LvoG2vkS/ikTpB/JJY7RWKab7hHy8HfEG22h2+cm+vS HVNcdDAEgSOfg== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C5B8F120175; Mon, 16 Sep 2019 15:00:18 -0400 (EDT) In-Reply-To: <87sgoxjgpb.fsf@web.de> (Michael Heerdegen's message of "Mon, 16 Sep 2019 01:13:52 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240082 Archived-At: > Matches are always limited by bounds of the current top-level > expression. A complete re-search from the beg-of-defun of window-start > up to window-end after a change is sufficient and doable in acceptable > time (in your concrete scenario, I could even restrict the search to all > parent sexps the edited text is in - most of the time these will no ever > be more than 20 or so...these can be tested very quickly). Good. > I already have a prototype (not based on font-lock), and it starts > refontification only after a (tiny) idle time, and the search function > is interruptable (via throw-on-input). When interrupted, the old > visible state is restored. > > This works quite nicely and feels quite natural unless the search > pattern is very costly (then I currently emit a warning - the pattern > could also remove itself from the list or turn the minor mode off). This makes it sound like you don't want to do it "synchronously" like font-lock, but rather asynchronously (from a timer). I'd tend to agree (tho arguably, font-lock should also be done asynchronously ;-). > The tricky rest is now stuff that font-lock already does well. My > current implementation has problems with cases like when different > (maybe overlapping) parts of a buffer are visible in different windows, > there is a certain risk of infinite retriggering of hi-locking etc. I think if you use jit-lock-register to be told about areas that need to be (re)searched, keep them in a side-data-structure (or as text-properties), and then in the timer you simply process this side-data-structure, you should naturally avoid infinite retriggering of hi-locking (assuming you're using either overlays for the actual highlight, or you're using with-silent-modifications to avoid needlessly retriggering jit-lock). Stefan