From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74349: 30.0.92; Visiting a file under c-ts-mode loads cc-mode Date: Wed, 13 Nov 2024 15:42:21 -0500 Message-ID: References: <86servkkdr.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21637"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74349@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 13 21:43:31 2024 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 1tBKD5-0005To-7Y for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Nov 2024 21:43:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBKCf-0007Fj-Ga; Wed, 13 Nov 2024 15:43:05 -0500 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 1tBKCd-0007FK-Jz for bug-gnu-emacs@gnu.org; Wed, 13 Nov 2024 15:43:03 -0500 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 1tBKCd-0000te-BU for bug-gnu-emacs@gnu.org; Wed, 13 Nov 2024 15:43:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=8ytH9G+vwtmWFmRpSQyLFJZ+lWOYRXy3QGNzCDsHM3w=; b=fWInoxYEsG/p/59HeLKmg697m8Ez40cS48LnDPwFU0+Oxc7qf1QofuArVEHBa6wClxdVdW2eoJVtjMkgz6i0yv8U9KuAqVTiPrtzxmvTeoMSvguK04fQKmWKGego8KYHU01dq44qo72jAo+aV0TOuSFi851lbuT3t4QPGP25ErFLZrTZBqyiRxWyT17aS+kF0Hzaw1/QUIW8H2vfy37j3WYklsn+bRJac7KStVj/49b49OlKwUTz1qUH6YFimSi0UWlqabAC2leJSFUMyGh+TTXEng+eYvRulrKxcQkct2t1LJR0JjdRKPRd8J6sEYiPfILUb//K+JuzXhUq5O/FNg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBKCd-0002Bs-5z for bug-gnu-emacs@gnu.org; Wed, 13 Nov 2024 15:43:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Nov 2024 20:43:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74349 X-GNU-PR-Package: emacs Original-Received: via spool by 74349-submit@debbugs.gnu.org id=B74349.17315305568367 (code B ref 74349); Wed, 13 Nov 2024 20:43:03 +0000 Original-Received: (at 74349) by debbugs.gnu.org; 13 Nov 2024 20:42:36 +0000 Original-Received: from localhost ([127.0.0.1]:43825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBKCB-0002As-OU for submit@debbugs.gnu.org; Wed, 13 Nov 2024 15:42:36 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:35734) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBKC7-0002AH-DR for 74349@debbugs.gnu.org; Wed, 13 Nov 2024 15:42:31 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8C113100126; Wed, 13 Nov 2024 15:42:25 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1731530544; bh=wolRTQH7UbOlt2zFP3AhE1QArv8CuN6JKCtN6KGIiNA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=j7/ZQVhP/3BKNp3b9EjQYPQb2bjKadYCAuSXvp8ndi0jSWxvPgXnyLOOySALcuatT Wq5omSlT0cJpqqLq2k51pm0aj9EnzDSLaKsOAkt9ZhBut2mptq3fAhq5wIhuB5Q9Jd arnsqQ6tTiwyOuP7j8GH7gokG/gwE6wzk735+4mozIgS5Pk7CXMrUHnG2c+kx2Gttj SMhQpuqKrJCzLxAo4DOEd2yiQBPljbNXjUeJMpV8w79X+y4wk1iqo4u81tYg/tOVoR bLVbNMJAEjtLazFNuAAty78MRL7DindSHe3vtkacecsfYU7Y9aqlHBn8d/VILeQ2Ke xkzsOjCgVVXhg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8909A100042; Wed, 13 Nov 2024 15:42:24 -0500 (EST) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 75E381204D5; Wed, 13 Nov 2024 15:42:24 -0500 (EST) In-Reply-To: <86servkkdr.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 13 Nov 2024 21:24:00 +0200") 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:295290 Archived-At: > So the C file was correctly visited using c-ts-mode, but cc-mode was > still loaded, quite unexpectedly. Could you clarify why you think it's a problem? > Moreover, the settings in our .dir-locals.el that are defined for > c-mode were applied to the buffer which is not under c-mode. Could you similarly clarify why you think it's a problem? > . hack-dir-local-variables 'funcall's the mode symbol when > processing directory-local variables for that mode It doesn't "funcall" it, but it does make sure the function is loaded: ;; If KEY is an extra parent it may remain not loaded ;; (hence with some of its mode-specific vars missing their ;; `safe-local-variable' property), leading to spurious ;; prompts about unsafe vars (bug#68246). (if (and (symbolp key) (autoloadp (indirect-function key))) (ignore-errors (autoload-do-load (indirect-function key)))) > I didn't expect derived-mode-add-parents to cause c-mode be turned on, It's not turned on: its file loaded. > and its directory-local settings be applied, when c-ts-mode is > used to visit a file. Looks like you forgot about it, but yes, that was discussed explicitly when we discussed `derived-mode-add-parents`. We decided back then that the extra var-settings will likely be harmless. > Can this be avoided, please? Users who want to use c-ts-mode for C > files will not necessarily be happy to have cc-mode and all its > dependencies loaded, and the c-mode-related settings applied, just > because of unrelated c-mode settings in .dir-locals.el. It bloats the > memory footprint of Emacs for no good reason, Maybe we could try and add more tests in the above code before deciding to `autoload-do-load`. E.g. we could first check the list of variables being set and if they all already have a `safe-local-variable` property, then we don't need to autoload the mode (and then we'd have to make sure CC-mode's `safe-local-variable` settings are all autoloaded). > and it modifies variables the user didn't mean to touch. We don't really know that without reading the user's mind, in the general case. Maybe the `c-mode` settings set only things like `indent-tabs-mode` and `require-final-newline` and the users definitely want them to apply to any mode used for the C files rather than only for the `cc-c-mode`. Stefan