core-lib: add auto-minor-mode, revise def-project-mode!
- Adds the auto-minor-mode package to replace our in-house implementation. - Merges associate! into the def-project-mode! macro because associate! on its own is less useful than auto-minor-mode-alist, auto-minor-mode-magic-alist or hooks. - Changes the semantics of :modes and :add-hooks properties of def-project-mode!. Its arguments are evaluated as is; lists will need to be quoted. squash! core-lib: remove associate! macro
This commit is contained in:
parent
3404899ec3
commit
0a84d2f0a9
15 changed files with 88 additions and 137 deletions
27
core/core.el
27
core/core.el
|
@ -299,33 +299,6 @@ users).")
|
|||
(add-hook 'focus-out-hook #'garbage-collect)
|
||||
|
||||
|
||||
;;
|
||||
;;; Minor mode version of `auto-mode-alist'
|
||||
|
||||
(defvar doom-auto-minor-mode-alist '()
|
||||
"Alist mapping filename patterns to corresponding minor mode functions, like
|
||||
`auto-mode-alist'. All elements of this alist are checked, meaning you can
|
||||
enable multiple minor modes for the same regexp.")
|
||||
|
||||
(defun doom-enable-minor-mode-maybe-h ()
|
||||
"Check file name against `doom-auto-minor-mode-alist'."
|
||||
(when (and buffer-file-name doom-auto-minor-mode-alist)
|
||||
(let ((name buffer-file-name)
|
||||
(remote-id (file-remote-p buffer-file-name))
|
||||
(alist doom-auto-minor-mode-alist))
|
||||
;; Remove backup-suffixes from file name.
|
||||
(setq name (file-name-sans-versions name))
|
||||
;; Remove remote file name identification.
|
||||
(when (and (stringp remote-id)
|
||||
(string-match (regexp-quote remote-id) name))
|
||||
(setq name (substring name (match-end 0))))
|
||||
(while (and alist (caar alist) (cdar alist))
|
||||
(if (string-match-p (caar alist) name)
|
||||
(funcall (cdar alist) 1))
|
||||
(setq alist (cdr alist))))))
|
||||
(add-hook 'find-file-hook #'doom-enable-minor-mode-maybe-h)
|
||||
|
||||
|
||||
;;
|
||||
;;; MODE-local-vars-hook
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue