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#57003: 28.1.90; Can local variables be loaded before loading major mode? Date: Sat, 29 Oct 2022 23:43:21 -0400 Message-ID: References: <87czdeoqy7.fsf@localhost> <87v8r54j3h.fsf@gnus.org> <875yj5xzou.fsf@localhost> <87h6zni1uc.fsf@localhost> <87pmeaauib.fsf@localhost> 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="19984"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Ihor Radchenko , 57003@debbugs.gnu.org, Lars Ingebrigtsen To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 30 04:44:24 2022 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 1oozFI-00051p-48 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Oct 2022 04:44:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oozEz-00079b-2K; Sat, 29 Oct 2022 23:44:05 -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 1oozEw-00079G-Qv for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2022 23:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oozEw-0006UE-7F for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2022 23:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oozEv-00039O-JJ for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2022 23:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Oct 2022 03:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57003 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 57003-submit@debbugs.gnu.org id=B57003.166710141712055 (code B ref 57003); Sun, 30 Oct 2022 03:44:01 +0000 Original-Received: (at 57003) by debbugs.gnu.org; 30 Oct 2022 03:43:37 +0000 Original-Received: from localhost ([127.0.0.1]:36993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oozEW-00038M-PG for submit@debbugs.gnu.org; Sat, 29 Oct 2022 23:43:37 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34329) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oozER-000380-Pf for 57003@debbugs.gnu.org; Sat, 29 Oct 2022 23:43:35 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 09B4E441189; Sat, 29 Oct 2022 23:43:25 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6FFB1441186; Sat, 29 Oct 2022 23:43:23 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1667101403; bh=D8KQiR1kMSBt03tLBNc22sf3lSTTQ46dCtLA64n9Cuk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=T/oo1xAP5yESlyry3RUmW9a5cupOAxJ8y7wnFf0FdoxYwiH9/RfGCrRwjRijp/Jc6 DX1+u9wwJTJWajc0Qgq2ibZG8+zB7HkoE7QSWrVR5B3CVu/Miej2ZomrJ3Bi83/CBN RMRrOdI14nMv1CV1dp6prQhsAMSM71Y/KAk2+cEni9qjmHYcXl9WvCXLh3gj0XLSjH 4fayakL2Wui3QEGcOv5gOx5be/CwsZfTOPAbbyqOy7yB5UFgdGpvcZ26BXpIihCDrt HZfTvHRmHpWkmqqHiD2qlz+tkW77nE3nvWPgFjqylrVqPSWlnw6Q2Y3Mc0fDgpGnNn kdKaCBdEmZofw== Original-Received: from pastel (65-110-220-202.cpe.pppoe.ca [65.110.220.202]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 25807120FD1; Sat, 29 Oct 2022 23:43:23 -0400 (EDT) In-Reply-To: <87pmeaauib.fsf@localhost> (Ihor Radchenko's message of "Sun, 30 Oct 2022 02:57:16 +0000") 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: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246581 Archived-At: >>> However, pretty much all the BODY in Org major mode definition will need >>> to go into the hook. It feels awkward. >> The body of a major mode should usually be limited to setting some >> variables. All the font-lock highlighting, the imenu scanning, the >> syntax-propertizing, etc... is done afterwards (the later the better). > One issue I envision is when unsafe variable dialogue is being > displayed. If font-locking is not setup prior to that, Emacs will try to > fontify the visible part of buffer when displaying the dialogue and > later font-lock settings may not fully apply. > > See https://list.orgmode.org/orgmode/878ro8kqwv.fsf@localhost/T/#u I didn't quite understand the problem from that thread. Your description above isn't very clear either On the one hand you say "font-locking is not setup prior to that" but on the other you say "Emacs will try to fontify the visible part of buffer" which only happens if font-lock is setup, AFAIK. I suggest you open a bug report to get to the bottom of this. >> The act of folding is not part of "defining" the major mode in my >> book :-) > Indeed. However, a lot more things in Org mode depend on user > customizations. For example, buffer-invisibility-spec may be changed > depending on user settings, including settings defined in file-local > variables. I don't see a problem with postpone that to `hack-local-variables-hook', no. [ Other approaches exist, of course, such as monitoring those config vars and updating the other pieces of data that depend on them whenever needed. ] >>> Will moving the whole major mode definition into >>> `hack-local-variables-hook' be safe? >> Define "safe". I'm sure it'll cause problems in corner cases. >> If those problems come down to the fact that `hack-local-variables-hook' >> doesn't fit the bill, then we can look at fixing that. > I was mostly asking if you are aware about any gotchas. Not really, no. I have no doubt that there are various (in addition to the one you mention above). Stefan