From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.devel Subject: Re: Font lock in org+elisp confused with ?\[ Date: Thu, 1 Apr 2021 11:04:11 +0200 Message-ID: <20210401090411.GB16534@tuxteam.de> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="oLBj+sq0vYjzfsbl" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16403"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Tom Gillespie , emacs-devel@gnu.org To: Arthur Miller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 01 11:08:16 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 1lRtJI-0004Bd-Aj for ged-emacs-devel@m.gmane-mx.org; Thu, 01 Apr 2021 11:08:16 +0200 Original-Received: from localhost ([::1]:52594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRtJH-00006k-Aq for ged-emacs-devel@m.gmane-mx.org; Thu, 01 Apr 2021 05:08:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRtFc-0005Sn-8r for emacs-devel@gnu.org; Thu, 01 Apr 2021 05:04:28 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:33982) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.90_1) (envelope-from ) id 1lRtFV-0004XX-E7 for emacs-devel@gnu.org; Thu, 01 Apr 2021 05:04:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:Date; bh=w85BkotLs7LZ5LlfgAA1pL8NyDt8f5IW3X7fN6ou6aA=; b=RJOz9cGMkFAwpIX9DOQ2zT31T+5Oikcn9yg9d/oVzPmYswAOU4m5yk7rf8cUAZJyRNLsplo+pxsFFvPbQP3qOhSgmLNmDtPbt/l4PmjBc7ETfEgyFp9cwqZGgNtVNA7jV7xe5eDtMR+VKLYCrXGqiK+aVWP620/BQ6u76cempV9ZpF4XDSoEhuCFEReygXxN7f4ygRi/A6QOB2L64ji2gwwrfmXc8SqcssDurZU2a6dPvdw4U1vmIl7JDZ9l6xFoBZSjoK8P1q/46jktah5VYQNo81VZsmskxfJz71iDgepIzREs1ipyCe7bWP90SzmcAIvdaNa+W8DffRF6n5gk/w==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1lRtFL-00063f-2j; Thu, 01 Apr 2021 11:04:11 +0200 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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:267244 Archived-At: --oLBj+sq0vYjzfsbl Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 01, 2021 at 09:18:30AM +0200, Arthur Miller wrote: > Tom Gillespie writes: >=20 > > This is a known issue with org babel blocks. It is due to the fact > > that org babel translates the font locking for the language but not > > the syntax propertization. Another frequent cause is the bash case > > statement. The end result is that unmatched parens leak out from the > > babel blocks and wreak havoc elsewhere in the org file unless you > > balance out the parens e.g. in a comment. I have a hacked fix for > > this, but it has horrible performance, especially with line numbers > > enabled. I think that a proper solution would run arbitrary syntax > > propertization on subsets of a buffer without having to continually > > check where those subsets start or end. Best, > > Tom >=20 > Thanks for the explanation! >=20 > I don't know how org-babel works, I guess it opens another buffer, > font-locks syntax there and copy it over? What was the reason why they > don't copy other properties? Performance or something else? Hm. I've just poked around a bit. If you are talking about babel blocks, I think the entry point is `org-src-font-lock-fontify-block', defined in `org-src.el'. And indeed, this function basically does this (with a lot of corner-case chasing around, as is usual in our trade): (let ((lang-mode (org-src-get-lang-mode lang))) ... (with-current-buffer (get-buffer-create (format " *org-src-fontification:%s*" lang-mode)) ...)) The rest is left to the reader's fantasy, as they say :) Cheers - t --oLBj+sq0vYjzfsbl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAmBljIsACgkQBcgs9XrR2kY04QCdHaSXdzf/yU0TWVC9CaZ1rKny hesAnAyTnYSOhMLeb7tzJQAyoZ4hlrow =z8qw -----END PGP SIGNATURE----- --oLBj+sq0vYjzfsbl--