Prevent recursive require errors with evil-org

Caused when evil-org-set-key-theme is called too early (somehow).

Also makes evil-org-key-theme customizable, so it doesn't override a
user's changes to it.

Reported by @majorgreys
This commit is contained in:
Henrik Lissner 2018-06-26 01:16:01 +02:00
parent 24fbf1bf0c
commit 14a6d7710c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -25,7 +25,7 @@
:when (featurep! :feature evil +everywhere) :when (featurep! :feature evil +everywhere)
:hook (org-mode . evil-org-mode) :hook (org-mode . evil-org-mode)
:init :init
(setq evil-org-key-theme '(navigation insert textobjects)) (defvar evil-org-key-theme '(navigation insert textobjects))
(add-hook 'org-load-hook #'+org|setup-evil) (add-hook 'org-load-hook #'+org|setup-evil)
(add-hook 'evil-org-mode-hook #'evil-normalize-keymaps) (add-hook 'evil-org-mode-hook #'evil-normalize-keymaps)
:config :config
@ -266,8 +266,10 @@ between the two."
[remap doom/backward-to-bol-or-indent] #'org-beginning-of-line [remap doom/backward-to-bol-or-indent] #'org-beginning-of-line
[remap doom/forward-to-last-non-comment-or-eol] #'org-end-of-line)) [remap doom/forward-to-last-non-comment-or-eol] #'org-end-of-line))
(defun +org|setup-evil (&rest _) (defun +org|setup-evil (&rest args)
(require 'evil-org) ;; In case this hook is used in an advice on `evil-org-set-key-theme', this
;; prevents recursive requires.
(unless args (require 'evil-org))
;; By default, TAB cycles the visibility of all children under the current ;; By default, TAB cycles the visibility of all children under the current
;; tree between three states. I want to toggle the tree between two states, ;; tree between three states. I want to toggle the tree between two states,
;; without affecting its children. ;; without affecting its children.