From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Blunderbuss ".dir-locals.el" raises everything in its path!! Date: Sun, 12 Jul 2009 21:21:03 +0000 Message-ID: <20090712212103.GB1009@muc.de> References: <20090712144137.GB2524@muc.de> <87hbxhony6.fsf@stupidchicken.com> <20090712180623.GA1009@muc.de> <87k52dycha.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1247433572 32174 80.91.229.12 (12 Jul 2009 21:19:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 12 Jul 2009 21:19:32 +0000 (UTC) Cc: Jan =?iso-8859-1?Q?Dj=E4rv?= , emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 12 23:19:25 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MQ6SB-0004nQ-Aw for ged-emacs-devel@m.gmane.org; Sun, 12 Jul 2009 23:19:24 +0200 Original-Received: from localhost ([127.0.0.1]:53569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQ6SA-000882-Nf for ged-emacs-devel@m.gmane.org; Sun, 12 Jul 2009 17:19:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQ6S0-00081b-RR for emacs-devel@gnu.org; Sun, 12 Jul 2009 17:19:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQ6Rw-0007xd-P7 for emacs-devel@gnu.org; Sun, 12 Jul 2009 17:19:12 -0400 Original-Received: from [199.232.76.173] (port=42834 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQ6Rw-0007xQ-GB for emacs-devel@gnu.org; Sun, 12 Jul 2009 17:19:08 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:3329 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MQ6Rv-0002I4-R6 for emacs-devel@gnu.org; Sun, 12 Jul 2009 17:19:08 -0400 Original-Received: (qmail 13724 invoked by uid 3782); 12 Jul 2009 21:19:05 -0000 Original-Received: from acm.muc.de (pD9E539F5.dip.t-dialin.net [217.229.57.245]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Sun, 12 Jul 2009 23:19:02 +0200 Original-Received: (qmail 3845 invoked by uid 1000); 12 Jul 2009 21:21:03 -0000 Content-Disposition: inline In-Reply-To: <87k52dycha.fsf@stupidchicken.com> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:112378 Archived-At: Hi, Yidong! On Sun, Jul 12, 2009 at 02:37:05PM -0400, Chong Yidong wrote: > Alan Mackenzie writes: > >> I'm not sure I understand. Directory-local variables are processed > >> right before file-local variables, and can be overridden by them. > > Sorry, yes. But that's the only thing they can be overridden by. That > > is surely not the right thing. > > Why on earth does .dir-locals.el take precedence over values set in a > > top-level `setq' or `c-mode-hook'? This is surely the Wrong Thing to > > do. > Because setting a directory-local variable is supposed to have the same > effect as setting a file-local variable inside every file in that > directory. Thus, instead of putting c-fill-style inside every .c file > in the Emacs source tree, you can simply write a .dir-locals.el file. > > In particular, the File Style and local variables settings are rarely > > used precision instruments, for configuring unusual files unusually. > This indicates that we should not set c-file-style in the .dir-locals.el > file of the Emacs source tree. That's fine by me! As well as amending that file, I've juiced up the doc strings in the two pertinent CC Mode variables, and put some stuff into the Emacs and Elisp manuals. I'd be grateful for somebody checking my prose. Incidentally, I've expanded the inane sentence that says that (project) files are kept in directories. I think most people knew that already. ;-) Index: .dir-locals.el =================================================================== RCS file: /cvsroot/emacs/emacs/.dir-locals.el,v retrieving revision 1.6 diff -c -r1.6 .dir-locals.el *** .dir-locals.el 14 Jan 2009 23:16:12 -0000 1.6 --- .dir-locals.el 12 Jul 2009 21:09:42 -0000 *************** *** 1,6 **** ((nil . ((tab-width . 8) (fill-column . 70))) - (c-mode . ((c-file-style . "GNU"))) (change-log-mode . ((add-log-time-zone-rule . t) (fill-column . 74) (bug-reference-url-format --- 1,5 ---- Index: doc/emacs/custom.texi =================================================================== RCS file: /cvsroot/emacs/emacs/doc/emacs/custom.texi,v retrieving revision 1.22 diff -c -r1.22 custom.texi *** doc/emacs/custom.texi 4 Jun 2009 03:13:28 -0000 1.22 --- doc/emacs/custom.texi 12 Jul 2009 21:09:44 -0000 *************** *** 1267,1279 **** @cindex per-directory local variables A @dfn{project} is a collection of files on which you work together. ! Usually, the project's files are kept in one or more directories. ! Occasionally, you may wish to define Emacs settings that are common to ! all the files that belong to the project. Emacs provides two ways to specify settings that are applicable to files in a specific directory: you can put a special file in that ! directory, or you can define a @dfn{project class} for that directory. @cindex @file{.dir-locals.el} file If you put a file with a special name @file{.dir-locals.el}@footnote{ --- 1267,1288 ---- @cindex per-directory local variables A @dfn{project} is a collection of files on which you work together. ! Usually, the project's files are kept in one or more directories of ! their own. Occasionally, you may wish to define Emacs settings that ! are common to all the files that belong to the project. Emacs provides two ways to specify settings that are applicable to files in a specific directory: you can put a special file in that ! directory, or you can define a @dfn{project class} for that ! directory. ! ! Note that Emacs applies these settings for each file it loads, after ! having initialized the file's major mode and run the mode hook. These ! settings can override those made by a user in his .emacs, possibly in ! a mode hook, so you should be careful not to set variables which are a ! matter of personal choice. You should probably not set ! @code{c-file-syle} and @code{c-file-offsets} here (@pxref{File ! Styles,,,ccmode}). @cindex @file{.dir-locals.el} file If you put a file with a special name @file{.dir-locals.el}@footnote{ *************** *** 1302,1309 **** ((nil . ((indent-tabs-mode . t) (tab-width . 4) (fill-column . 80))) - (c-mode . ((c-file-style . "BSD"))) - (java-mode . ((c-file-style . "BSD"))) ("src/imported" . ((nil . ((change-log-default-name . "ChangeLog.local")))))) @end example --- 1311,1316 ---- Index: doc/lispref/variables.texi =================================================================== RCS file: /cvsroot/emacs/emacs/doc/lispref/variables.texi,v retrieving revision 1.19 diff -c -r1.19 variables.texi *** doc/lispref/variables.texi 17 Jun 2009 02:58:57 -0000 1.19 --- doc/lispref/variables.texi 12 Jul 2009 21:09:53 -0000 *************** *** 1703,1708 **** --- 1703,1716 ---- variables: by putting them in a special file, or by defining a @dfn{project class} for that directory. + Note that Emacs applies these settings for each file it loads, after + having initialized the file's major mode and run the mode hook + (@pxref{Mode Hooks}). These settings can override those made by a + user in his .emacs, possibly in a mode hook, so you should be careful + not to set variables which are a matter of personal choice. You + should probably not set @code{c-file-syle} and @code{c-file-offsets} + here (@pxref{File Styles,,,ccmode}). + @defvr Constant dir-locals-file This constant is the name of the file where Emacs expects to find the directory-local variables. The name of the file is Index: lisp/progmodes/cc-vars.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-vars.el,v retrieving revision 1.73 diff -c -r1.73 cc-vars.el *** lisp/progmodes/cc-vars.el 30 Apr 2009 10:36:24 -0000 1.73 --- lisp/progmodes/cc-vars.el 12 Jul 2009 21:09:55 -0000 *************** *** 1608,1613 **** --- 1608,1618 ---- string suitable for `c-set-style'. When the file is visited, CC Mode will set the style of the file to this value automatically. + Don't use this variable anywhere but a file's Local Variable section. + You probably don't want to use this in a .dir-locals.el file, since + this would nullify any explicit settings of style variables at the + top level or in hooks. + Note that file style settings are applied before file offset settings as designated in the variable `c-file-offsets'.") (make-variable-buffer-local 'c-file-style) *************** *** 1620,1625 **** --- 1625,1635 ---- When the file is visited, CC Mode will institute these offset settings automatically. + Don't use this variable anywhere but a file's Local Variable section. + You probably don't want to use this in a .dir-locals.el file, since + this would nullify any explicit settings of style variables at the + top level or in hooks. + Note that file offset settings are applied after file style settings as designated in the variable `c-file-style'.") (make-variable-buffer-local 'c-file-offsets) Goodnight! -- Alan Mackenzie (Nuremberg, Germany).