Use an alist for evil-collection-mode-list

This commit is contained in:
Pierre Neidhardt 2017-12-08 18:02:29 +01:00
parent 459395ebd3
commit 7a3f88668b
1 changed files with 65 additions and 70 deletions

View File

@ -36,76 +36,72 @@
"A set of keybindings for Evil mode" "A set of keybindings for Evil mode"
:group 'evil) :group 'evil)
(defcustom evil-collection-setup-minibuffer nil
"Whether to setup Evil bindings in the minibuffer."
:type 'boolean
:group 'evil-collection)
(defcustom evil-collection-mode-list (defcustom evil-collection-mode-list
`(ag `((ag t)
alchemist (alchemist t)
anaconda-mode (anaconda-mode t)
arc-mode (arc-mode t)
bookmark (bookmark t)
calendar (calendar t)
cider (cider t)
comint (comint t)
company (company t)
compile (compile t)
custom (custom t)
cus-theme (cus-theme t)
debbugs (debbugs t)
debug (debug t)
diff-mode (diff-mode t)
dired (dired t)
doc-view (doc-view t)
edebug (edebug t)
elfeed (elfeed t)
elisp-mode (elisp-mode t)
elisp-refs (elisp-refs t)
emms (emms t)
eshell (eshell t)
eval-sexp-fu (eval-sexp-fu t)
flycheck (flycheck t)
geiser (geiser t)
ggtags (ggtags t)
help (help t)
helm (helm t)
ibuffer (ibuffer t)
image (image t)
image+ (image+ t)
info (info t)
ivy (ivy t)
macrostep (macrostep t)
man (man t)
,@(when evil-collection-setup-minibuffer '(minibuffer)) (minibuffer nil)
;; occur is in replace.el which was built-in before Emacs 26. ;; occur is in replace.el which was built-in before Emacs 26.
(occur ,(if (<= emacs-major-version 25) "replace" 'replace)) (occur ,(if (<= emacs-major-version 25) "replace" 'replace))
outline (outline t)
p4 (p4 t)
(package-menu package) (package-menu package)
pass (pass t)
(pdf pdf-view) (pdf pdf-view)
proced (proced t)
prodigy (prodigy t)
profiler (profiler t)
rtags (rtags t)
slime (slime t)
(term term ansi-term multi-term) (term t ansi-term multi-term)
tide (tide t)
transmission (transmission t)
vlf (vlf t)
woman (woman t)
xref (xref t)
(ztree ztree-diff)) (ztree ztree-diff))
"The list of modes which will be evilified by `evil-collection-init'. "The alist of modes which will be evilified by `evil-collection-init'.
Elements are either target mode symbols or lists which `car' is the The values are list of target modes. If t, then the target
mode symbol and `cdr' the packages to register. name is the same as the key.
By default, `minibuffer' is not included because many users find By default, `minibuffer' is not activated by default because many
this confusing. It will be included if users find this confusing. It can be activated with
`evil-collection-setup-minibuffer' is set to t."
:type '(repeat (choice symbol sexp)) (setcar (alist-get 'minibuffer evil-collection-mode-list) t)"
:type '(alist)
:group 'evil-collection) :group 'evil-collection)
;;;###autoload ;;;###autoload
@ -120,15 +116,14 @@ instance:
(evil-collection-calendar-setup))" (evil-collection-calendar-setup))"
(interactive) (interactive)
(dolist (mode evil-collection-mode-list) (dolist (mode evil-collection-mode-list)
(let ((m mode) (let ((name (car mode))
(reqs (list mode))) (reqs (cdr mode)))
(when (listp mode)
(setq m (car mode)
reqs (cdr mode)))
(dolist (req reqs) (dolist (req reqs)
(when (eq req t)
(setq req name))
(with-eval-after-load req (with-eval-after-load req
(require (intern (concat "evil-collection-" (symbol-name m)))) (require (intern (concat "evil-collection-" (symbol-name name))))
(funcall (intern (concat "evil-collection-" (symbol-name m) "-setup")))))))) (funcall (intern (concat "evil-collection-" (symbol-name name) "-setup"))))))))
(provide 'evil-collection) (provide 'evil-collection)
;;; evil-collection.el ends here ;;; evil-collection.el ends here