New function `configuration-layer/layer-declaredp`

This commit is contained in:
syl20bnr 2014-12-26 15:14:15 -05:00
parent a9adee3039
commit 89fb5a46d6
2 changed files with 11 additions and 7 deletions

View File

@ -153,18 +153,22 @@ for that layer."
(push (cons (intern f) dir) result)))
result)))
(defun configuration-layer//declare-layer (sym)
"Declare a layer with SYM name (symbol). Return a cons cell (symbol . plist)
(defun configuration-layer//declare-layer (name)
"Declare a layer with NAME symbol. Return a cons cell (symbol . plist)
where `symbol' is the name of the layer and `plist' is a property list with
the following keys:
- `:dir' the absolute path to the base directory of the layer.
- `:ext-dir' the absolute path to the directory containing the extensions."
(let* ((sym-name (symbol-name sym))
(base-dir (configuration-layer/get-layer-path sym))
(dir (format "%s%s/" base-dir sym-name))
(let* ((namestr (symbol-name name))
(base-dir (configuration-layer/get-layer-path name))
(dir (format "%s%s/" base-dir namestr))
(ext-dir (format "%sextensions/" dir)))
(when (and base-dir (file-exists-p dir))
(cons sym (list :dir dir :ext-dir ext-dir)))))
(cons name (list :dir dir :ext-dir ext-dir)))))
(defun configuration-layer/layer-declaredp (layer)
"Return non-nil if LAYER symbol corresponds to a declared layer."
(ht-contains? configuration-layer-all-packages layer))
(defun configuration-layer/get-layers-list ()
"Return a list of all discovered layer symbols."

View File

@ -102,7 +102,7 @@
(evil-leader/set-key "cC" 'compile)
(evil-leader/set-key "cr" 'recompile)
;; narrow & widen -------------------------------------------------------------
(unless (ht-contains? configuration-layer-all-packages 'fancy-narrow)
(unless (configuration-layer/layer-declaredp 'fancy-narrow)
(evil-leader/set-key
"nr" 'narrow-to-region
"np" 'narrow-to-page