From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] cc-mode: don't tread dir-local and file-local variables differently Date: Mon, 25 May 2020 22:28:15 -0400 Message-ID: References: <20200512194516.83180-1-mina86@mina86.com> <20200513184745.GA8857@ACM> <20200517142327.GA12554@ACM> <20200525184412.GA8662@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="127863"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: bug-cc-mode@gnu.org, Alan Mackenzie , emacs-devel@gnu.org To: =?utf-8?Q?Micha=C5=82?= Nazarewicz Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 26 04:28:51 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jdPKl-000XBP-N6 for ged-emacs-devel@m.gmane-mx.org; Tue, 26 May 2020 04:28:51 +0200 Original-Received: from localhost ([::1]:51882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdPKk-000357-M6 for ged-emacs-devel@m.gmane-mx.org; Mon, 25 May 2020 22:28:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdPKI-0002dI-FE for emacs-devel@gnu.org; Mon, 25 May 2020 22:28:22 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:36046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdPKG-0006o0-Qx; Mon, 25 May 2020 22:28:21 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 08BDF10031E; Mon, 25 May 2020 22:28:19 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 31C551002FC; Mon, 25 May 2020 22:28:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1590460097; bh=wfFZ1S4fxOMxTK9ZSeP6YsRvFO30z553JWTFSKyZmAA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=mCFnaUrY1Wn6s7hkxmdDmY7kG1uAjmKN2BBqdwbUw9YVxsceyZPl9/2Jjn7bZ25pk 2Ysn93nNe028wo9cMc7YpSQ7YET+dpMndjjmIz7cD41q1Q64du73i7GNHS86Nd7eew JFUhD7tSDWvl6w8TgLpouS0C0NqZW0LOWSFax7QPRb1fTh/peWTU+dXTlw21mf0VSn O0e+9gXKn7vZslTCrNHUdmSdmPr2wbuf1kH3MnqDqzdDo9BuR3ja2l/cw6Ofe57Qd4 g7KnvPf5cv/ooLEvbDlkblnh9CNztFQ5t1pM5d9uj45ee84YnGkGslw/VJTNJsnflW LDShUSAhWwVWA== Original-Received: from milanesa (unknown [216.154.27.250]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C6C37120554; Mon, 25 May 2020 22:28:16 -0400 (EDT) In-Reply-To: (=?utf-8?Q?=22Micha=C5=82?= Nazarewicz"'s message of "Mon, 25 May 2020 20:47:06 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/25 22:19:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:251414 Archived-At: > 1) /tmp/foo/.dir-locals.el exists and contains a single line: > > ((nil . ((c-file-style . "bsd")))) > > Opening an empty /tmp/foo/foo.c file results in =E2=80=98c-basic-offse= t=E2=80=99 > being four and =E2=80=98c-file-style=E2=80=99 being "bsd". > > 2) /tmp/bar/.dir-locals.el does not exist but /tmp/bar/bar.c does and > contains a single line: > > /* -*- c-file-style: "bsd" -*- */ > > Opening that file results in =E2=80=98c-basic-offset=E2=80=99 being ei= ght and > =E2=80=98c-file-style=E2=80=99 being "bsd". (Value of eight for the o= ffset comes > from "bsd" style). I haven't thought very deeply about those two cases, so I'm not sure whether I'd consider it a problem or a feature. > I maintain that in both cases =E2=80=98c-basic-offset=E2=80=99 should be = the same. > I further maintain that its value should be eight. Alan disagrees and > maintains that cc-mode-hook should overwrite settings in dir-local > variables but should be overwritten by settings in file-local variables. Not sure what `cc-mode-hook` has to do with it since your above example didn't use it. >> Just as it is sensible that a hook setting takes precedence over a >> dir-local setting. > No, it doesn=E2=80=99t. dir-local and file-local configuration is both l= ocated > closer to the file being open than settings specified in a hook. Values > in a hook apply to anything user opens anywhere. dir-local and > file-local variables are narrower in scope and thus should have higher > priority. A hook setting can perform any test it likes to adjust the setting to any detail of the situation. So it is definitely more specific than a dir-locals.el setting which applies blindly to all files underneath. > It=E2=80=99s highly relevant that c-file-style variable behave completely > different whether it=E2=80=99s dir-local or file-local. IIUC your example shows a different interaction between a global setting and file-vs-dir setting. FWIW, I do find it surprising that file-local would be treated differently from dir-local when faced with a global settin= g. Stefan