* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
@ 2012-09-05 13:38 Johan Claesson
2012-09-05 16:23 ` Johan Claesson
2012-09-08 1:13 ` Glenn Morris
0 siblings, 2 replies; 14+ messages in thread
From: Johan Claesson @ 2012-09-05 13:38 UTC (permalink / raw)
To: 12357
Hi,
A minor suggestion for shadow.el. list-load-path-shadows will detect
if there are two lisp files with the same name in the load-path. Such
a clash could cause problems for normal lisp files. But i think it is
normal to have multiple .dir-locals.el files spread across the
load-path. In order to avoid false warnings list-load-path-shadows
could ignore the special file name .dir-locals.el.
If you agree with this change it may be implemented by adding
".dir-locals" to the ignore list at line 118 of shadow.el:
;; Ignore these files.
(member file '("subdirs" "leim-list" ".dir-locals")))
The following test case creates two temporary directories and puts
empty .dir-locals.el files in them. It currently returns
"/tmp/dir1-28571pXx/.dir-locals hides /tmp/dir2-28571bhA/.dir-locals".
(let* ((dir1 (make-temp-file "/tmp/dir1-" t))
(dir2 (make-temp-file "/tmp/dir2-" t)))
(require 'shadow)
(write-region "" nil (concat dir1 "/.dir-locals.el"))
(write-region "" nil (concat dir2 "/.dir-locals.el"))
(let* ((load-path (list dir1 dir2))
(shadows (list-load-path-shadows t)))
(delete-directory dir1 t)
(delete-directory dir2 t)
shadows))
Regards,
/Johan
In GNU Emacs 24.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10)
of 2012-09-03 on goblin
Windowing system distributor `The X.Org Foundation', version 11.0.11203000
Configured using:
`configure '--prefix=/home/jcl/usr' '--without-toolkit-scroll-bars'
'-C' '--disable-maintainer-mode' '--without-compress-info''
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: en_US.UTF-8
value of $XMODIFIERS: nil
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: Summary
Minor modes in effect:
erc-list-mode: t
erc-menu-mode: t
erc-autojoin-mode: t
erc-ring-mode: t
erc-networks-mode: t
erc-pcomplete-mode: t
erc-track-mode: t
erc-track-minor-mode: t
erc-match-mode: t
erc-button-mode: t
erc-fill-mode: t
erc-stamp-mode: t
erc-netsplit-mode: t
erc-irccontrols-mode: t
erc-noncommands-mode: t
erc-move-to-prompt-mode: t
erc-readonly-mode: t
display-time-mode: t
global-cwarn-mode: t
which-function-mode: t
icomplete-mode: t
minibuffer-depth-indicate-mode: t
diff-auto-refine-mode: t
shell-dirtrack-mode: t
ido-everywhere: t
electric-layout-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC
SPC SPC SPC SPC [ [ [ [ [ [ C-1 C-1 p s SPC - e f SPC
| S-SPC g r e p SPC s e n d m a i l <return> M-x p
r o c e d <return> M-1 T C-s e m a c s C-s C-a C-s
C-s C-s C-s <C-home> C-s s e n d <home> F C-g f a l
<tab> <return> C-s C-s m a i l C-s C-a q <C-tab> <M-next>
<return> <return> <return> <return> C-q i q p p p C-q
i M-g n C-v M-v ! q g p p p p <return> q C-q i M-g
C-1 C-1 <return> <return> C-x C-f i n s t a l l e m
<return> C-s b z e C-s <backspace> <backspace> r C-s
C-s C-s C-s C-s C-a C-l C-1 C-1 c d <return> c d SPC
b u i <tab> t r <tab> <return> b z r SPC p u l l <return>
C-1 C-2 <return> <return> f i n d SPC . SPC - n a m
e SPC s h a d o w . e l <return> C-s <up> <left> <left>
C-x C-f C-f C-g C-x C-S-f <return> C-s i g n o r e
C-a C-1 C-1 C-q C-q <return> C-1 C-r <up> <up> C-1
C-r <home> C-s d i r - <home> C-x s M-x e m a c s -
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> r e p o r C-g C-q i M-g n n C-p C-p C-p
B B u l f <return> C-n E M-x r e p o r t = e m <backspace>
<backspace> <backspace> - e m <tab> b <tab> <retur
n>
Recent messages:
Expiring articles...done
Reading incoming mail from file... [2 times]
Wrote /home/jcl/mail/erlang-questions/13282
Wrote /home/jcl/mail/emacs-devel/14561
Wrote /home/jcl/mail/inbox/7063
Wrote /home/jcl/mail/inbox/7064
nnml: Reading incoming mail (4 new)...done
Copying to ulfc: (7051)...
Wrote /home/jcl/mail/ulfc/60
Quit
Load-path shadows:
None found.
Features:
(vc-bzr emacsbug shadow w3m-lnum w3m-bookmark w3m-tabmenu w3m-session
w3m-cookie w3m-form chistory rx desktop etags jcl-wesnoth-init
wesnoth-mode wesnoth-wml-data wesnoth-update tabify hippie-exp dabbrev
url-handlers gnus-draft gnus-fun flow-fill python-21 python cl-specs
edebug mailalias cal-iso cal-move sort gnus-cite mail-extr gnus-bcklg
gnus-async vc-git nnrss xml mm-url misearch multi-isearch add-log
gnus-dired url-cache url-http url-gw url-auth erc-menu erc-join erc-ring
erc-networks erc-pcomplete erc-track erc-match erc-button erc-fill
erc-stamp erc-netsplit erc-goodies erc erc-backend erc-compat
jcl-replace jcl-ruby jcl-sl w3m-load jcl-w3m w3m-search jcl-work-buffer
w3m-type-ahead jcl-games jcl-text-translator-init text-translator
text-translator-window text-translator-vars text-translator-sites
jcl-muse htmlize-hack htmlize muse-latex muse-html muse-xml-common
muse-colors cus-edit cus-start cus-load muse-publish muse-project
muse-protocols muse-regexps derived muse muse-nested-tags muse-mode
jcl-dictem-init dictem jcl-yaoddmuse yaoddmuse-extension w3m doc-view
jka-compr image-mode timezone w3m-hist w3m-fb bookmark-w3m w3m-ems
w3m-ccl ccl w3m-favicon w3m-image w3m-proc w3m-util yaoddmuse url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-util url-parse url-vars skeleton sgml-mode smiley network-stream tls
jcl-stumpwm autorevert jcl-slime slime-fancy slime-fontifying-fu
slime-package-fu slime-references slime-scratch slime-presentations
slime-fuzzy slime-fancy-inspector slime-c-p-c slime-editing-commands
slime-autodoc slime-parse slime-repl slime apropos hyperspec browse-url
find-lisp eldoc time eldoc-eval-autoloads muse-autoloads
svg-clock-autoloads package tabulated-list jcl-renegade-goblin
jcl-home-boot mule-util flyspell qp parse-time gnus-ml nndraft nnmh
nnfolder nnml gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 epg-config mm-view mml-smime smime dig
nntp gnus-cache jcl-gnus-init jcl-gnus gnus-sum nnoo gnus-group
gnus-undo nnmail mail-source gnus-start gnus-spec gnus-int gnus-range
gnus-win mailcap starttls smtpmail sendmail message rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mailabbrev gmm-utils mailheader gnus gnus-ems nnheader
mail-utils wid-edit jcl-goblin fuzzy-match jcl-load-beta jcl-torrent
text-translator-load jcl-calendar-init appt jcl-calendar holidays
hol-loaddefs diary-lib diary-loaddefs cal-menu calendar cal-loaddefs
jcl-emms-init emms-playing-time emms-mode-line emms-cache
emms-info-ogginfo emms-info-mp3info emms-info later-do
emms-playlist-mode emms-player-vlc emms-player-mplayer
emms-player-simple emms-source-playlist emms-source-file emms-setup emms
emms-compat jcl-erc-init jcl-file-cache-init jcl-grep-sbg sbg
jcl-ido-init jcl-eel bindat jcl-dired dired-x dired-details wdired
dired-aux jcl-register-init jcl-command-subset-init jcl-generic
generic-x jcl-erlang-init jcl-erlang distel-ie edb patmatch erl-service
derl erlext epmd net-fsm erl distel erlang man erlang-eunit jcl-safe
jcl-abbrev-init jcl-swedish-postfix quail help-mode jcl-term time-stamp
ange-ftp jcl-face hl-line jcl-modes-init jcl-rfc rfcview view goto-addr
proced table picture inf-ruby ruby-mode sh-script noutline outline
hideshow cwarn jcl-imenu jcl-global-init which-func imenu winner
thingatpt paren mic-paren printing ps-print ps-def lpr icomplete ispell
uniquify mb-depth midnight whitespace ffap saveplace jcl-keys-init
diff-mode easy-mmode term disp-table ehelp kmacro tramp tramp-compat
auth-source eieio assoc gnus-util mm-util mail-prsvr password-cache
shell pcomplete format-spec tramp-loaddefs windmove jcl-keys
jcl-load-functions jcl-file-cache ert find-func ewoc debug filecache
jcl-elisp hi-lock jcl-register jcl-grep grep compile jcl-command-subset
ido jcl-emacsclient jcl-duff jcl-template-init jcl-template jcl-motion
jcl-windows jcl-recommended jcl-site-start jcl-erlang-log bookmark pp
jcl-ediff byte-opt warnings bytecomp byte-compile cconv macroexp
jcl-misc newcomment jcl-compile ediff-merg ediff-diff ediff-wind
ediff-help ediff-util ediff-mult ediff-init ediff fpl electric cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs erlang-start clearcase tq reporter executable dired comint
regexp-opt ansi-color ring info easymenu jcl-times-init advice help-fns
advice-preload jcl-times jcl-util server cl jcl-load-path time-date
tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow
timer select scroll-bar 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 minibuffer loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2012-09-05 13:38 bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el Johan Claesson
@ 2012-09-05 16:23 ` Johan Claesson
2012-09-08 1:13 ` Glenn Morris
1 sibling, 0 replies; 14+ messages in thread
From: Johan Claesson @ 2012-09-05 16:23 UTC (permalink / raw)
To: 12357
Maybe the following is cleaner.
;; Ignore these files.
(member file '("subdirs" "leim-list"))
(string= file (file-name-sans-extension dir-locals-file)))
Regards,
/Johan
Johan Claesson <johanclaesson@bredband.net> writes:
> Hi,
>
> A minor suggestion for shadow.el. list-load-path-shadows will detect
> if there are two lisp files with the same name in the load-path. Such
> a clash could cause problems for normal lisp files. But i think it is
> normal to have multiple .dir-locals.el files spread across the
> load-path. In order to avoid false warnings list-load-path-shadows
> could ignore the special file name .dir-locals.el.
>
> If you agree with this change it may be implemented by adding
> ".dir-locals" to the ignore list at line 118 of shadow.el:
>
> ;; Ignore these files.
> (member file '("subdirs" "leim-list" ".dir-locals")))
>
> The following test case creates two temporary directories and puts
> empty .dir-locals.el files in them. It currently returns
> "/tmp/dir1-28571pXx/.dir-locals hides /tmp/dir2-28571bhA/.dir-locals".
>
> (let* ((dir1 (make-temp-file "/tmp/dir1-" t))
> (dir2 (make-temp-file "/tmp/dir2-" t)))
> (require 'shadow)
> (write-region "" nil (concat dir1 "/.dir-locals.el"))
> (write-region "" nil (concat dir2 "/.dir-locals.el"))
> (let* ((load-path (list dir1 dir2))
> (shadows (list-load-path-shadows t)))
> (delete-directory dir1 t)
> (delete-directory dir2 t)
> shadows))
>
> Regards,
>
> /Johan
>
>
>
> In GNU Emacs 24.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10)
> of 2012-09-03 on goblin
> Windowing system distributor `The X.Org Foundation', version 11.0.11203000
> Configured using:
> `configure '--prefix=/home/jcl/usr' '--without-toolkit-scroll-bars'
> '-C' '--disable-maintainer-mode' '--without-compress-info''
>
> 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: en_US.UTF-8
> value of $XMODIFIERS: nil
> locale-coding-system: utf-8-unix
> default enable-multibyte-characters: t
>
> Major mode: Summary
>
> Minor modes in effect:
> erc-list-mode: t
> erc-menu-mode: t
> erc-autojoin-mode: t
> erc-ring-mode: t
> erc-networks-mode: t
> erc-pcomplete-mode: t
> erc-track-mode: t
> erc-track-minor-mode: t
> erc-match-mode: t
> erc-button-mode: t
> erc-fill-mode: t
> erc-stamp-mode: t
> erc-netsplit-mode: t
> erc-irccontrols-mode: t
> erc-noncommands-mode: t
> erc-move-to-prompt-mode: t
> erc-readonly-mode: t
> display-time-mode: t
> global-cwarn-mode: t
> which-function-mode: t
> icomplete-mode: t
> minibuffer-depth-indicate-mode: t
> diff-auto-refine-mode: t
> shell-dirtrack-mode: t
> ido-everywhere: t
> electric-layout-mode: t
> electric-indent-mode: t
> mouse-wheel-mode: t
> file-name-shadow-mode: t
> global-font-lock-mode: t
> font-lock-mode: t
> auto-composition-mode: t
> auto-encryption-mode: t
> auto-compression-mode: t
> line-number-mode: t
> transient-mark-mode: t
>
> Recent input:
> SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC
> SPC SPC SPC SPC [ [ [ [ [ [ C-1 C-1 p s SPC - e f SPC
> | S-SPC g r e p SPC s e n d m a i l <return> M-x p
> r o c e d <return> M-1 T C-s e m a c s C-s C-a C-s
> C-s C-s C-s <C-home> C-s s e n d <home> F C-g f a l
> <tab> <return> C-s C-s m a i l C-s C-a q <C-tab> <M-next>
> <return> <return> <return> <return> C-q i q p p p C-q
> i M-g n C-v M-v ! q g p p p p <return> q C-q i M-g
> C-1 C-1 <return> <return> C-x C-f i n s t a l l e m
> <return> C-s b z e C-s <backspace> <backspace> r C-s
> C-s C-s C-s C-s C-a C-l C-1 C-1 c d <return> c d SPC
> b u i <tab> t r <tab> <return> b z r SPC p u l l <return>
> C-1 C-2 <return> <return> f i n d SPC . SPC - n a m
> e SPC s h a d o w . e l <return> C-s <up> <left> <left>
> C-x C-f C-f C-g C-x C-S-f <return> C-s i g n o r e
> C-a C-1 C-1 C-q C-q <return> C-1 C-r <up> <up> C-1
> C-r <home> C-s d i r - <home> C-x s M-x e m a c s -
> <backspace> <backspace> <backspace> <backspace> <backspace>
> <backspace> r e p o r C-g C-q i M-g n n C-p C-p C-p
> B B u l f <return> C-n E M-x r e p o r t = e m <backspace>
> <backspace> <backspace> - e m <tab> b <tab> <retur
> n>
>
> Recent messages:
> Expiring articles...done
> Reading incoming mail from file... [2 times]
> Wrote /home/jcl/mail/erlang-questions/13282
> Wrote /home/jcl/mail/emacs-devel/14561
> Wrote /home/jcl/mail/inbox/7063
> Wrote /home/jcl/mail/inbox/7064
> nnml: Reading incoming mail (4 new)...done
> Copying to ulfc: (7051)...
> Wrote /home/jcl/mail/ulfc/60
> Quit
>
> Load-path shadows:
> None found.
>
> Features:
> (vc-bzr emacsbug shadow w3m-lnum w3m-bookmark w3m-tabmenu w3m-session
> w3m-cookie w3m-form chistory rx desktop etags jcl-wesnoth-init
> wesnoth-mode wesnoth-wml-data wesnoth-update tabify hippie-exp dabbrev
> url-handlers gnus-draft gnus-fun flow-fill python-21 python cl-specs
> edebug mailalias cal-iso cal-move sort gnus-cite mail-extr gnus-bcklg
> gnus-async vc-git nnrss xml mm-url misearch multi-isearch add-log
> gnus-dired url-cache url-http url-gw url-auth erc-menu erc-join erc-ring
> erc-networks erc-pcomplete erc-track erc-match erc-button erc-fill
> erc-stamp erc-netsplit erc-goodies erc erc-backend erc-compat
> jcl-replace jcl-ruby jcl-sl w3m-load jcl-w3m w3m-search jcl-work-buffer
> w3m-type-ahead jcl-games jcl-text-translator-init text-translator
> text-translator-window text-translator-vars text-translator-sites
> jcl-muse htmlize-hack htmlize muse-latex muse-html muse-xml-common
> muse-colors cus-edit cus-start cus-load muse-publish muse-project
> muse-protocols muse-regexps derived muse muse-nested-tags muse-mode
> jcl-dictem-init dictem jcl-yaoddmuse yaoddmuse-extension w3m doc-view
> jka-compr image-mode timezone w3m-hist w3m-fb bookmark-w3m w3m-ems
> w3m-ccl ccl w3m-favicon w3m-image w3m-proc w3m-util yaoddmuse url
> url-proxy url-privacy url-expand url-methods url-history url-cookie
> url-util url-parse url-vars skeleton sgml-mode smiley network-stream tls
> jcl-stumpwm autorevert jcl-slime slime-fancy slime-fontifying-fu
> slime-package-fu slime-references slime-scratch slime-presentations
> slime-fuzzy slime-fancy-inspector slime-c-p-c slime-editing-commands
> slime-autodoc slime-parse slime-repl slime apropos hyperspec browse-url
> find-lisp eldoc time eldoc-eval-autoloads muse-autoloads
> svg-clock-autoloads package tabulated-list jcl-renegade-goblin
> jcl-home-boot mule-util flyspell qp parse-time gnus-ml nndraft nnmh
> nnfolder nnml gnus-agent gnus-srvr gnus-score score-mode nnvirtual
> gnus-msg gnus-art mm-uu mml2015 epg-config mm-view mml-smime smime dig
> nntp gnus-cache jcl-gnus-init jcl-gnus gnus-sum nnoo gnus-group
> gnus-undo nnmail mail-source gnus-start gnus-spec gnus-int gnus-range
> gnus-win mailcap starttls smtpmail sendmail message rfc822 mml mml-sec
> mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
> ietf-drums mailabbrev gmm-utils mailheader gnus gnus-ems nnheader
> mail-utils wid-edit jcl-goblin fuzzy-match jcl-load-beta jcl-torrent
> text-translator-load jcl-calendar-init appt jcl-calendar holidays
> hol-loaddefs diary-lib diary-loaddefs cal-menu calendar cal-loaddefs
> jcl-emms-init emms-playing-time emms-mode-line emms-cache
> emms-info-ogginfo emms-info-mp3info emms-info later-do
> emms-playlist-mode emms-player-vlc emms-player-mplayer
> emms-player-simple emms-source-playlist emms-source-file emms-setup emms
> emms-compat jcl-erc-init jcl-file-cache-init jcl-grep-sbg sbg
> jcl-ido-init jcl-eel bindat jcl-dired dired-x dired-details wdired
> dired-aux jcl-register-init jcl-command-subset-init jcl-generic
> generic-x jcl-erlang-init jcl-erlang distel-ie edb patmatch erl-service
> derl erlext epmd net-fsm erl distel erlang man erlang-eunit jcl-safe
> jcl-abbrev-init jcl-swedish-postfix quail help-mode jcl-term time-stamp
> ange-ftp jcl-face hl-line jcl-modes-init jcl-rfc rfcview view goto-addr
> proced table picture inf-ruby ruby-mode sh-script noutline outline
> hideshow cwarn jcl-imenu jcl-global-init which-func imenu winner
> thingatpt paren mic-paren printing ps-print ps-def lpr icomplete ispell
> uniquify mb-depth midnight whitespace ffap saveplace jcl-keys-init
> diff-mode easy-mmode term disp-table ehelp kmacro tramp tramp-compat
> auth-source eieio assoc gnus-util mm-util mail-prsvr password-cache
> shell pcomplete format-spec tramp-loaddefs windmove jcl-keys
> jcl-load-functions jcl-file-cache ert find-func ewoc debug filecache
> jcl-elisp hi-lock jcl-register jcl-grep grep compile jcl-command-subset
> ido jcl-emacsclient jcl-duff jcl-template-init jcl-template jcl-motion
> jcl-windows jcl-recommended jcl-site-start jcl-erlang-log bookmark pp
> jcl-ediff byte-opt warnings bytecomp byte-compile cconv macroexp
> jcl-misc newcomment jcl-compile ediff-merg ediff-diff ediff-wind
> ediff-help ediff-util ediff-mult ediff-init ediff fpl electric cc-mode
> cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
> cc-defs erlang-start clearcase tq reporter executable dired comint
> regexp-opt ansi-color ring info easymenu jcl-times-init advice help-fns
> advice-preload jcl-times jcl-util server cl jcl-load-path time-date
> tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
> dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow
> timer select scroll-bar 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 minibuffer loaddefs button faces
> cus-face files text-properties overlay sha1 md5 base64 format env
> code-pages mule custom widget hashtable-print-readable backquote
> make-network-process dbusbind dynamic-setting system-font-setting
> font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2012-09-05 13:38 bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el Johan Claesson
2012-09-05 16:23 ` Johan Claesson
@ 2012-09-08 1:13 ` Glenn Morris
2012-09-08 14:08 ` Johan Claesson
1 sibling, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2012-09-08 1:13 UTC (permalink / raw)
To: Johan Claesson; +Cc: 12357
Johan Claesson wrote:
> A minor suggestion for shadow.el. list-load-path-shadows will detect
> if there are two lisp files with the same name in the load-path. Such
> a clash could cause problems for normal lisp files. But i think it is
> normal to have multiple .dir-locals.el files spread across the
> load-path. In order to avoid false warnings list-load-path-shadows
> could ignore the special file name .dir-locals.el.
I think you are right, but if any one given directory has more than one
dir-locals file above it in the directory tree, then the "lowest" one
does indeed shadow all the "higher" ones. So it might be good to still
report such cases?
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2012-09-08 1:13 ` Glenn Morris
@ 2012-09-08 14:08 ` Johan Claesson
2012-09-16 18:56 ` Johan Claesson
0 siblings, 1 reply; 14+ messages in thread
From: Johan Claesson @ 2012-09-08 14:08 UTC (permalink / raw)
To: Glenn Morris; +Cc: 12357
I did not think about that kind of shadowing. I agree that would also
be nice to have reported. But i think it is a different thing. Also
it could be that the user wants the lower dir-locals file to shadow the
higher one. But i guess no user wants one lisp file to shadow another
in the load-path.
Maybe a separate command could search for dir-local files shadowing
other dir-local files for a given directory or list of directories.
(I could submit such a function.)
I usually run list-load-path-shadows in the same go as compiling my
elisp directory and just like it is nice to have no compiler warnings it
is nice to have no shadow warnings.
Regards,
/Johan
Glenn Morris <rgm@gnu.org> writes:
> Johan Claesson wrote:
>
>> A minor suggestion for shadow.el. list-load-path-shadows will detect
>> if there are two lisp files with the same name in the load-path. Such
>> a clash could cause problems for normal lisp files. But i think it is
>> normal to have multiple .dir-locals.el files spread across the
>> load-path. In order to avoid false warnings list-load-path-shadows
>> could ignore the special file name .dir-locals.el.
>
> I think you are right, but if any one given directory has more than one
> dir-locals file above it in the directory tree, then the "lowest" one
> does indeed shadow all the "higher" ones. So it might be good to still
> report such cases?
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2012-09-08 14:08 ` Johan Claesson
@ 2012-09-16 18:56 ` Johan Claesson
2014-02-26 8:49 ` Xue Fuqiao
0 siblings, 1 reply; 14+ messages in thread
From: Johan Claesson @ 2012-09-16 18:56 UTC (permalink / raw)
To: Glenn Morris; +Cc: 12357
A command to search for .dir-local.el shadows could look something like
below. Let me know if a polished version of the code below would be
useful.
I should probably clarify that this was not at all what i had in mind
when writing this bug report/suggestion in the first place :). I would
be happy if just the list-load-path-shadows command would ignore
.dir-locals.el files.
(defun list-load-path-dir-locals-shadows ()
(interactive)
(dir-locals-shadows load-path))
(defun dir-locals-shadows (path)
(when (stringp path)
(setq path (list path)))
(with-current-buffer (get-buffer-create "*Dir-Locals-Shadows*")
(erase-buffer)
(dolist (dir path)
(dir-locals-shadows-aux dir (dir-locals-find-file (file-name-as-directory dir))))
(if (> (point-max) (point-min))
(display-buffer (current-buffer))
(kill-buffer (current-buffer))
(message "No dir-local shadows found."))))
(defun dir-locals-class-name (class)
(if (stringp class)
class
(if (file-name-directory (symbol-name (cadr class)))
(concat (car class) dir-locals-file)
(format "%s%s (class %s)" (car class) dir-locals-file (cadr class)))))
(defun dir-locals-shadows-aux (dir locals)
(dolist (file (directory-files dir nil nil t))
(let ((subdir (expand-file-name file dir)))
(when (and (file-directory-p subdir)
(not (or (string-equal file ".")
(string-equal file "..")
(file-symlink-p subdir))))
(let ((subdir-locals (dir-locals-find-file (file-name-as-directory subdir))))
(and locals
(not (equal locals subdir-locals))
(insert (format "%s shadows %s\n"
(dir-locals-class-name subdir-locals)
(dir-locals-class-name locals))))
(dir-locals-shadows-aux subdir subdir-locals))))))
Regards,
/Johan
Johan Claesson <johanclaesson@bredband.net> writes:
> I did not think about that kind of shadowing. I agree that would also
> be nice to have reported. But i think it is a different thing. Also
> it could be that the user wants the lower dir-locals file to shadow the
> higher one. But i guess no user wants one lisp file to shadow another
> in the load-path.
>
> Maybe a separate command could search for dir-local files shadowing
> other dir-local files for a given directory or list of directories.
> (I could submit such a function.)
>
> I usually run list-load-path-shadows in the same go as compiling my
> elisp directory and just like it is nice to have no compiler warnings it
> is nice to have no shadow warnings.
>
> Regards,
>
> /Johan
>
>
> Glenn Morris <rgm@gnu.org> writes:
>
>> Johan Claesson wrote:
>>
>>> A minor suggestion for shadow.el. list-load-path-shadows will detect
>>> if there are two lisp files with the same name in the load-path. Such
>>> a clash could cause problems for normal lisp files. But i think it is
>>> normal to have multiple .dir-locals.el files spread across the
>>> load-path. In order to avoid false warnings list-load-path-shadows
>>> could ignore the special file name .dir-locals.el.
>>
>> I think you are right, but if any one given directory has more than one
>> dir-locals file above it in the directory tree, then the "lowest" one
>> does indeed shadow all the "higher" ones. So it might be good to still
>> report such cases?
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2012-09-16 18:56 ` Johan Claesson
@ 2014-02-26 8:49 ` Xue Fuqiao
2014-03-02 22:14 ` Johan Claesson
0 siblings, 1 reply; 14+ messages in thread
From: Xue Fuqiao @ 2014-02-26 8:49 UTC (permalink / raw)
To: 12357
Johan Claesson <johanclaesson@bredband.net> writes:
> A command to search for .dir-local.el shadows could look something like
> below.
Looks fine to me. I made a patch (and tested it). Any comments?
(I haven't written the documentation/ChangeLog/NEWS yet.)
=== modified file 'lisp/emacs-lisp/shadow.el'
--- lisp/emacs-lisp/shadow.el 2014-01-01 07:43:34 +0000
+++ lisp/emacs-lisp/shadow.el 2014-02-26 08:38:54 +0000
@@ -115,7 +115,8 @@
;; FILE now contains the current file name, with no suffix.
(unless (or (member file files-seen-this-dir)
;; Ignore these files.
- (member file '("subdirs" "leim-list")))
+ (member file '("subdirs" "leim-list"))
+ (string= file (file-name-sans-extension dir-locals-file)))
;; File has not been seen yet in this directory.
;; This test prevents us declaring that XXX.el shadows
;; XXX.elc (or vice-versa) when they are in the same directory.
@@ -281,6 +282,49 @@
(forward-line 1))
(message "%s" msg)))))))
+\f
+
+(defun list-load-path-dir-locals-shadows ()
+ "Display a list of dir-local files that shadow other files."
+ (interactive)
+ (dir-locals-shadows load-path))
+
+(defun dir-locals-shadows (path)
+ "Display a list of dir-local files that shadow other files under PATH."
+ (when (stringp path)
+ (setq path (list path)))
+ (with-current-buffer (get-buffer-create "*Dir-Locals-Shadows*")
+ (erase-buffer)
+ (dolist (dir path)
+ (dir-locals-shadows-1 dir (dir-locals-find-file (file-name-as-directory dir))))
+ (if (> (point-max) (point-min))
+ (display-buffer (current-buffer))
+ (kill-buffer (current-buffer))
+ (message "No dir-local shadows found."))))
+
+(defun dir-locals-class-name (class)
+ (if (stringp class)
+ class
+ (if (file-name-directory (symbol-name (cadr class)))
+ (concat (car class) dir-locals-file)
+ (format "%s%s (class %s)" (car class) dir-locals-file (cadr class)))))
+
+(defun dir-locals-shadows-1 (dir locals)
+ "Auxiliary function for `dir-locals-shadows'."
+ (dolist (file (directory-files dir nil nil 'no-sort))
+ (let ((subdir (expand-file-name file dir)))
+ (when (and (file-directory-p subdir)
+ (not (or (string-equal file ".")
+ (string-equal file "..")
+ (file-symlink-p subdir))))
+ (let ((subdir-locals (dir-locals-find-file (file-name-as-directory subdir))))
+ (and locals
+ (not (equal locals subdir-locals))
+ (insert (format "%s shadows %s\n"
+ (dir-locals-class-name subdir-locals)
+ (dir-locals-class-name locals))))
+ (dir-locals-shadows-1 subdir subdir-locals))))))
+
(provide 'shadow)
;;; shadow.el ends here
--
http://www.gnu.org/software/emacs/
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2014-02-26 8:49 ` Xue Fuqiao
@ 2014-03-02 22:14 ` Johan Claesson
2014-03-02 22:36 ` Xue Fuqiao
0 siblings, 1 reply; 14+ messages in thread
From: Johan Claesson @ 2014-03-02 22:14 UTC (permalink / raw)
To: Xue Fuqiao; +Cc: 12357
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
Great. Attached is a loading.texi patch that just add to the
description of list-load-path-shadows that it will not report
.dir-locals.el files. Do you think there should be a @deffn entry for
list-load-path-dir-locals-shadows as well?
Also attached is a shadow.el patch with the following changes:
1. Some more doc string text.
2. list-load-path-dir-locals-shadows uses the same button making code as
list-load-path-shadows.
3. Inherit the major mode from special-mode instead of fundamental-mode
to get quit on ?q etc.
4. Also bind forward-button to tab in this mode. And backward-button to
backtab.
5. It will not bail out on an invalid directory in load-path any more (i
happened to have some invalid directories in load-path while testing
this :) ).
Regards,
/Johan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: loading.texi.diff --]
[-- Type: text/x-diff, Size: 825 bytes --]
=== modified file 'doc/lispref/loading.texi'
--- old/doc/lispref/loading.texi 2014-01-01 07:43:34 +0000
+++ new/doc/lispref/loading.texi 2014-03-02 21:39:14 +0000
@@ -411,12 +411,19 @@
directory. Such a situation might indicate a problem in the way Emacs
was installed.
+Files named @file{.dir-locals.el} are not reported by this command.
+These files specify directory local variables, see @ref{Directory
+Local Variables}. It is normal that it exists multiple files with
+this name.
+
When called from Lisp, this function prints a message listing the
shadowed files, instead of displaying them in a buffer. If the
optional argument @code{stringp} is non-@code{nil}, it instead returns
the shadowed files as a string.
@end deffn
+
+
@node Loading Non-ASCII
@section Loading Non-@acronym{ASCII} Characters
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: shadow.el.diff --]
[-- Type: text/x-diff, Size: 6049 bytes --]
=== modified file 'lisp/emacs-lisp/shadow.el'
--- old/lisp/emacs-lisp/shadow.el 2014-01-01 07:43:34 +0000
+++ new/lisp/emacs-lisp/shadow.el 2014-03-02 22:06:37 +0000
@@ -115,7 +115,8 @@
;; FILE now contains the current file name, with no suffix.
(unless (or (member file files-seen-this-dir)
;; Ignore these files.
- (member file '("subdirs" "leim-list")))
+ (member file '("subdirs" "leim-list"))
+ (string= file (file-name-sans-extension dir-locals-file)))
;; File has not been seen yet in this directory.
;; This test prevents us declaring that XXX.el shadows
;; XXX.elc (or vice-versa) when they are in the same directory.
@@ -169,20 +170,27 @@
. (1 font-lock-warning-face)))
"Keywords to highlight in `load-path-shadows-mode'.")
-(define-derived-mode load-path-shadows-mode fundamental-mode "LP-Shadows"
+(define-derived-mode load-path-shadows-mode special-mode "LP-Shadows"
"Major mode for load-path shadows buffer."
(set (make-local-variable 'font-lock-defaults)
'((load-path-shadows-font-lock-keywords)))
(setq buffer-undo-list t
buffer-read-only t))
+(let ((map (make-sparse-keymap)))
+ (define-key map [tab] 'forward-button)
+ (define-key map [backtab] 'backward-button)
+ (setq load-path-shadows-mode-map map))
+
;; TODO use text-properties instead, a la dired.
(require 'button)
(define-button-type 'load-path-shadows-find-file
'follow-link t
-;; 'face 'default
'action (lambda (button)
- (let ((file (concat (button-get button 'shadow-file) ".el")))
+ (let* ((shadow-file (button-get button 'shadow-file))
+ (file (if (equal (file-name-extension shadow-file) "el")
+ shadow-file
+ (concat shadow-file ".el"))))
(or (file-exists-p file)
(setq file (concat file ".gz")))
(if (file-readable-p file)
@@ -190,6 +198,20 @@
(error "Cannot read file"))))
'help-echo "mouse-2, RET: find this file")
+(defun load-path-shadows-make-buttons ()
+ "Create buttons for `load-path-shadows-mode'."
+ (let ((inhibit-read-only t))
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "\\(^.*\\) hides \\(.*$\\)"
+ nil t)
+ (dotimes (i 2)
+ (make-button (match-beginning (1+ i))
+ (match-end (1+ i))
+ 'type 'load-path-shadows-find-file
+ 'shadow-file
+ (match-string (1+ i))))))))
+
\f
;;;###autoload
(defun list-load-path-shadows (&optional stringp)
@@ -231,6 +253,11 @@
XXX.elc in an early directory (that does not contain XXX.el) is
considered to shadow a later file XXX.el, and vice-versa.
+Files named .dir-locals.el are not reported by this command.
+These files specify directory local variables. It is normal that
+it exists multiple files with this name. But see the command
+`list-load-path-dir-locals-shadows'.
+
Shadowings are located by calling the (non-interactive) companion
function, `load-path-shadows-find'."
(interactive)
@@ -257,14 +284,7 @@
(erase-buffer)
(insert string)
(insert msg "\n")
- (while (re-search-backward "\\(^.*\\) hides \\(.*$\\)"
- nil t)
- (dotimes (i 2)
- (make-button (match-beginning (1+ i))
- (match-end (1+ i))
- 'type 'load-path-shadows-find-file
- 'shadow-file
- (match-string (1+ i)))))
+ (load-path-shadows-make-buttons)
(goto-char (point-max)))))
;; We are non-interactive, print shadows via message.
(unless (zerop n)
@@ -281,6 +301,64 @@
(forward-line 1))
(message "%s" msg)))))))
+
+
+\f
+
+(defun list-load-path-dir-locals-shadows ()
+ "Display a list of dir-local files that shadow other such files.
+
+A .dir-locals.el file will shadow any other such file higher up
+in the directory tree. Sometimes this is what you want,
+sometimes it is not. This command will show all such shadowing
+in the current `load-path'.
+
+This command complements the command `list-load-path-shadows'.
+"
+ (interactive)
+ (dir-locals-shadows load-path))
+
+(defun dir-locals-shadows (path)
+ "Display a list of dir-local files that shadow other files under PATH."
+ (when (stringp path)
+ (setq path (list path)))
+ (with-current-buffer (get-buffer-create "*Dir-Locals-Shadows*")
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (dolist (dir path)
+ (if (file-directory-p dir)
+ (dir-locals-shadows-1 dir (dir-locals-find-file (file-name-as-directory dir)))
+ (insert (format "invalid dir %s\n" dir)))))
+ (load-path-shadows-mode)
+ (load-path-shadows-make-buttons)
+ (if (> (point-max) (point-min))
+ (display-buffer (current-buffer))
+ (kill-buffer (current-buffer))
+ (message "No dir-local shadows found."))))
+
+(defun dir-locals-class-name (class)
+ (if (stringp class)
+ class
+ (if (file-name-directory (symbol-name (cadr class)))
+ (concat (car class) dir-locals-file)
+ (format "%s%s (class %s)" (car class) dir-locals-file (cadr class)))))
+
+(defun dir-locals-shadows-1 (dir locals)
+ "Auxiliary function for `dir-locals-shadows'."
+ (dolist (file (directory-files dir nil nil 'no-sort))
+ (let ((subdir (expand-file-name file dir)))
+ (when (and (file-directory-p subdir)
+ (not (or (string-equal file ".")
+ (string-equal file "..")
+ (file-symlink-p subdir))))
+ (let ((subdir-locals (dir-locals-find-file (file-name-as-directory subdir))))
+ (and locals
+ (not (equal locals subdir-locals))
+ (insert (format "%s hides %s\n"
+ (dir-locals-class-name subdir-locals)
+ (dir-locals-class-name locals))))
+ (dir-locals-shadows-1 subdir subdir-locals))))))
+
(provide 'shadow)
;;; shadow.el ends here
[-- Attachment #4: Type: text/plain, Size: 3006 bytes --]
Xue Fuqiao <xfq@gnu.org> writes:
> Johan Claesson <johanclaesson@bredband.net> writes:
>
>> A command to search for .dir-local.el shadows could look something like
>> below.
>
> Looks fine to me. I made a patch (and tested it). Any comments?
>
> (I haven't written the documentation/ChangeLog/NEWS yet.)
>
> === modified file 'lisp/emacs-lisp/shadow.el'
> --- lisp/emacs-lisp/shadow.el 2014-01-01 07:43:34 +0000
> +++ lisp/emacs-lisp/shadow.el 2014-02-26 08:38:54 +0000
> @@ -115,7 +115,8 @@
> ;; FILE now contains the current file name, with no suffix.
> (unless (or (member file files-seen-this-dir)
> ;; Ignore these files.
> - (member file '("subdirs" "leim-list")))
> + (member file '("subdirs" "leim-list"))
> + (string= file (file-name-sans-extension dir-locals-file)))
> ;; File has not been seen yet in this directory.
> ;; This test prevents us declaring that XXX.el shadows
> ;; XXX.elc (or vice-versa) when they are in the same directory.
> @@ -281,6 +282,49 @@
> (forward-line 1))
> (message "%s" msg)))))))
>
> +\f
> +
> +(defun list-load-path-dir-locals-shadows ()
> + "Display a list of dir-local files that shadow other files."
> + (interactive)
> + (dir-locals-shadows load-path))
> +
> +(defun dir-locals-shadows (path)
> + "Display a list of dir-local files that shadow other files under PATH."
> + (when (stringp path)
> + (setq path (list path)))
> + (with-current-buffer (get-buffer-create "*Dir-Locals-Shadows*")
> + (erase-buffer)
> + (dolist (dir path)
> + (dir-locals-shadows-1 dir (dir-locals-find-file (file-name-as-directory dir))))
> + (if (> (point-max) (point-min))
> + (display-buffer (current-buffer))
> + (kill-buffer (current-buffer))
> + (message "No dir-local shadows found."))))
> +
> +(defun dir-locals-class-name (class)
> + (if (stringp class)
> + class
> + (if (file-name-directory (symbol-name (cadr class)))
> + (concat (car class) dir-locals-file)
> + (format "%s%s (class %s)" (car class) dir-locals-file (cadr class)))))
> +
> +(defun dir-locals-shadows-1 (dir locals)
> + "Auxiliary function for `dir-locals-shadows'."
> + (dolist (file (directory-files dir nil nil 'no-sort))
> + (let ((subdir (expand-file-name file dir)))
> + (when (and (file-directory-p subdir)
> + (not (or (string-equal file ".")
> + (string-equal file "..")
> + (file-symlink-p subdir))))
> + (let ((subdir-locals (dir-locals-find-file (file-name-as-directory subdir))))
> + (and locals
> + (not (equal locals subdir-locals))
> + (insert (format "%s shadows %s\n"
> + (dir-locals-class-name subdir-locals)
> + (dir-locals-class-name locals))))
> + (dir-locals-shadows-1 subdir subdir-locals))))))
> +
> (provide 'shadow)
>
> ;;; shadow.el ends here
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2014-03-02 22:14 ` Johan Claesson
@ 2014-03-02 22:36 ` Xue Fuqiao
2014-03-04 22:29 ` Johan Claesson
0 siblings, 1 reply; 14+ messages in thread
From: Xue Fuqiao @ 2014-03-02 22:36 UTC (permalink / raw)
To: Johan Claesson; +Cc: Xue Fuqiao, 12357
Johan Claesson <johanclaesson@bredband.net> writes:
> Do you think there should be a @deffn entry for
> list-load-path-dir-locals-shadows as well?
I think so.
--
http://www.gnu.org/software/emacs/
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2014-03-02 22:36 ` Xue Fuqiao
@ 2014-03-04 22:29 ` Johan Claesson
2014-03-05 0:54 ` Leo Liu
0 siblings, 1 reply; 14+ messages in thread
From: Johan Claesson @ 2014-03-04 22:29 UTC (permalink / raw)
To: Xue Fuqiao; +Cc: 12357
[-- Attachment #1: Type: text/plain, Size: 1074 bytes --]
Ok, that is added to the loading.texi patch.
Also list-load-path-dir-locals-shadows was renamed to
list-dir-locals-shadows. An argument PATH was added since it makes
sense to run this on other directories than load-path. And the argument
STRINGP was added to align with list-load-path-shadows.
NEWS suggestion:
** `list-load-path-shadows' no longer reports .dir-locals.el files. A
.dir-locals.el file may shadow another .dir-locals.el file but not in
the same sense as in `list-load-path-shadows'. A new command
`list-dir-locals-shadows' is introduced. It detect shadows of
.dir-locals.el files in a way that make sense for this type of files.
ChangeLog suggestion:
* emacs-lisp/shadows.el (load-path-shadows-find): Do not report
.dir-locals.el files.
(list-dir-locals-shadows): New command that reports shadows of
.dir-locals.el in a way that make sense for that type of file.
(dir-locals-shadows-find, dir-locals-shadows-find-1)
(dir-locals-class-name, dir-locals-shadows-display): Auxiliary
functions for list-dir-locals-shadows.
Regards,
/Johan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: shadow.el.diff --]
[-- Type: text/x-diff, Size: 7188 bytes --]
=== modified file 'lisp/emacs-lisp/shadow.el'
--- old/lisp/emacs-lisp/shadow.el 2014-01-01 07:43:34 +0000
+++ new/lisp/emacs-lisp/shadow.el 2014-03-04 22:26:00 +0000
@@ -115,7 +115,8 @@
;; FILE now contains the current file name, with no suffix.
(unless (or (member file files-seen-this-dir)
;; Ignore these files.
- (member file '("subdirs" "leim-list")))
+ (member file '("subdirs" "leim-list"))
+ (string= file (file-name-sans-extension dir-locals-file)))
;; File has not been seen yet in this directory.
;; This test prevents us declaring that XXX.el shadows
;; XXX.elc (or vice-versa) when they are in the same directory.
@@ -169,20 +170,27 @@
. (1 font-lock-warning-face)))
"Keywords to highlight in `load-path-shadows-mode'.")
-(define-derived-mode load-path-shadows-mode fundamental-mode "LP-Shadows"
+(define-derived-mode load-path-shadows-mode special-mode "LP-Shadows"
"Major mode for load-path shadows buffer."
(set (make-local-variable 'font-lock-defaults)
'((load-path-shadows-font-lock-keywords)))
(setq buffer-undo-list t
buffer-read-only t))
+(let ((map (make-sparse-keymap)))
+ (define-key map [tab] 'forward-button)
+ (define-key map [backtab] 'backward-button)
+ (setq load-path-shadows-mode-map map))
+
;; TODO use text-properties instead, a la dired.
(require 'button)
(define-button-type 'load-path-shadows-find-file
'follow-link t
-;; 'face 'default
'action (lambda (button)
- (let ((file (concat (button-get button 'shadow-file) ".el")))
+ (let* ((shadow-file (button-get button 'shadow-file))
+ (file (if (equal (file-name-extension shadow-file) "el")
+ shadow-file
+ (concat shadow-file ".el"))))
(or (file-exists-p file)
(setq file (concat file ".gz")))
(if (file-readable-p file)
@@ -190,6 +198,21 @@
(error "Cannot read file"))))
'help-echo "mouse-2, RET: find this file")
+(defun load-path-shadows-make-buttons ()
+ "Create buttons for `load-path-shadows-mode'."
+ (let ((inhibit-read-only t))
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "\\(^.*\\) hides \\(.*$\\)"
+ nil t)
+ (dotimes (i 2)
+ (let ((file (match-string (1+ i))))
+ (when (file-exists-p file)
+ (make-button (match-beginning (1+ i))
+ (match-end (1+ i))
+ 'type 'load-path-shadows-find-file
+ 'shadow-file file))))))))
+
\f
;;;###autoload
(defun list-load-path-shadows (&optional stringp)
@@ -231,6 +254,11 @@
XXX.elc in an early directory (that does not contain XXX.el) is
considered to shadow a later file XXX.el, and vice-versa.
+Files named .dir-locals.el are not reported by this command.
+These files specify directory local variables. It is normal that
+it exists multiple files with this name. But see the command
+`list-dir-locals-shadows'.
+
Shadowings are located by calling the (non-interactive) companion
function, `load-path-shadows-find'."
(interactive)
@@ -257,14 +285,7 @@
(erase-buffer)
(insert string)
(insert msg "\n")
- (while (re-search-backward "\\(^.*\\) hides \\(.*$\\)"
- nil t)
- (dotimes (i 2)
- (make-button (match-beginning (1+ i))
- (match-end (1+ i))
- 'type 'load-path-shadows-find-file
- 'shadow-file
- (match-string (1+ i)))))
+ (load-path-shadows-make-buttons)
(goto-char (point-max)))))
;; We are non-interactive, print shadows via message.
(unless (zerop n)
@@ -281,6 +302,93 @@
(forward-line 1))
(message "%s" msg)))))))
+
+
+\f
+;;;###autoload
+(defun list-dir-locals-shadows (&optional stringp path)
+ "Display a list of .dir-locals.el files that shadow other such files.
+
+A .dir-locals.el file will shadow any other such file higher up
+in the directory tree. Sometimes this is what you want,
+sometimes it is not.
+
+If the optional argument STRINGP is non-nil, returns any shadows
+as a string. Otherwise, if interactive shows any shadows in a
+`*Dir-Locals-Shadows*' buffer; else print a message listing any
+shadows.
+
+The optional argument PATH is the directory or list of
+directories to examine. It defaults to the value of `load-path'.
+
+This command complements the command `list-load-path-shadows'."
+ (interactive)
+ (unless path
+ (setq path load-path))
+ (let ((string (dir-locals-shadows-find path)))
+ (if stringp
+ string
+ (if (zerop (length string))
+ (message "No dir-local shadows found.")
+ (if (called-interactively-p 'interactive)
+ (dir-locals-shadows-display string)
+ (message "Dir-locals shadows:\n%s" string))))))
+
+(defun dir-locals-shadows-find (path)
+ "Return a string of .dir-locals.el files that shadows other such files.
+
+The argument PATH is the directory or list of directories to
+examine.
+
+A .dir-locals.el file will shadow any other such file higher up
+in the directory tree. Sometimes this is what you want,
+sometimes it is not."
+ (when (stringp path)
+ (setq path (list path)))
+ (with-temp-buffer
+ (dolist (dir path)
+ (if (file-directory-p dir)
+ (dir-locals-shadows-find-1 dir (dir-locals-find-file (file-name-as-directory dir)))
+ (insert (format "Invalid dir %s\n" dir))))
+ (buffer-string)))
+
+(defun dir-locals-shadows-find-1 (dir locals)
+ "Auxiliary function for `dir-locals-shadows-find'."
+ (dolist (file (directory-files dir nil nil 'no-sort))
+ (let ((subdir (expand-file-name file dir)))
+ (when (and (file-directory-p subdir)
+ (not (or (string-equal file ".")
+ (string-equal file "..")
+ (file-symlink-p subdir))))
+ (let ((subdir-locals (dir-locals-find-file (file-name-as-directory subdir))))
+ (and locals
+ (not (equal locals subdir-locals))
+ (insert (format "%s hides %s\n"
+ (dir-locals-class-name subdir-locals)
+ (dir-locals-class-name locals))))
+ (dir-locals-shadows-find-1 subdir subdir-locals))))))
+
+(defun dir-locals-class-name (class)
+ "Returns a describing string for directory-local class CLASS.
+
+CLASS is a values returned from `dir-locals-find-file'. It
+can be a string or a list. See that function for details."
+ (if (stringp class)
+ class
+ (if (file-name-directory (symbol-name (cadr class)))
+ (concat (car class) dir-locals-file)
+ (format "%s (class %s)" (car class) (cadr class)))))
+
+(defun dir-locals-shadows-display (string)
+ "Display the dir-locals shadows STRING in a buffer."
+ (with-current-buffer (get-buffer-create "*Dir-Locals-Shadows*")
+ (load-path-shadows-mode)
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (insert string)
+ (load-path-shadows-make-buttons)
+ (display-buffer (current-buffer)))))
+
(provide 'shadow)
;;; shadow.el ends here
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: loading.texi.diff --]
[-- Type: text/x-diff, Size: 1612 bytes --]
=== modified file 'doc/lispref/loading.texi'
--- old/doc/lispref/loading.texi 2014-01-01 07:43:34 +0000
+++ new/doc/lispref/loading.texi 2014-03-04 22:12:52 +0000
@@ -411,12 +411,35 @@
directory. Such a situation might indicate a problem in the way Emacs
was installed.
+Files named @file{.dir-locals.el} are not reported by this command.
+These files specify directory local variables, see @ref{Directory
+Local Variables}. It is normal that it exists multiple files with
+this name. But see the command @code{list-dir-locals-shadows}
+below.
+
When called from Lisp, this function prints a message listing the
shadowed files, instead of displaying them in a buffer. If the
-optional argument @code{stringp} is non-@code{nil}, it instead returns
+optional argument @var{stringp} is non-@code{nil}, it instead returns
the shadowed files as a string.
@end deffn
+@deffn Command list-dir-locals-shadows &optional stringp path
+This command displays a list of @file{.dir-locals.el} files that shadow other
+such files.
+
+A @file{.dir-locals.el} file will shadow any other such file higher up
+in the directory tree. Sometimes this is what you want,
+sometimes it is not.
+
+If the optional argument @var{stringp} is non-@code{nil}, returns any
+shadows as a string. Otherwise, if interactive shows any shadows in a
+buffer; else prints a message listing any shadows.
+
+The optional argument @var{path} is the directory or list of directories
+to examine. It defaults to the value of @code{load-path}.
+@end deffn
+
+
@node Loading Non-ASCII
@section Loading Non-@acronym{ASCII} Characters
[-- Attachment #4: Type: text/plain, Size: 210 bytes --]
Xue Fuqiao <xfq@gnu.org> writes:
> Johan Claesson <johanclaesson@bredband.net> writes:
>
>> Do you think there should be a @deffn entry for
>> list-load-path-dir-locals-shadows as well?
>
> I think so.
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2014-03-04 22:29 ` Johan Claesson
@ 2014-03-05 0:54 ` Leo Liu
2014-03-05 7:09 ` Johan Claesson
2014-03-05 7:25 ` Johan Claesson
0 siblings, 2 replies; 14+ messages in thread
From: Leo Liu @ 2014-03-05 0:54 UTC (permalink / raw)
To: Johan Claesson; +Cc: 12357
On 2014-03-05 06:29 +0800, Johan Claesson wrote:
> * emacs-lisp/shadows.el (load-path-shadows-find): Do not report
> .dir-locals.el files.
> (list-dir-locals-shadows): New command that reports shadows of
> .dir-locals.el in a way that make sense for that type of file.
> (dir-locals-shadows-find, dir-locals-shadows-find-1)
> (dir-locals-class-name, dir-locals-shadows-display): Auxiliary
> functions for list-dir-locals-shadows.
I am not too sure what problems are solved by the change.
In the case of list-load-path-shadows, it should print anything when in
doubt since false positives can be helpful. So it is not entirely wrong
to report .dir-locals.el.
Use .dir-locals.el in a child directory to shadow parent directory isn't
uncommon practice. In future we might even make it capable of inheriting
settings in parent directory. So I am not even sure the use case of
listing .dir-locals files (defaulting to the load-path)??
Leo
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2014-03-05 0:54 ` Leo Liu
@ 2014-03-05 7:09 ` Johan Claesson
2014-03-06 2:07 ` Glenn Morris
2014-03-05 7:25 ` Johan Claesson
1 sibling, 1 reply; 14+ messages in thread
From: Johan Claesson @ 2014-03-05 7:09 UTC (permalink / raw)
To: 12357
Well i would like the false positives to go away. That is the problem
this attempts to fix.
How about a defvar load-path-shadows-report-dir-locals instead?
It would of course be true by default to preserve legacy behaviour.
Regards,
/Johan
Leo Liu <sdl.web@gmail.com> writes:
> On 2014-03-05 06:29 +0800, Johan Claesson wrote:
>> * emacs-lisp/shadows.el (load-path-shadows-find): Do not report
>> .dir-locals.el files.
>> (list-dir-locals-shadows): New command that reports shadows of
>> .dir-locals.el in a way that make sense for that type of file.
>> (dir-locals-shadows-find, dir-locals-shadows-find-1)
>> (dir-locals-class-name, dir-locals-shadows-display): Auxiliary
>> functions for list-dir-locals-shadows.
>
> I am not too sure what problems are solved by the change.
>
> In the case of list-load-path-shadows, it should print anything when in
> doubt since false positives can be helpful. So it is not entirely wrong
> to report .dir-locals.el.
>
> Use .dir-locals.el in a child directory to shadow parent directory isn't
> uncommon practice. In future we might even make it capable of inheriting
> settings in parent directory. So I am not even sure the use case of
> listing .dir-locals files (defaulting to the load-path)??
>
> Leo
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2014-03-05 0:54 ` Leo Liu
2014-03-05 7:09 ` Johan Claesson
@ 2014-03-05 7:25 ` Johan Claesson
1 sibling, 0 replies; 14+ messages in thread
From: Johan Claesson @ 2014-03-05 7:25 UTC (permalink / raw)
To: Leo Liu; +Cc: Xue Fuqiao, 12357
Well i would like the false positives to go away. That is the problem
this attempts to fix.
How about a defvar load-path-shadows-report-dir-locals instead?
It would of course be true by default to preserve legacy behaviour.
I agree that list-dir-locals-shadows is not very useful. It was written
only to motivate that list-load-path-shadows should not report
.dir-locals.el.
Regards,
/Johan
Leo Liu <sdl.web@gmail.com> writes:
> On 2014-03-05 06:29 +0800, Johan Claesson wrote:
>> * emacs-lisp/shadows.el (load-path-shadows-find): Do not report
>> .dir-locals.el files.
>> (list-dir-locals-shadows): New command that reports shadows of
>> .dir-locals.el in a way that make sense for that type of file.
>> (dir-locals-shadows-find, dir-locals-shadows-find-1)
>> (dir-locals-class-name, dir-locals-shadows-display): Auxiliary
>> functions for list-dir-locals-shadows.
>
> I am not too sure what problems are solved by the change.
>
> In the case of list-load-path-shadows, it should print anything when in
> doubt since false positives can be helpful. So it is not entirely wrong
> to report .dir-locals.el.
>
> Use .dir-locals.el in a child directory to shadow parent directory isn't
> uncommon practice. In future we might even make it capable of inheriting
> settings in parent directory. So I am not even sure the use case of
> listing .dir-locals files (defaulting to the load-path)??
>
> Leo
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2014-03-05 7:09 ` Johan Claesson
@ 2014-03-06 2:07 ` Glenn Morris
2014-03-06 21:58 ` Johan Claesson
0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2014-03-06 2:07 UTC (permalink / raw)
To: 12357-done
Version: 24.4
On reflection, I think you were right from the start, and that this
command should simply ignore dir-locals, since they are not looked up
via load-path anyway. So I made that change. Sorry for the delay.
I do not think that a specialized command for dealing with dir-locals
is required. (We should add inheritance so it's not an issue.)
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
2014-03-06 2:07 ` Glenn Morris
@ 2014-03-06 21:58 ` Johan Claesson
0 siblings, 0 replies; 14+ messages in thread
From: Johan Claesson @ 2014-03-06 21:58 UTC (permalink / raw)
To: 12357
Good, thanks. I totally agree that is all that is needed for this
minor issue.
Regards,
/Johan
Glenn Morris <rgm@gnu.org> writes:
> Version: 24.4
>
> On reflection, I think you were right from the start, and that this
> command should simply ignore dir-locals, since they are not looked up
> via load-path anyway. So I made that change. Sorry for the delay.
> I do not think that a specialized command for dealing with dir-locals
> is required. (We should add inheritance so it's not an issue.)
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-03-06 21:58 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 13:38 bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el Johan Claesson
2012-09-05 16:23 ` Johan Claesson
2012-09-08 1:13 ` Glenn Morris
2012-09-08 14:08 ` Johan Claesson
2012-09-16 18:56 ` Johan Claesson
2014-02-26 8:49 ` Xue Fuqiao
2014-03-02 22:14 ` Johan Claesson
2014-03-02 22:36 ` Xue Fuqiao
2014-03-04 22:29 ` Johan Claesson
2014-03-05 0:54 ` Leo Liu
2014-03-05 7:09 ` Johan Claesson
2014-03-06 2:07 ` Glenn Morris
2014-03-06 21:58 ` Johan Claesson
2014-03-05 7:25 ` Johan Claesson
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.