From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wolfgang Scherer Newsgroups: gmane.emacs.bugs Subject: bug#61925: 30.0.50; normal-mode does not set up local variables in temporary buffers (scratch, with-temp-buffer) Date: Sun, 5 Mar 2023 05:58:09 +0100 Message-ID: <31009265-77c5-0cc6-30ab-30c4209fe5e5@gmx.de> References: <9c0bc5b9-4dad-993a-f0e8-5aebca46a52e@gmx.de> <834jr0byz0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38948"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Cc: 61925@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 05 05:59:23 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 1pYgSx-0009wh-He for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Mar 2023 05:59:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYgSf-000075-Us; Sat, 04 Mar 2023 23:59:09 -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 1pYgSc-00006Y-TY for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2023 23:59:03 -0500 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 1pYgSc-0007Dk-Kw for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2023 23:59:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pYgSc-0000sO-41 for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2023 23:59:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Scherer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Mar 2023 04:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61925 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 61925-submit@debbugs.gnu.org id=B61925.16779923063317 (code B ref 61925); Sun, 05 Mar 2023 04:59:02 +0000 Original-Received: (at 61925) by debbugs.gnu.org; 5 Mar 2023 04:58:26 +0000 Original-Received: from localhost ([127.0.0.1]:38196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYgS2-0000rR-41 for submit@debbugs.gnu.org; Sat, 04 Mar 2023 23:58:26 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:57485) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYgRu-0000r1-VL for 61925@debbugs.gnu.org; Sat, 04 Mar 2023 23:58:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1677992292; i=wolfgang.scherer@gmx.de; bh=RWGqus0/Eb12C92NuXASQMTPTR/MOGop9aprmmCEwMI=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=iIS5OLWPY0DEVZyYX6dQuNgtdTi/X407HnmM2YY+KMYNemqG0hnE72J4v+AiHk5+B u6aSAzhL4nAAbu3PjBzV6c8KIcYL++st26X/sHA/dbWhY/sAM2bz9NDvayD2Y9Jf0A 7MvTcoBq++TfigVg8boh+k8Pp15DEx/xXSaKjmP9SVSPQzTEwXK7PtCwwge2llnzWZ hROXp0uJkK8nQ6izwtCzONnMvacZHbebSsmZ1JaXPNGfJ/TZsf0W/w3/lFJG+0nvpL CVHz9S9S9iIKPIYiwWpliZMYh2PEluA5K0E2bmSvEQHg0bthSuavJ/pREf2XIm9oda iN1CbH+qpgJDA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from sheckley.simul.de ([87.144.32.75]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MrQEn-1qKvpL1THj-00oSWa; Sun, 05 Mar 2023 05:58:12 +0100 Original-Received: from [192.168.33.23] (franke.simul.de [192.168.33.23]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by sheckley.simul.de (Postfix) with ESMTPSA id 5973119405DC; Sun, 5 Mar 2023 05:58:09 +0100 (CET) Content-Language: de-DE, en-US In-Reply-To: <834jr0byz0.fsf@gnu.org> X-Provags-ID: V03:K1:O7SI1rKT/P27MAgZciOey+x4rFQkkHl1LQmqcXiXdWbug0qTv6i LoEk82d0gZ9H2y1CJ346mss9KEi80S8HRNu/LGTZe1FsUlO4dGsQ7Fy+xI5Xi/Aou4SlUFQ UcEv8JpysITnK7nwfurzRbItm6kTatHeC+mKMW5jieEpUfMaFJw1WHVgqqLbWpDxd5XrAjl g4Oh9WpOjUz/duJ7RUmpw== UI-OutboundReport: notjunk:1;M01:P0:VVuJFBBtNTg=;5nzPUIxfqdT+rLSPD7opitLT0i7 svTTmvd9tJPbccQ6mflrERAbEmAIWVDQicWiCcvBPD44XX/fY9AiuYl/SAuq/65YnnD8rY3iW H7GhtnnPUTutXzNx8LW6HV2QPG2nuClTOjV9jUCTpy8VAKl3bHnCcrnQWhZhads7icXAjlvmS y196qbg2QiCGBmpdR1OmwSYJ0HEtTcjJyPL2D5Kb2t35JlaiGtq/pMvFkeSSHw+21h0vHvvOn rrEfDhJ56QCNmUjxL3Kbka0MAzhzakW5G7KH0evnBHgpgWGkI1P5olLWukDoEAzXahj+K+sUc MygTIGPeLKkzyKQRq69XyFNoQMCesbxUV/lrfnfx1rAcd+7pXwXn2Z38BDBySAobfAHxLQ0S3 LR3+h6NT6mvl4T80WMamfadYalVgbq07r/incg5FunSD1KLs3vgc1JU4WlY3RFGFJjRtRNpxm LhBx4obWiblGDdDTNIePv7LrPysHOuDOQfgLfMB7fyFYG0sOeg11J2sbGwKZ5J1vSHvj1FEB3 JQnDaoVm+UNDhFII2KNtm51RuKb2lR3Nxe9F+YNY+6wX9ilD3s28cXigalH6gRr2WGXAeT37o /kHhgFBU8LHd7XF4276Ixh3lgLNj/mEEaJGoDZEApfsQxGbYhzJxvByqEvYHhibmM1BzVUeCA 0YzWID0BggzQvNaBkTivHuLenSZAjc9X8DMqcixkVWYSW3ROfoC5Qxd5UF/6QOZXp+tEEi1gc R77j2LoX/1eDItfn4u3uHDA3EXeklOKCgh5eUe8gMVgw5AVvYIGKmX2V+EunDOgsahVW6ab3 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:257329 Archived-At: > tags 61925 notabug > thanks > >> Date: Fri, 3 Mar 2023 00:11:13 +0100 >> From: Wolfgang Scherer >> >> The command `normal-mode' does not set file local variables, if a >> buffer does not have a `buffer-file-name'. This affects *scratch* and >> buffers created using `with-temp-buffer'. >> >> The behavior changed at some time between Emacs version 20.5.2.2 and 20= .6.3. >> See output from various Emacs versions further below. >> >> If that was an intentional change, it should be prominently documented >> to avoid the confusion when examples do not work in a *scratch* buffer. > This was an intentional change, yes. Alright, in this case, I would like to publish an advice which restores the previous behavior for anybody running into the same problem: (let* ((expected-value (not (default-value 'truncate-lines))) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (need-advice (with-temp-buffer =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (insert (format (co= ncat ";; -*-" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 " mode: fudamental-= mode;" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 " truncate-lines: %= S;" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 " -*-") =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 expected-value)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (normal-mode) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (not (eq truncate-l= ines expected-value))))) =C2=A0 (when need-advice =C2=A0=C2=A0=C2=A0 (defadvice normal-mode (around wsx-normal-mode activat= e) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "Bind buffer-file-name to `null-device', i= f it is nil." =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let ((buffer-file-name (or buffer-file-na= me null-device "/dev/null"))) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ad-do-it)))) > And AFAICT, it _is_ documented in the ELisp Reference manual: > > -- Command: normal-mode &optional find-file > This function establishes the proper major mode and buffer-local > variable bindings for the current buffer. It calls =E2=80=98set-a= uto-mode=E2=80=99 > (see below). As of Emacs 26.1, it no longer runs > =E2=80=98hack-local-variables=E2=80=99, this now being done in =E2= =80=98run-mode-hooks=E2=80=99 at > the initialization of major modes (*note Mode Hooks::). > > And the documentation of run-mode-hooks says: > > > -- Function: run-mode-hooks &rest hookvars > Major modes should run their mode hook using this function. It is > similar to =E2=80=98run-hooks=E2=80=99 (*note Hooks::), but it als= o runs > =E2=80=98change-major-mode-after-body-hook=E2=80=99, =E2=80=98hack= -local-variables=E2=80=99 (when > the buffer is visiting a file) (*note File Local Variables::) ^^^= ^ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > The user manual indeed didn't mention this caveat; I've now mentioned > that aspect there (and also in the doc strings of the relevant > functions). > > (The change in Emacs 26 that caused this as a side effect was to fix > bug#15577 and bug#23407.) > >> I would even recommend a warning prompt in normal-mode, when called >> interactively. > I think such a warning could be an annoyance. It most definitely should be, to get the proper attention. It could be disabled by setting a customized variable, pretty much the same way as risky local variables can be enabled with custom settings. That would reduce the annoyance to once in a session or once in a lifetime.