[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cc-mode fontification feels random

From: Ergus
Subject: Re: cc-mode fontification feels random
Date: Wed, 16 Jun 2021 00:38:15 +0200

Hi Stefan:

Finally anyone wrote to the emacs-tree-sitter module package to request
them to join to elpa and do the paperwork?

On Mon, Jun 14, 2021 at 10:39:49AM -0400, Stefan Monnier wrote:
It is undocumented practice to steadily undermine the role of
`open-paren-in-column-0-is-defun-start' in all modes with
`beginning-of-defun' the only place left where it currently has any

You seem to attribute malice to the perpetrators (e.g. yours truly ;-).

Here's my reasoning:

`open-paren-in-column-0-is-defun-start` was used at a few different
places which feel into two categories:

1- `beginning-of-defun`, where the effect is clear, deterministic, and reliable.
2- The rest (mostly `back_comment` in src/syntax.c, but also in some
  parts of font-lock which used `beginning-of-defun`) where the effect
  was not clear and reliable, it was a form of optimization which took
  effect in some cases but not all.

Part (2) has disappeared now, replaced by the `syntax-ppss` cache which
gives more reliable optimization (both in the sense that it speeds
things up more reliably and that it gives a more reliable behavior).

You liked some of the side-effects of (2), apparently.  I can agree with
that, but the old code did not really provide the feature you describe
(e.g. an unclosed comment/string in one defun would not magically stop
from "bleeding" into the next defun, although in some cases it indeed
did stop bleeding at some buffer position which depended on how the
chunks of text happened to be rehighlighted).

So, I suggest you implement the behavior you describe (you might be able
to do that fairly easily by taking some of the code used for
multi-major-mode support (since those also need to confine
syntax-propertization and font-locking in separate blocks)).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]