From c5c8929180c228d66e3b23d1f609cf944e3bb145 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 10 Apr 2021 17:25:22 -0500 Subject: Add `:mode' setup form (:mode EXTENSION) expands to (add-to-list 'auto-mode-alist '(EXTENSION . setup-mode)). --- init.el | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/init.el b/init.el index a53dada..1784039 100644 --- a/init.el +++ b/init.el @@ -45,6 +45,12 @@ :documentation "Bind KEY to COMMAND in `acdw/leader' (C-z) map." :repeatable t) +(setup-define :mode + (lambda (ext) + `(add-to-list 'auto-mode-alist '(,ext . setup-mode))) + :documentation "Add SETUP-MODE to `auto-mode-alist' for EXTENSION." + :repeatable t) + ;;; `no-littering' (setup (:straight no-littering) (:option no-littering-etc-directory (acdw/dir) @@ -408,8 +414,7 @@ (setup (:straight (gemini-mode :host nil :repo "https://git.carcosa.net/jmcbray/gemini.el.git")) - (:option (append auto-mode-alist) - '("\\.\\(gemini\\|gmi\\)\\'" . gemini-mode))) + (:mode "\\.\\(gemini\\|gmi\\)\\'")) (setup dired (:option dired-recursive-copies 'always @@ -450,8 +455,8 @@ magit-popup-display-buffer-action '((display-buffer-same-window)))) (setup (:straight nov) - (:option nov-text-width fill-column - (append auto-mode-alist) '("\\.epub\\'" . nov-mode))) + (:option nov-text-width fill-column) + (:mode "\\.epub\\'")) (when (eq acdw/system :home) (setup (:straight pdf-tools) @@ -784,12 +789,11 @@ don't want." (when (executable-find "fennel") (setup (:straight fennel-mode) - (autoload 'fennel-mode "fennel-mode" nil t) (autoload 'fennel-repl "fennel-mode" nil t) - (:option (append auto-mode-alist) '("\\.fnl\\'" . fennel-mode)))) + (:mode "\\.fnl\\'"))) (setup (:straight lua-mode) - (:option (append auto-mode-alist) '("\\.lua\\'" . lua-mode))) + (:mode "\\.lua\\'")) (setup sh-mode (:option sh-basic-offset tab-width @@ -812,15 +816,13 @@ don't want." (:option css-level-offset 2 js-indent-level 2 sgml-indent-offset 2) - (dolist (extension '("\\(p\\|dj\\)?html" - "html?" - "\\(tpl\\.\\)?php" - "[agj]sp" - "as[cp]x" - "erb" - "mustache")) - (add-to-list 'auto-mode-alist - `(,(concat "\\." extension "\\'") . web-mode)))) + (:mode "\\.\\(p\\|dj\\)?html\\'" + "\\.html?\\'" + "\\.\\(tpl\\.\\)?php\\'" + "\\.[agj]sp\\'" + "\\.as[cp]x\\'" + "\\.erb\\'" + "\\.mustache\\'")) (when (locate-library "gforth") (autoload 'forth-mode "gforth") -- cgit 1.4.1-21-gabe81