From 1846984bd053fc3dad74eb07ce3ed6fb0305b49a Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Sun, 22 Jan 2017 13:41:04 -0500 Subject: [PATCH] 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. --- core/core-configuration-layer.el | 14 ++++++++++++-- layers/auto-layer.el | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/core-configuration-layer.el b/core/core-configuration-layer.el index ce24421ce..719232618 100644 --- a/core/core-configuration-layer.el +++ b/core/core-configuration-layer.el @@ -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." diff --git a/layers/auto-layer.el b/layers/auto-layer.el index 23f692d48..078dab72f 100644 --- a/layers/auto-layer.el +++ b/layers/auto-layer.el @@ -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))