From 8e49378b47157357227ac8f06c9d0a0062a4220c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 22 Apr 2021 10:20:25 -0500 Subject: Move lexical-binding setting into a hook *scratch* still doesn't apply the (setq-default lexical-binding t) form, but the advice I'd been giving `setup' broke the documentation generator function. So I just added lexical-binding to a hook when opening an emacs-lisp-mode buffer. Will this bite me later? Possibly. But I'll deal with that then. The worst that could happen is that I'd write another function, `setup-test' or something, that'd apply lexical-binding and then run `setup'. Or I could just set lexical-binding to t manually. Whatever. --- init.el | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/init.el b/init.el index d2a8960..3e19ec0 100644 --- a/init.el +++ b/init.el @@ -16,17 +16,6 @@ ;;; Code: -;; Let's use lexical binding by default, shall we? -(setq-default lexical-binding t) - -;; For some reason, the above setting doesn't translate to the *scratch* -;; buffer, where I try out packages. -(advice-add 'setup :around - (defun acdw/setup-lexical-advice (orig-fun &rest args) - "Wrap `setup' in a `lexical-binding' form." - (let ((lexical-binding t)) - (apply orig-fun args)))) - ;;; Necessary packages @@ -843,6 +832,11 @@ if ripgrep is installed, otherwise `consult-grep'." eval-expression-print-level nil lisp-indent-function #'lisp-indent-function) + (defun acdw/enforce-lexical-binding () + (setq lexical-binding t)) + + (add-hook 'emacs-lisp-mode-hook #'acdw/enforce-lexical-binding) + (defun acdw/eval-region-or-buffer () (interactive) (if (region-active-p) -- cgit 1.4.1-21-gabe81