Fix loading of evil-collection-X from subdirs
Create autoloads for each of the setup functions in evil-collection. Add evil-collection-require, which is a version of require that knows where the evil-collection files live. Use evil-collection-require to fix header in evil-collection-woman. Update readme to reflect the fact that it's no longer necessary to load the evil-collection-X file to run evil-collection-X-setup
This commit is contained in:
parent
fdb7b3010b
commit
107ed151e9
|
@ -110,7 +110,7 @@ through removing their entry from `evil-collection-mode-list'."
|
|||
:type 'boolean
|
||||
:group 'evil-collection)
|
||||
|
||||
(defcustom evil-collection-mode-list
|
||||
(defvar evil-collection--supported-modes
|
||||
`(2048-game
|
||||
ag
|
||||
alchemist
|
||||
|
@ -240,6 +240,19 @@ through removing their entry from `evil-collection-mode-list'."
|
|||
xref
|
||||
youtube-dl
|
||||
(ztree ztree-diff))
|
||||
"List of modes supported by evil-collection. Elements are
|
||||
either target mode symbols or lists which `car' is the mode
|
||||
symbol and `cdr' the packages to register.")
|
||||
|
||||
(dolist (mode evil-collection--supported-modes)
|
||||
(let ((ec-mode-name (if (listp mode) (car mode) mode)))
|
||||
(autoload
|
||||
(intern (format "evil-collection-%s-setup" ec-mode-name))
|
||||
(expand-file-name
|
||||
(format "modes/%s/evil-collection-%s" ec-mode-name ec-mode-name)
|
||||
evil-collection-base-dir))))
|
||||
|
||||
(defcustom evil-collection-mode-list evil-collection--supported-modes
|
||||
"The list of modes which will be evilified by `evil-collection-init'.
|
||||
Elements are either target mode symbols or lists which `car' is the
|
||||
mode symbol and `cdr' the packages to register.
|
||||
|
@ -498,6 +511,20 @@ should consist of key swaps (e.g. \"a\" \"b\" is equivalent to \"a\" \"b\" \"b\"
|
|||
collect replacement and collect key))
|
||||
`(evil-collection-translate-key ,states ,keymaps ,@args))
|
||||
|
||||
;;;###autoload
|
||||
(defun evil-collection-require (mode &optional noerror)
|
||||
"Require the evil-collection-MODE file, but do not activate it.
|
||||
|
||||
MODE should be a symbol. This requires the evil-collection-MODE
|
||||
feature without needing to manipulate `load-path'. NOERROR is
|
||||
forwarded to `require'."
|
||||
(let* ((mode-name (symbol-name mode))
|
||||
(feature (intern (format "evil-collection-%s" mode-name)))
|
||||
(file (expand-file-name
|
||||
(format "modes/%s/evil-collection-%s" mode-name mode-name)
|
||||
evil-collection-base-dir)))
|
||||
(require feature file noerror)))
|
||||
|
||||
;;;###autoload
|
||||
(defun evil-collection-init (&optional modes)
|
||||
"Register the Evil bindings for all modes in `evil-collection-mode-list'.
|
||||
|
@ -506,7 +533,6 @@ Alternatively, you may register select bindings manually, for
|
|||
instance:
|
||||
|
||||
(with-eval-after-load 'calendar
|
||||
(require 'evil-collection-calendar)
|
||||
(evil-collection-calendar-setup))
|
||||
|
||||
If MODES is specified (as either one mode or a list of modes), use those modes
|
||||
|
@ -523,9 +549,7 @@ instead of the modes in `evil-collection-mode-list'."
|
|||
reqs (cdr mode)))
|
||||
(dolist (req reqs)
|
||||
(with-eval-after-load req
|
||||
(load (expand-file-name (format "modes/%s/evil-collection-%s" m m)
|
||||
evil-collection-base-dir)
|
||||
nil t)
|
||||
(evil-collection-require m)
|
||||
(funcall (intern (concat "evil-collection-" (symbol-name m)
|
||||
"-setup")))
|
||||
(let ((mode-keymaps
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
;;; Code:
|
||||
(require 'evil-collection)
|
||||
(require 'evil-collection-man) ; WoMan's keymap inherits from Man.
|
||||
(evil-collection-require 'man)
|
||||
(require 'woman)
|
||||
|
||||
(defconst evil-collection-woman-maps '(woman-mode-map))
|
||||
|
|
|
@ -41,7 +41,7 @@ more.
|
|||
|
||||
or mode-by-mode, for instance:
|
||||
|
||||
: (with-eval-after-load 'calendar (require 'evil-collection-calendar) (evil-collection-calendar-setup))
|
||||
: (with-eval-after-load 'calendar (evil-collection-calendar-setup))
|
||||
|
||||
or by providing an argument to ~evil-collection-init~:
|
||||
|
||||
|
|
Loading…
Reference in New Issue