From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Sam Halliday Newsgroups: gmane.emacs.devel Subject: possible bug in anchored font-lock functions Date: Sun, 11 Nov 2018 14:26:03 +0000 Message-ID: <87r2frg078.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1541948194 11713 195.159.176.226 (11 Nov 2018 14:56:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Nov 2018 14:56:34 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 11 15:56:30 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLrA4-0002ur-Rp for ged-emacs-devel@m.gmane.org; Sun, 11 Nov 2018 15:56:29 +0100 Original-Received: from localhost ([::1]:42452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLrCA-00036M-MD for ged-emacs-devel@m.gmane.org; Sun, 11 Nov 2018 09:58:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLqgr-0002Lq-QI for emacs-devel@gnu.org; Sun, 11 Nov 2018 09:26:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLqgl-0000oI-Rl for emacs-devel@gnu.org; Sun, 11 Nov 2018 09:26:17 -0500 Original-Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:54886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gLqgk-0000mb-3A for emacs-devel@gnu.org; Sun, 11 Nov 2018 09:26:10 -0500 Original-Received: by mail-wm1-x332.google.com with SMTP id r63-v6so6053617wma.4 for ; Sun, 11 Nov 2018 06:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=qCKKnrxI5HkcfB8edVgG31HmKKulwvnKTMsQRUYBVnQ=; b=cqJGSOtD2b3u41U8dlC116YEIEzUeN34++y1npNJvQR4FcdfpdDPN+JRwxXlX7zY3E NpD7NNvN5UEmVnGwJhuqQ0HTdDsU9WBzzaZCl+qxs31aP1asjrdj52+YJUlNT41g86sR 0JZ6tvQzTNQXppjeAQ8al58vq8NubLn6LWDlMOlE2AnuiwFvlqSiyrJJD2nf1Lf1o9cK Nul+HXHj/mdnpAK0yzKWLg+uhYdmZVvlikc4gb7cQqu3ClV/qrTFOdtVbaY4B9j7WVwn NTw/XiA7z8tGuvj+ST37A6fZnhuiJeQFv9CS8oKGEH2/MwWysBaCKWa6wSw+pKbGXWc0 ORVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=qCKKnrxI5HkcfB8edVgG31HmKKulwvnKTMsQRUYBVnQ=; b=MrjTv3dUeqheUCPG+xsMRK3D1vy2JYZhKQ3fGmSOAisOtjTxo/G6b2LS9fte9elMSn a3yCVpeBAFdPXaAe6hcrAmEI05DSkS7EoC/X2PWXJDqcBoy1lvk3zll/hRglKWwygfen aozjvjLp+8jmqUYXOFGmg19exALItmHX3q61/PCY/3GIx9uOVl5mvhDAHCQGv6fGyzAo zg6X9RipTSOTjvHE/GywyYRP3WqgGg0et6gh4XsSdI84Reo6z/p7wGHGH1dw5AK77sON k/9+hY+4pA2Sfqqb8Vdcq27E4QFjB7tUt9PzbAG8E23PxCrBy11knGgSpT8MBM58BwQ4 UuAw== X-Gm-Message-State: AGRZ1gJEWVZ0HYpxkmxqAVjagCI9AWP+JNMMkZpdf7VQ87dQFjgIOL17 OyFdzD+QXSzzIOfLQrmnQgWYcgsb X-Google-Smtp-Source: AJdET5dATcGULAlbdTwxY2dlpjXDQ5tLyfdYJ+av+nvRMXAymPAwMFrzUyWia3J4bmB+5uf3KjnskA== X-Received: by 2002:a1c:1807:: with SMTP id 7-v6mr4853548wmy.29.1541946367680; Sun, 11 Nov 2018 06:26:07 -0800 (PST) Original-Received: from Samurai (host86-183-172-189.range86-183.btcentralplus.com. [86.183.172.189]) by smtp.gmail.com with ESMTPSA id j203-v6sm10617160wmd.46.2018.11.11.06.26.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Nov 2018 06:26:06 -0800 (PST) X-Google-Original-From: Sam Halliday X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 X-Mailman-Approved-At: Sun, 11 Nov 2018 09:58:32 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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:231072 Archived-At: --=-=-= Content-Type: text/plain Dear all, I think I might have found a bug in GNU Emacs but I would like to check my understanding first, before filing a report or (ideally) fixing it. In Search Based Fontification[1] it is possible to specify a function as a matcher. It must obey the following contract: > it receives one argument, the limit of the search; it should begin > searching at point, and not search beyond the limit. It should return > non-nil if it succeeds, and set the match data to describe the match > that was found. Returning nil indicates failure of the search. In addition, it is possible to extend the region to be fontified by adding a routine to `font-lock-extend-region-functions` that in-place updates the `font-lock-beg` or `font-lock-end` variables (these variables are not visible in a function matcher). Let's ignore `font-lock-multiline` property approaches, I'm not using them. Indeed, I have confirmed that if I extend the region in a `font-lock-extend-region-functions` then the `limit` does increase for my function matcher! However, if I use an an `anchored` matcher, having the form `(matcher . anchored-highlighter)`, where the `anchored-highlighter` is a `function`, my custom `font-lock-{beg,end}` regions are ignored and `limit` is much reduced! Is there something I need to do so that anchored matchers receive the calculated regions or are they only designed to extend to the end of the current line by default? If I had to guess I'd say the anchored matcher is forgetting to use `font-lock-{beg,end}` and is instead calculating a new limit or using a cached version of the limit from before `font-lock-extend-region-functions` ran. I would greatly appreciate it if somebody could please point me to the source code in GNU Emacs where the `font-lock-keywords` are called for anchored matchers. I suspect the limit is also broken for `regexp` matchers, not just `function`, but I have no way of printing out `limit` in that case. A final note, this is the first time I've written a syntax-table and font-lock for a programming language, and I have found the experience to be much more pleasant than I expected! The font-lock-keyword API is lovely to work with and I've been using the rx macro to avoid writing regexps by hand... my code reads like a simplified BNF description! --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable [1] https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Search_0= 02dbased-Fontification =2D-=20 Best regards, Sam --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQTrVS7VRt8l2pBJU9SHlDipUv0byQUCW+g7+wAKCRCHlDipUv0b yf1xAJoD6it/aAaIz0N5NqStRSAewBL7lQCdFSLAVz/SMExhfDs+TD8Uurlt2cM= =pRd8 -----END PGP SIGNATURE----- --==-=-=-- --=-=-=--