core: add support for interpreter-mode-alist to layer lazy installation

Update python lazy declaration as an example.
Still need to update the auto-layer.el file for other modes.
This commit is contained in:
syl20bnr 2017-01-22 13:41:04 -05:00
parent 220bbabd36
commit 1846984bd0
2 changed files with 13 additions and 3 deletions

View File

@ -949,7 +949,8 @@ USEDP if non-nil indicates that made packages are used packages."
"Configure auto-installation of layer with name LAYER-NAME."
(declare (indent 1))
(when (configuration-layer//lazy-install-p layer-name)
(let ((extensions (spacemacs/mplist-get props :extensions)))
(let ((extensions (spacemacs/mplist-get props :extensions))
(interpreter (plist-get props :interpreter)))
(when (configuration-layer/layer-usedp layer-name)
(let* ((layer (configuration-layer/get-layer layer-name))
(package-names (when layer (cfgl-layer-owned-packages layer))))
@ -980,7 +981,16 @@ USEDP if non-nil indicates that made packages are used packages."
'auto-mode-alist
`(,ext . (lambda ()
(configuration-layer//auto-mode
',layer-name ',mode)))))))))
',layer-name ',mode))))
))
;; configure `interpreter-mode-alist'
(when interpreter
(let ((regex (car interpreter))
(mode (cadr interpreter)))
(add-to-list
'interpreter-mode-alist
`(,regex . (lambda () (configuration-layer//auto-mode
',layer-name ',mode)))))))))
(defun configuration-layer//auto-mode (layer-name mode)
"Auto mode support of lazily installed layers."

View File

@ -87,7 +87,7 @@
(configuration-layer/lazy-install 'python :extensions '("\\(\\.pyx\\'\\|\\.pxd\\'\\|\\.pxi\\'\\)" cython-mode))
(configuration-layer/lazy-install 'python :extensions '("\\(\\.hy\\'\\)" hy-mode))
(configuration-layer/lazy-install 'python :extensions '("\\(\\.pip\\'\\|requirements\\(?:.\\|\n\\)*\\.txt\\'\\)" pip-requirements-mode))
(configuration-layer/lazy-install 'python :extensions '("\\(\\.py\\'\\)" python-mode))
(configuration-layer/lazy-install 'python :extensions '("\\(\\.py\\'\\)" python-mode) :interpreter '("python[0-9.]*" python-mode))
(configuration-layer/lazy-install 'racket :extensions '("\\(\\.rkt[dl]?\\'\\)" racket-mode))