From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#66223: treesit-major-mode-setup should not call font-lock-mode Date: Wed, 27 Sep 2023 00:21:16 -0700 Message-ID: <23152919-A885-4B9A-8624-D5F079D576CF@gmail.com> References: <0f34478f-6d41-078d-295e-15caa4556b3f@gutov.dev> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3967"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66223@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 27 09:22:13 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qlOs8-0000hu-Sp for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 27 Sep 2023 09:22:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlOrn-00037D-DZ; Wed, 27 Sep 2023 03:21:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlOrk-000373-OZ for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2023 03:21:48 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlOrk-0007GG-FZ for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2023 03:21:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qlOrx-0005y9-Sc for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2023 03:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Sep 2023 07:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66223 X-GNU-PR-Package: emacs Original-Received: via spool by 66223-submit@debbugs.gnu.org id=B66223.169579931022927 (code B ref 66223); Wed, 27 Sep 2023 07:22:01 +0000 Original-Received: (at 66223) by debbugs.gnu.org; 27 Sep 2023 07:21:50 +0000 Original-Received: from localhost ([127.0.0.1]:50396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlOrm-0005xj-EF for submit@debbugs.gnu.org; Wed, 27 Sep 2023 03:21:50 -0400 Original-Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:55800) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlOrk-0005xV-5Q for 66223@debbugs.gnu.org; Wed, 27 Sep 2023 03:21:48 -0400 Original-Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-69101022969so9385294b3a.3 for <66223@debbugs.gnu.org>; Wed, 27 Sep 2023 00:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695799289; x=1696404089; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=o+Zd6HED50MHmC/SpTV4cYUSZ+ZX5+oqJZGSPw4WKfs=; b=QobwgMIf8oMRfnuGmmopXa30QHwgqlauRZJxR3O0HxntnhreLtKLDRt+ImS80cgFRt hm1uWDVlhNsPw+z099Jpne92dafupCARVXY3eMCE16yLGQctPuIeEskMc06S4c5cYsqB Jv5FrJkYALGVnxX2+tnmiU9T8M0hwHVt4DsYAJzwX+nVzs1au+1t/NtVFgxndlprKz/B PsFvFA1axfdklepes/yBv02ga1J8EJyhGE+TADaiH9gRK2jtTMraQFvZznj8VH4/eD3S sBYszRHWwKl65BA/h5PVty8+CuX+gskqE/JgQFFzsM+SsiXfy/chitETFnUpuKFqAFH/ qL4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695799289; x=1696404089; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o+Zd6HED50MHmC/SpTV4cYUSZ+ZX5+oqJZGSPw4WKfs=; b=oHGBas8axx6ufPU4xGVZ8sfHHfIj69rCcV4KNlYIEHGsCIzcBBLYWiWSrPPSfO/Ehj ReipKjtRzY4fGiigbxpZ0Bg9+aKyfcE1GT8H++yGwrfWKaDmiQPcivoT+xUmi969SlGn kBfbHl9Sz5lvFc0ZC1ov01u8e6i5T+EyoUiwe07SSF1O8aJwcmZXKOj0tQub1/iMhJe5 hZagWtgq3T0StV+SvNu/fyoFaKstxJqVdpSAPU8js4LZcLB6s/RMyTW3vZKWgyRWURvL z4GjSCuz5AuWQS7+oMqODiVC+7tE7BcAZtLTPjBuWtB60mrDaRlcEe0z87s8C5TrbUwq SGAw== X-Gm-Message-State: AOJu0YxagpGudKk+ahHbEfb+T810xaKzSHwG6+vViuv1n2flM0xle81s oljo51cemiLsh95B0TNVFN0= X-Google-Smtp-Source: AGHT+IHcIK5SgdrneM8EAIXzgZBlr9b8bpJyQ+5C4a827f+v45AOBx/oZDNuAkZWJqojO4snzDbctg== X-Received: by 2002:a05:6a00:244e:b0:68f:a661:d037 with SMTP id d14-20020a056a00244e00b0068fa661d037mr1469689pfj.3.1695799288534; Wed, 27 Sep 2023 00:21:28 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id c14-20020aa7880e000000b0069100e70943sm11115963pfo.24.2023.09.27.00.21.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2023 00:21:28 -0700 (PDT) In-Reply-To: <0f34478f-6d41-078d-295e-15caa4556b3f@gutov.dev> X-Mailer: Apple Mail (2.3731.700.6) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271411 Archived-At: > On Sep 26, 2023, at 5:17 PM, Dmitry Gutov wrote: >=20 > X-Debbugs-CC: Yuan Fu >=20 > It doesn't seem necessary (everything seems to work okay without that = call), and it's not the right thing idiomatically (the user should have = the ability to disable global-font-lock-mode). >=20 > If it does get called, the call to = treesit-font-lock-recompute-features should happen before that. >=20 > The report was triggered by somewhat unusual circumstances (somebody = trying out mmm-mode together with typescript-ts-mode: = https://github.com/dgutov/mmm-mode/issues/138), but the fix seems easy = and natural enough. >=20 > To reproduce the bug, though, try this: >=20 > (with-current-buffer (generate-new-buffer "foo") > (let (font-lock-support-mode) > (typescript-ts-mode))) >=20 > It results in >=20 > Debugger entered--Lisp error: (treesit-query-error "Node type error = at" 2 "(jsx_opening_element [(nested_identifier (identifier)) = (identifier)] @typescript-ts-jsx-tag-face) (jsx_closing_element = [(nested_identifier (identifier)) (identifier)] = @typescript-ts-jsx-tag-face) (jsx_self_closing_element = [(nested_identifier (identifier)) (identifier)] = @typescript-ts-jsx-tag-face) (jsx_attribute (property_identifier) = @typescript-ts-jsx-attribute-face)" "Debug the query with = `treesit-query-validate'") > treesit-query-capture(# = # 1 1) > (let* ((delta-start ... > treesit--font-lock-fontify-region-1(# = # 1 1 nil nil) > (let ((sub-node (car tail)))... > treesit-font-lock-fontify-region(1 1 nil) > font-lock-fontify-syntactically-region(1 1 nil) > font-lock-default-fontify-region(1 1 nil) > font-lock-fontify-region(1 1 nil) > font-lock-default-fontify-buffer() > font-lock-fontify-buffer() > font-lock-initial-fontify() > font-lock-mode(1) > (progn (set (make-lo... > treesit-major-mode-setup() > typescript-ts-mode() >=20 > because typescript-ts-mode's treesit-font-lock-settings hide the jsx = rule (which the typescript grammar itself doesn't support, only the tsx = one does) using the absence of that feature in = treesit-font-lock-feature-list. But for that to take effect, the call to = 'treesit-font-lock-recompute-features' needs to happen first. The = jit-lock conceals the problem by inhibiting the first fontification = until the major mode function has run and the buffer is visible. I ended = up disabling it in mmm-mode's auxiliary temp buffer because it spams the = message "Not enabling jit-lock: it does not work in indirect buffer=E2=80=9D= . Makes sense. We can remove that line in master, and see if anything = comes up. I don=E2=80=99t remember why I added it, I don=E2=80=99t think = there was any particular reason. Yuan=