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
|
:type 'boolean
|
||||||
:group 'evil-collection)
|
:group 'evil-collection)
|
||||||
|
|
||||||
(defcustom evil-collection-mode-list
|
(defvar evil-collection--supported-modes
|
||||||
`(2048-game
|
`(2048-game
|
||||||
ag
|
ag
|
||||||
alchemist
|
alchemist
|
||||||
|
@ -240,6 +240,19 @@ through removing their entry from `evil-collection-mode-list'."
|
||||||
xref
|
xref
|
||||||
youtube-dl
|
youtube-dl
|
||||||
(ztree ztree-diff))
|
(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'.
|
"The list of modes which will be evilified by `evil-collection-init'.
|
||||||
Elements are either target mode symbols or lists which `car' is the
|
Elements are either target mode symbols or lists which `car' is the
|
||||||
mode symbol and `cdr' the packages to register.
|
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))
|
collect replacement and collect key))
|
||||||
`(evil-collection-translate-key ,states ,keymaps ,@args))
|
`(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
|
;;;###autoload
|
||||||
(defun evil-collection-init (&optional modes)
|
(defun evil-collection-init (&optional modes)
|
||||||
"Register the Evil bindings for all modes in `evil-collection-mode-list'.
|
"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:
|
instance:
|
||||||
|
|
||||||
(with-eval-after-load 'calendar
|
(with-eval-after-load 'calendar
|
||||||
(require 'evil-collection-calendar)
|
|
||||||
(evil-collection-calendar-setup))
|
(evil-collection-calendar-setup))
|
||||||
|
|
||||||
If MODES is specified (as either one mode or a list of modes), use those modes
|
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)))
|
reqs (cdr mode)))
|
||||||
(dolist (req reqs)
|
(dolist (req reqs)
|
||||||
(with-eval-after-load req
|
(with-eval-after-load req
|
||||||
(load (expand-file-name (format "modes/%s/evil-collection-%s" m m)
|
(evil-collection-require m)
|
||||||
evil-collection-base-dir)
|
|
||||||
nil t)
|
|
||||||
(funcall (intern (concat "evil-collection-" (symbol-name m)
|
(funcall (intern (concat "evil-collection-" (symbol-name m)
|
||||||
"-setup")))
|
"-setup")))
|
||||||
(let ((mode-keymaps
|
(let ((mode-keymaps
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'evil-collection)
|
(require 'evil-collection)
|
||||||
(require 'evil-collection-man) ; WoMan's keymap inherits from Man.
|
(evil-collection-require 'man)
|
||||||
(require 'woman)
|
(require 'woman)
|
||||||
|
|
||||||
(defconst evil-collection-woman-maps '(woman-mode-map))
|
(defconst evil-collection-woman-maps '(woman-mode-map))
|
||||||
|
|
|
@ -41,7 +41,7 @@ more.
|
||||||
|
|
||||||
or mode-by-mode, for instance:
|
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~:
|
or by providing an argument to ~evil-collection-init~:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue