From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: immerrr again Newsgroups: gmane.emacs.devel Subject: Bug in font-lock-syntactic-keywords handling? Date: Mon, 6 Oct 2014 15:42:19 +0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1412595775 14879 80.91.229.3 (6 Oct 2014 11:42:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Oct 2014 11:42:55 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 06 13:42:50 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xb6gi-00087a-Fh for ged-emacs-devel@m.gmane.org; Mon, 06 Oct 2014 13:42:48 +0200 Original-Received: from localhost ([::1]:51323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb6gi-0002f2-49 for ged-emacs-devel@m.gmane.org; Mon, 06 Oct 2014 07:42:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb6gL-0002dk-8W for emacs-devel@gnu.org; Mon, 06 Oct 2014 07:42:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xb6gH-00022i-Fv for emacs-devel@gnu.org; Mon, 06 Oct 2014 07:42:25 -0400 Original-Received: from mail-qg0-x236.google.com ([2607:f8b0:400d:c04::236]:55141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb6gH-00022M-Cd for emacs-devel@gnu.org; Mon, 06 Oct 2014 07:42:21 -0400 Original-Received: by mail-qg0-f54.google.com with SMTP id z107so3504433qgd.13 for ; Mon, 06 Oct 2014 04:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=YDaOVsa+ueUj8B2hH7bOeEjw48NVeyDiriH36gyX0do=; b=U6z3NL19ikI5Bf48NM7wCPjCJr1JBB+87DaHdLCmovEjJ0LJbOQeAx5AZgxiyzC7xr 3E+aU6t0r5LyAQQVJTgl3ryR3Q0yTvBsBV4UWqirKYVWDuIWExM43vtmSbfafbjCcx6K 9O4nyqppnIoFBKdbpRRF3wTiP5dHPeaQTFF/ELTPva13er4qZOyxy8CM0+mBJPpqjsCO PUwIL+ixI8AVBE2UPUbVFtETDiAI1sSKqXGXEtf7Z9kOyOgob+C+VMmE93IPNCzivpG6 hdbEZ1WoZnLmq7Dx3k8Q9/hY6dORcuThw4ZGdToI/VZIDcAwjNnSgGtG5sgjG+P+HwKy Yefw== X-Received: by 10.140.48.1 with SMTP id n1mr2030098qga.104.1412595739915; Mon, 06 Oct 2014 04:42:19 -0700 (PDT) Original-Received: by 10.140.98.148 with HTTP; Mon, 6 Oct 2014 04:42:19 -0700 (PDT) X-Google-Sender-Auth: jc1Jw-AAtwdpkr3mOhCmk8F8KJ8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:175010 Archived-At: Hi all I've run into an interesting issue with syntactic fontification with lua-mode: it uses font-lock-syntactic-keywords to mark up long-strings and long-comments as advised earlier in this list [1] and there has been a report that this approach failed on a certain file [2]. It looks like that initial fontification indeed fails on that "connection.lua", but after-change refontification works fine. In a nutshell, the problem is that font-lock-syntactically-fontified is only moved forward when font-lock-syntactically-fontified < start. Which means that when you first propertize [s0; s1) and then propertize [s1, s2), font-lock-syntactically-fontified will still be at s1 which is clearly inconsistent. Let's look at the initial fontification of the file I've referenced above that exhibits that behaviour (messages are annotated with their respective line numbers according to [3]): =========== 1212: unfontify-region: [1; 520] 1217: font-lock-syntactically-fontified: 0 1217: start: 1 1218: moving start to 1 1219: set font-lock-syntactically-fontified: 520 1220: font-lock-fontify-syntactic-keywords-region: [1; 520] ============ 1212: unfontify-region: [520; 1082] 1217: font-lock-syntactically-fontified: 520 1217: start: 520 1220: font-lock-fontify-syntactic-keywords-region: [520; 1082] ============ 1212: unfontify-region: [1082; 1583] 1217: font-lock-syntactically-fontified: 520 1217: start: 1082 1218: moving start to 520 1219: set font-lock-syntactically-fontified: 1583 1220: font-lock-fontify-syntactic-keywords-region: [520; 1583] As you can see, for the third iteration start moves back to the beginning of the second chunk and it tries to re-propertize it without unfontifying which causes an bug in lua-mode's syntactic keyword handling. I do know that I (ab-)used a deprecated variable to maintain compatibility with Emacs23 and using `syntax-propertize-function` should fix that for Emacs24, but I'd be grateful if anyone pointed me to a simple fix for Emacs23. Cheers, immerrr 1. http://comments.gmane.org/gmane.emacs.devel/153447 2. https://github.com/immerrr/lua-mode/issues/78 3. http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/font-lock.el#n1212