bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8814: 23.3.50; dir-locals configuration does not work for subdirecto


From: Alex Harsanyi
Subject: bug#8814: 23.3.50; dir-locals configuration does not work for subdirectories
Date: Tue, 7 Jun 2011 21:05:03 +0800

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 <tab> y <tab> v <tab> <return> <down-mouse-1> <mouse-1> 
<double-down-mouse-1> <double-mouse-1> <down-mouse-1> 
<mouse-1> <wheel-down> <double-wheel-down> <wheel-down> 
<double-wheel-down> C-x b s h <return> c d SPC ~ / 
p r o <tab> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
O h <tab> <backspace> t h <tab> <return> m k d i r 
SPC - p SPC t e s t / { d c <backspace> o c } <backspace> 
, c f g } <return> c d SPC t e s t <return> c a t SPC 
S-SPC . <backspace> <backspace> > S-SPC . d i r - l 
o c a l s . e l <return> C-x b C-s C-s <return> C-SPC 
M-< M-w C-x b <return> C-y C-d C-c C-c c a t SPC . 
d i r - l o <tab> <return> M-p M-p M-p <return> M-p 
M-p M-p C-d <return> <help-echo> <menu-bar> <signals> 
<eof> c a t SPC . d i r . <backspace> - l o <tab> <return> 
C-x b <return> C-x b C-s <return> <wheel-up> <down-mouse-1> 
<mouse-1> <down-mouse-1> <mouse-1> <down-mouse-1> <mouse-movement> 
<mouse-movement> <drag-mouse-1> <down-mouse-1> <mouse-1> 
<down-mouse-1> <mouse-movement> <mouse-movement> <drag-mouse-1> 
<down-mouse-1> <mouse-1> <wheel-up> C-x b <return> 
<down> <down> <down> <down> C-x b C-s <return> c a 
t SPC > S-SPC c f g / c o n f i g . t x t <return> 
C-x b c o n <backspace> <backspace> <backspace> C-x 
C-f <C-backspace> s i <tab> <backspace> <backspace> 
s a m <tab> - p <backspace> p r o <tab> <return> <down> 
<down> <up> <return> <down> <return> C-SPC M-> M-w 
C-x b C-s C-s <return> C-y C-c C-d <return> <wheel-up> 
<wheel-up> <help-echo> <down-mouse-1> <mouse-movement> 
<mouse-movement> <help-echo> <mouse-movement> <mouse-movement> 
<drag-mouse-1> M-w C-x b C-g M-x r e p o r t - r e 
m <backspace> <backspace> <backspace> e m <tab> <r
eturn>

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)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]