diff --git a/core/core-defuns.el b/core/core-defuns.el index 14e859a17..424d3afd8 100644 --- a/core/core-defuns.el +++ b/core/core-defuns.el @@ -92,22 +92,27 @@ Examples: (declare (indent 1)) (let* ((minor-p (assoc mode minor-mode-alist))) `(progn - (,@(when match - `(add-to-list ',(if minor-p 'narf-auto-minor-mode-alist 'auto-mode-alist) - (cons ,match ',mode)))) - (,@(when files - (unless (or (listp files) (stringp files)) - (user-error "associate! :files expects a string or list of strings")) - (let ((hook-name (intern (format "narf--init-mode-%s" mode)))) - `(progn - (defun ,hook-name () - (when (and (not ,mode) - (narf/project-has-files ,@(-list files))) - (,mode 1))) - ,@(if (and in (listp in)) - (mapcar (lambda (h) `(add-hook ',h ',hook-name)) - (mapcar (lambda (m) (intern (format "%s-hook" m))) in)) - `((add-hook 'find-file-hook ',hook-name)))))))))) + (,@(cond ((or files in) + (when (and files (not (or (listp files) + (stringp files)))) + (user-error "associate! :files expects a string or list of strings")) + (let ((hook-name (intern (format "narf--init-mode-%s" mode)))) + `(progn + (defun ,hook-name () + (when (and (if ,match (string-match-p ,match (buffer-file-name)) t) + (or ,(not files) + (and (not ,mode) + (narf/project-has-files ,@(-list files))))) + (,mode 1))) + ,@(if (and in (listp in)) + (mapcar (lambda (h) `(add-hook ',h ',hook-name)) + (mapcar (lambda (m) (intern (format "%s-hook" m))) in)) + `((add-hook 'find-file-hook ',hook-name)))))) + (match + `(add-to-list ',(if minor-p 'narf-auto-minor-mode-alist 'auto-mode-alist) + (cons ,match ',mode))) + (t (user-error "associate! invalid rules for mode [%s] (in %s) (match %s) (files %s)" + mode in match files))))))) (after! evil ;; Register keywords for proper indentation (see `map!') diff --git a/modules/module-python.el b/modules/module-python.el index 611b4eaf5..13de3b13a 100644 --- a/modules/module-python.el +++ b/modules/module-python.el @@ -24,7 +24,7 @@ :commands nose-mode :preface (defvar nose-mode-map (make-sparse-keymap)) :init - (associate! nose-mode :pattern "/test_.+\\.py\\'") + (associate! nose-mode :match "/test_.+\\.py\\'") :config (map! :map nose-mode-map (:localleader diff --git a/modules/module-web.el b/modules/module-web.el index ac8fdceea..723b32e60 100644 --- a/modules/module-web.el +++ b/modules/module-web.el @@ -107,9 +107,12 @@ :keymap (make-sparse-keymap) (add-yas-minor-mode! 'jekyll-mode)) (associate! jekyll-mode - :match "/\\(css\\|_\\(layouts\\|posts\\|sass\\)\\)/.+$" + :match "/\\(\\(css\\|_\\(layouts\\|posts\\|sass\\)\\)/.+\\|.+.html\\)$" :files ("config.yml" "_layouts") :in (web-mode scss-mode html-mode markdown-mode)) +(add-hook! jekyll-mode + (when (eq major-mode 'web-mode) + (web-mode-set-engine "django"))) ;; (after! company-dict (add-to-list 'company-dict-minor-mode-alist 'jekyll-mode)) (define-minor-mode wordpress-mode @@ -118,8 +121,9 @@ :lighter " wp" :keymap (make-sparse-keymap) (add-yas-minor-mode! 'wordpress-mode)) -(associate! wordpress-mode :match "/wp-\\(content\\|admin\\|includes\\)/.+$") -(associate! wordpress-mode :match "/wp-.+\\.php$") +(associate! wordpress-mode + :match "/wp-\\(\\(content\\|admin\\|includes\\)/\\)?.+$" + :files ("wp-config.php" "wp-content")) ;; (after! company-dict (add-to-list 'company-dict-minor-mode-alist 'wordpress-mode)) (provide 'module-web)