GNU bug report logs - #63463
29.0.90; Using python-ts-mode for single buffer should not alter global auto-mode-alist settings

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Yikai Zhao <yikai@HIDDEN>; Keywords: notabug wontfix; dated Fri, 12 May 2023 12:46:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) notabug and wontfix. Request was from Eli Zaretskii <eliz@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 63463 <at> debbugs.gnu.org:


Received: (at 63463) by debbugs.gnu.org; 12 May 2023 13:26:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 12 09:26:30 2023
Received: from localhost ([127.0.0.1]:54463 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pxSmz-00073y-TC
	for submit <at> debbugs.gnu.org; Fri, 12 May 2023 09:26:30 -0400
Received: from eggs.gnu.org ([209.51.188.92]:44754)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>)
 id 1pxSmy-00073f-2F; Fri, 12 May 2023 09:26:28 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pxSms-0008He-Lt; Fri, 12 May 2023 09:26:22 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=UG0jw8XuAlkAOA849nMM3wr/kSzR5pJrT962Fj/42qk=; b=JPndUghHc8EE
 w1KehyWd/8mjgk5oIlXLTuWdHR16lN3RCnC/CK50PzN0stJeh0qZh1WYWnIIZj6iW0FeMotsgQ3Od
 6pEsmKc7Ol79Ebqh+QCUmGVa7zROSe1kXaAONVmBOMW92HRe+XnsQF/wmueH0W8woZub+G2Kutdgs
 0jdm8fI8jqAyg4BTjCt6xcgJRDrn2wjlb7tKCN+NjNEtIbayxxYIVsPUUufzOZ9Xgmei3qX4lA0DE
 puojcmiwLYM0N9e5pslvbFHv6LJMmIeZ3VM4lKC9Y+N8ojB0nYC8NwVO6bTCT4PxTEQqoEGIuhXz1
 ZU1F6N/+Qi7PVDWMW7xhNg==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pxSmg-0000J3-Od; Fri, 12 May 2023 09:26:22 -0400
Date: Fri, 12 May 2023 16:26:08 +0300
Message-Id: <831qjld6kv.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Yikai Zhao <yikai@HIDDEN>
In-Reply-To: <CANMyjpgJECvd8sCjyif9_-2_d4p+tegEBfBTAyUTPjdKPfNB4w@HIDDEN>
 (message from Yikai Zhao on Fri, 12 May 2023 20:45:18 +0800)
Subject: Re: bug#63463: 29.0.90;
 Using python-ts-mode for single buffer should not alter global
 auto-mode-alist settings
References: <CANMyjpgJECvd8sCjyif9_-2_d4p+tegEBfBTAyUTPjdKPfNB4w@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 63463
Cc: 63463 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

tags 63463 notabug wontfix
thanks

> From: Yikai Zhao <yikai@HIDDEN>
> Date: Fri, 12 May 2023 20:45:18 +0800
> 
> So today, out of nowhere, I noticed that some of the *.py
> buffers I opened are using `python-ts-mode` instead of the default
> `python-mode`, also some of my configs are not working correctly because
> of this (due to different hooks etc.). I was sure I didn't enable or configure
> anything related to `python-ts-mode` so that's very strange.
> 
> After some debugging, it turns out that `markdown-mode` used
> `python-ts-mode` when fontifying a python code block
> (https://github.com/jrblevin/markdown-mode/commit/44ac8e4f96f03149f60cb182f8b3f1503f66f6d0),
> and during that, `python-ts-mode` modified the global `auto-mode-alist`
> settings so that all future *.py buffers I opened use that instead.
> 
> I believe this is a bug in emacs: using some treesit-based major mode
> for single buffer should not automatically alter the global settings. I
> don't think previously there's any other major modes doing that.

It is not a bug, it is the intended behavior that loading
python-ts-mode makes that mode the default for Python files.

However, the root cause of the issue you are describing seems to be
markdown-mode, which is not part of Emacs.  I don't understand well
enough why markdown-mode needs to load python-ts-mode, but in any
case, this issue should be solved in markdown-mode, I think.

> (I also submitted a bug report to `markdown-mode`:
> https://github.com/jrblevin/markdown-mode/issues/761)

Thanks; let's see what the markdown-mode's developers say about this.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#63463; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 12 May 2023 12:45:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 12 08:45:44 2023
Received: from localhost ([127.0.0.1]:54386 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pxS9X-0005o9-KJ
	for submit <at> debbugs.gnu.org; Fri, 12 May 2023 08:45:44 -0400
Received: from lists.gnu.org ([209.51.188.17]:37506)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <i@HIDDEN>) id 1pxS9W-0005o2-6E
 for submit <at> debbugs.gnu.org; Fri, 12 May 2023 08:45:42 -0400
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 <i@HIDDEN>) id 1pxS9U-0001tn-Mb
 for bug-gnu-emacs@HIDDEN; Fri, 12 May 2023 08:45:41 -0400
Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <i@HIDDEN>) id 1pxS9S-00083n-PR
 for bug-gnu-emacs@HIDDEN; Fri, 12 May 2023 08:45:40 -0400
