core: cleanup layers discovery
Some directories were added twice. Make it more explicit in the code which directories we look into and filter out directories that don't exist. Emit a warning if an unknown directory is provided.
This commit is contained in:
parent
703733b46b
commit
f5957eb877
|
@ -1061,12 +1061,28 @@ Returns nil if the directory is not a category."
|
||||||
;; must have the final word on configuration choices. Let
|
;; must have the final word on configuration choices. Let
|
||||||
;; `dotspacemacs-directory' override the private directory if it exists.
|
;; `dotspacemacs-directory' override the private directory if it exists.
|
||||||
(setq configuration-layer--indexed-layers (make-hash-table :size 1024))
|
(setq configuration-layer--indexed-layers (make-hash-table :size 1024))
|
||||||
(let ((search-paths (append (list configuration-layer-directory)
|
(let ((search-paths (append
|
||||||
dotspacemacs-configuration-layer-path
|
;; layers shipped with spacemacs
|
||||||
(list configuration-layer-private-layer-directory)
|
(list configuration-layer-directory)
|
||||||
|
;; layers in private folder ~/.emacs.d/private
|
||||||
|
(list configuration-layer-private-directory)
|
||||||
|
;; layers in dotdirectory
|
||||||
(when dotspacemacs-directory
|
(when dotspacemacs-directory
|
||||||
(list dotspacemacs-directory))))
|
(list (expand-file-name (concat dotspacemacs-directory
|
||||||
|
"layers/"))))
|
||||||
|
;; additional layer directories provided by the user
|
||||||
|
dotspacemacs-configuration-layer-path))
|
||||||
(discovered '()))
|
(discovered '()))
|
||||||
|
;; filter out directories that don't exist
|
||||||
|
(setq search-paths (configuration-layer/filter-objects
|
||||||
|
search-paths
|
||||||
|
(lambda (x)
|
||||||
|
(let ((exists (file-exists-p x)))
|
||||||
|
(unless exists
|
||||||
|
(configuration-layer//warning
|
||||||
|
"Layer directory \"%s\" not found. Ignoring it."
|
||||||
|
x))
|
||||||
|
exists))))
|
||||||
;; depth-first search of subdirectories
|
;; depth-first search of subdirectories
|
||||||
(while search-paths
|
(while search-paths
|
||||||
(let ((current-path (car search-paths)))
|
(let ((current-path (car search-paths)))
|
||||||
|
@ -1093,7 +1109,9 @@ Returns nil if the directory is not a category."
|
||||||
(if indexed-layer
|
(if indexed-layer
|
||||||
;; the same layer may have been discovered twice,
|
;; the same layer may have been discovered twice,
|
||||||
;; in which case we don't need a warning
|
;; in which case we don't need a warning
|
||||||
(unless (string-equal (directory-file-name (oref indexed-layer :dir)) (directory-file-name sub))
|
(unless (string-equal
|
||||||
|
(directory-file-name (oref indexed-layer :dir))
|
||||||
|
(directory-file-name sub))
|
||||||
(configuration-layer//warning
|
(configuration-layer//warning
|
||||||
(concat
|
(concat
|
||||||
"Duplicated layer %s detected in directory \"%s\", "
|
"Duplicated layer %s detected in directory \"%s\", "
|
||||||
|
|
Loading…
Reference in a new issue