From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex Harsanyi Newsgroups: gmane.emacs.bugs Subject: bug#8814: 23.3.50; dir-locals configuration does not work for subdirectories Date: Tue, 7 Jun 2011 21:05:03 +0800 Message-ID: <49DD4F22-3845-4EBC-974D-EF7BCA723AE6@me.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1307465001 26013 80.91.229.12 (7 Jun 2011 16:43:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 7 Jun 2011 16:43:21 +0000 (UTC) To: 8814@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 07 18:43:15 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QTzN4-0000lA-Mo for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Jun 2011 18:43:14 +0200 Original-Received: from localhost ([::1]:42751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTzN3-0002cI-An for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Jun 2011 12:43:13 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:50172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTywq-0003vV-3d for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2011 12:16:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTywl-00060Z-LE for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2011 12:16:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTywl-00060S-4m for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2011 12:16:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QTywk-00025Z-L5; Tue, 07 Jun 2011 12:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Harsanyi Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Jun 2011 16:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13074633588015 (code B ref -1); Tue, 07 Jun 2011 16:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Jun 2011 16:15:58 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QTywc-000257-3w for submit@debbugs.gnu.org; Tue, 07 Jun 2011 12:15:58 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QTvyU-0006Jd-9z for submit@debbugs.gnu.org; Tue, 07 Jun 2011 09:05:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTvyI-0001Pk-Kx for submit@debbugs.gnu.org; Tue, 07 Jun 2011 09:05:32 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:36742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTvyI-0001Pe-AB for submit@debbugs.gnu.org; Tue, 07 Jun 2011 09:05:26 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTvyB-0002mU-F0 for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2011 09:05:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTvy4-0001NN-Iz for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2011 09:05:19 -0400 Original-Received: from outbound-mail02.westnet.com.au ([203.10.1.243]:32884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTvy2-0001JO-M5 for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2011 09:05:12 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApIBAPQg7k18qS5e/2dsb2JhbAAMRAPRdJ9LgzeCagSGdplm X-IronPort-AV: E=Sophos;i="4.65,332,1304265600"; d="scan'208";a="150352185" Original-Received: from 124-169-46-94.dyn.iinet.net.au (HELO [10.0.1.2]) ([124.169.46.94]) by outbound-mail02.westnet.com.au with ESMTP/TLS/AES128-SHA; 07 Jun 2011 21:05:04 +0800 X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Tue, 07 Jun 2011 12:15:52 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 07 Jun 2011 12:16:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-Mailman-Approved-At: Tue, 07 Jun 2011 12:18:37 -0400 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:47022 Archived-At: I'm trying to use the dir-locals mechanism to specify different mode settings for files in different directories. For example, my project has files with the "txt" extension in a "doc" directory which are RST documents and should be opened in "rst-mode" and configuration files in a cfg directory also with a "txt" extension which should be opened in "conf-mode". For example: $ mkdir -p test/{doc,cfg} $ cd test $ cat > .dir-locals.el (("doc" (text-mode (mode . rst))) ("cfg" (text-mode (mode . conf)))) ^D $ cat > cfg/config.txt [my_app] key=value ^D $ cat > doc/document.txt ====================== Some design document ====================== This is in *RST* mode ^D $ Unfortunately, in `hack-dir-local-variables', the "doc" and "cfg" directories are not recognized relative to the .dir-locals.el file but relative to the opened file. This means that with this dir-locals file, both the "config.txt" and "document.txt" are opened in text mode. The following patch fixes the problem: === modified file 'lisp/files.el' --- lisp/files.el 2011-03-11 12:19:08 +0000 +++ lisp/files.el 2011-06-07 12:49:57 +0000 @@ -3432,7 +3432,7 @@ and `file-local-variables-alist', withou (dir-name nil)) (cond ((stringp variables-file) - (setq dir-name (file-name-directory (buffer-file-name))) + (setq dir-name (file-name-directory variables-file)) (setq class (dir-locals-read-from-file variables-file))) ((consp variables-file) (setq dir-name (nth 0 variables-file)) Best Regards, Alex. In GNU Emacs 23.3.50.1 (x86_64-apple-darwin10.6.0, NS apple-appkit-1038.35) of 2011-06-04 on karinji-2.local Windowing system distributor `Apple', version 10.3.1038 configured using `configure '--with-ns'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: nil value of $XMODIFIERS: nil locale-coding-system: nil default enable-multibyte-characters: t Major mode: Shell Minor modes in effect: diff-auto-refine-mode: t shell-dirtrack-mode: t show-paren-mode: t global-cwarn-mode: t display-time-mode: t iswitchb-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t line-number-mode: t Recent input: c y v C-x b s h c d SPC ~ / p r o O h t h m k d i r SPC - p SPC t e s t / { d c o c } , c f g } c d SPC t e s t c a t SPC S-SPC . > S-SPC . d i r - l o c a l s . e l C-x b C-s C-s C-SPC M-< M-w C-x b C-y C-d C-c C-c c a t SPC . d i r - l o M-p M-p M-p M-p M-p M-p C-d c a t SPC . d i r . - l o C-x b C-x b C-s C-x b C-x b C-s c a t SPC > S-SPC c f g / c o n f i g . t x t C-x b c o n C-x C-f s i s a m - p p r o C-SPC M-> M-w C-x b C-s C-s C-y C-c C-d M-w C-x b C-g M-x r e p o r t - r e m e m Recent messages: History item: 2 History item: 3 History item: 1 History item: 2 History item: 3 comint-delchar-or-maybe-eof: End of buffer Completed Directory has changed on disk; type g to update Dired Mark set [3 times] comint-send-input: Current buffer has no process Quit Load-path shadows: None found. Features: (shadow sort mail-extr message ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock hashcash mail-utils info emacsbug dabbrev vc-dispatcher vc-bzr sha1 hex-util diff-mode easy-mmode vc-hg help-mode conf-mode newcomment dired thingatpt rst compile ansi-color shell comint ring calc-menu uniquify paren avoid cwarn cus-start cus-load time view cal-china lunar solar cal-dst cal-bahai cal-islam cal-hebrew holidays hol-loaddefs appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs tex-site folding-isearch folding warnings advice help-fns advice-preload protbuf server midnight time-stamp whitespace iswitchb cc-mode cc-menus cc-cmds ah-bufsel ah-cc-mode-extra cc-styles cc-align semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw eieio byte-opt bytecomp byte-compile mode-local cedet cc-fonts cc-engine cc-vars cc-defs regexp-opt ah-util calc-forms calc-ext calc calc-loaddefs calc-macs autoinsert cl cl-19 tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win easymenu tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind ns multi-tty emacs)