Received: by mail-wm1-x335.google.com with SMTP id
 5b1f17b1804b1-3f41dceb9c9so50172135e9.3
 for <bug-gnu-emacs@HIDDEN>; Fri, 12 May 2023 05:45:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=z1k.dev; s=google; t=1683895529; x=1686487529;
 h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=LLQN13wJCGPrRRdWi3JX08Uq/SZqO58keBe+uv7/ztY=;
 b=FI8zp/Qqf5XLxPIFSdQoJI3ncXTZDXCudY0LJelbxVpfucxC4TMEK9+JYk/qieVgPT
 rY8qCVloN5loA2kqSI1cA1J2lp0xuCTno+PfjrvNqc3F9gCS+eOMj2jENU7ombhjCtqH
 CUDdJ48SyXrwhVbXBIJ6jfWAmYNSZfu1s6r8uuVN1X6ZFE/jFYd+HMAe+PkTbGG2SVKg
 n/IqTscMxumOirjPpgSkaNcYU3cvHo53RfwrxDzNIeh/N0b+MPj7vXGNB41bIQgqi8I0
 j93/LBuN3G5FYSACQ9B1y1e/vxXs1ad2ayNLNK7fzZfpaosz2l4ksD75+V/6hA/v5jTf
 1WAA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1683895529; x=1686487529;
 h=to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=LLQN13wJCGPrRRdWi3JX08Uq/SZqO58keBe+uv7/ztY=;
 b=SZBJsiG5+/I3QjghuO0MM5yLqPNkp9yyqBodJDMKeaMvDnXUnAgKQfwBQ7LwFaEvvH
 Mvd9s7yvUebOMJUVOG+HULvVrczc7eXPDVXs56gN7OKYI9h8iCoX8adnFALGClJFCGo8
 Xu4Lu3XpIUFXNt2XC6DjKF1+ezd+eAt7l7DzNqAJdu+OaAELqjzg6tFfnpGta6gXGFQz
 ed2b02wkcwXFZywdcnimenxpz9FSJJ2esO/ne3dw+/oYDL/6M0eYXjyekROeFBEukY21
 oY3j6QJ8CCu19wrKD77TZezsLzGb3M4nH8PDYJTni9DhPPT/nUuV/ozqmU8Z0Y4US9Mw
 T/Aw==
X-Gm-Message-State: AC+VfDx8Z6MF30soZEdQvl2n5I2KyIhw3Pfs8QzKHuWQ9/ad4jnYH17v
 blz42RFYUS0syslSzhvM+J+t5O2x4B9J6qF/KT8UEKzZWbMNKMWnwFjWZtVF
X-Google-Smtp-Source: ACHHUZ6cjFCL098QiiEGDyeLLfL34S1XJgSqQyBvhsKn5QM3tU7vwE9rYffzZqdU3tDO8EzWjXhQ/EHc3hxYE8VuxJM=
X-Received: by 2002:a1c:7308:0:b0:3ef:6819:b2ad with SMTP id
 d8-20020a1c7308000000b003ef6819b2admr17100967wmb.37.1683895529187; Fri, 12
 May 2023 05:45:29 -0700 (PDT)
MIME-Version: 1.0
From: Yikai Zhao <yikai@HIDDEN>
Date: Fri, 12 May 2023 20:45:18 +0800
Message-ID: <CANMyjpgJECvd8sCjyif9_-2_d4p+tegEBfBTAyUTPjdKPfNB4w@HIDDEN>
Subject: 29.0.90; Using python-ts-mode for single buffer should not alter
 global auto-mode-alist settings
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=2a00:1450:4864:20::335;
 envelope-from=i@HIDDEN; helo=mail-wm1-x335.google.com
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

Hi emacs devs,

So today, out of nowhere, I noticed that some of the *.py
buffers I opened are using `python-ts-mode` instead of the default
`python-mode`, also some of my configs are not working correctly because
of this (due to different hooks etc.). I was sure I didn't enable or configure
anything related to `python-ts-mode` so that's very strange.

After some debugging, it turns out that `markdown-mode` used
`python-ts-mode` when fontifying a python code block
(https://github.com/jrblevin/markdown-mode/commit/44ac8e4f96f03149f60cb182f8b3f1503f66f6d0),
and during that, `python-ts-mode` modified the global `auto-mode-alist`
settings so that all future *.py buffers I opened use that instead.

I believe this is a bug in emacs: using some treesit-based major mode
for single buffer should not automatically alter the global settings. I
don't think previously there's any other major modes doing that.

I understand that some may argue this behavior to be reasonable based
on the thought that,
"if the user chose to use treesit for one file, then it would be good to
use treesit automatically for all future files". This MAY be true, but
in my case, I didn't choose to use it by my own. It's some lisp code
down the rabbit hole that loads it without me even realized.

I fear that this kind of issue would become more common when: 1. more
distros build emacs with treesit support by default and ship with
treesit language libraries, 2. more emacs packages tries to use
treesit-based major modes internally

(I also submitted a bug report to `markdown-mode`:
https://github.com/jrblevin/markdown-mode/issues/761)

---

In GNU Emacs 29.0.90 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.16.0, Xaw3d scroll bars)
Repository revision: emacs-29.0.90
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.5 LTS

Configured using:
 'configure
 --prefix=/nix/store/4mgq52v87wxra7nqhvsspn3klp8c731m-emacs-unstable-29.0.90
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-native-compilation'




Acknowledgement sent to Yikai Zhao <yikai@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#63463; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 12 May 2023 13:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.