Skip to content

Commit

Permalink
core: add support for interpreter-mode-alist to layer lazy installation
Browse files Browse the repository at this point in the history
Update python lazy declaration as an example.
Still need to update the auto-layer.el file for other modes.
  • Loading branch information
syl20bnr committed Apr 2, 2017
1 parent c8595e7 commit 14ac814
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions core/core-configuration-layer.el
Expand Up @@ -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))))
Expand Down Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion layers/auto-layer.el
Expand Up @@ -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))

Expand Down

0 comments on commit 14ac814

Please sign in to comment.