From a4a0441ec9d5f41ee55a6a3ff811f24d78d50ebc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 29 Jul 2018 17:58:15 +0200 Subject: [PATCH] Rewrite comments for forced deferral of elisp-mode Made clearer and more succinct. --- modules/lang/emacs-lisp/config.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/modules/lang/emacs-lisp/config.el b/modules/lang/emacs-lisp/config.el index 2f2a3b441..3be19de8c 100644 --- a/modules/lang/emacs-lisp/config.el +++ b/modules/lang/emacs-lisp/config.el @@ -1,21 +1,19 @@ ;;; lang/emacs-lisp/config.el -*- lexical-binding: t; -*- -;; `elisp-mode' is always loaded at startup, so to lazy load its config we need -;; to be creative. So we configure it the first tiem `emacs-lisp-mode' is run. -(advice-add #'emacs-lisp-mode :before #'+emacs-lisp|init) -;; And we remove `elisp-mode' so later invokations of (after! elisp-mode ...) -;; work as expected. +;; `elisp-mode' is loaded at startup. In order to lazy load its config we need +;; to pretend it isn't loaded (delq 'elisp-mode features) +;; ...until the first time `emacs-lisp-mode' runs +(advice-add #'emacs-lisp-mode :before #'+emacs-lisp|init) (defun +emacs-lisp|init (&rest _) - ;; Some plugins (like yasnippet) will run `emacs-lisp-mode' early, prematurely - ;; triggering this function in a non-ideal environment (`emacs-lisp-mode-hook' - ;; is let-bound to nil). This breaks a lot of Doom setters, because they try - ;; to add hooks to `emacs-lisp-mode-hook'! - ;; - ;; This means, in some sessions, elisp-mode is never configured properly, so - ;; we have to make extra sure `emacs-lisp-mode' was executed interactively. + ;; Some plugins (like yasnippet) run `emacs-lisp-mode' early, to parse some + ;; elisp. This would prematurely trigger this function. In these cases, + ;; `emacs-lisp-mode-hook' is let-bound to nil or its hooks are delayed, so if + ;; we see either, keep pretending elisp-mode isn't loaded. (when (and emacs-lisp-mode-hook (not delay-mode-hooks)) + ;; Otherwise, announce to the world elisp-mode has been loaded, so `after!' + ;; handlers can respond and configure elisp-mode as expected. (provide 'elisp-mode) (advice-remove #'emacs-lisp-mode #'+emacs-lisp|init)))