From 9e8b33d6e1e9fd8be6763cddb6460956c863bb56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Kryger?= Date: Tue, 10 Dec 2024 12:55:08 +0000 Subject: [PATCH] Enable lexical-binding and disable flycheck-checkdoc in PP output buffers --- .ci/unit-tests.sh | 5 +++-- modules/init-elisp.el | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.ci/unit-tests.sh b/.ci/unit-tests.sh index 36d3a7ae..b474ae38 100755 --- a/.ci/unit-tests.sh +++ b/.ci/unit-tests.sh @@ -14,11 +14,12 @@ ${EMACS} -Q --batch \ exordium-spell-check nil) (load-file "'"${EMACS_DIR}"'/init.el") (load-file "'"${EMACS_DIR}"'/modules/init-bde-style.t.el") + (load-file "'"${EMACS_DIR}"'/modules/init-elisp.t.el") (load-file "'"${EMACS_DIR}"'/modules/init-forge.t.el") - (load-file "'"${EMACS_DIR}"'/modules/init-util.t.el") + (load-file "'"${EMACS_DIR}"'/modules/init-highlight.t.el") (load-file "'"${EMACS_DIR}"'/modules/init-lib.t.el") (load-file "'"${EMACS_DIR}"'/modules/init-require.t.el") - (load-file "'"${EMACS_DIR}"'/modules/init-highlight.t.el") + (load-file "'"${EMACS_DIR}"'/modules/init-util.t.el") (let ((print-level 50) (eval-expression-print-level 50) (eval-expression-print-length 1000) diff --git a/modules/init-elisp.el b/modules/init-elisp.el index 3f5a4115..be1722ac 100644 --- a/modules/init-elisp.el +++ b/modules/init-elisp.el @@ -20,6 +20,19 @@ (use-package elisp-mode :ensure nil :defer t + :functions (exordium--pp-last-sexp-filter-quote) + :init + + (defun exordium--pp-output-setup () + "Enable `lexical-binding' and disable `flycheck-checkdoc' in PP output buffers." + (when (string-match-p (rx "*Pp " (or "Eval" "Macroexpand") " Output*") + (buffer-name)) + (when (boundp 'flycheck-disabled-checkers) + (add-to-list 'flycheck-disabled-checkers 'emacs-lisp-checkdoc)) + (goto-char (point-min)) + (insert ";; -*- lexical-binding: t -*-\n\n") + (goto-char (point-min)) + (setq-local lexical-binding t))) :bind (:map emacs-lisp-mode-map ("M-C-g" . #'helm-imenu) @@ -34,7 +47,9 @@ ("C-c C-M-e" . #'pp-macroexpand-last-sexp) ("M-." . #'xref-find-definitions) ("M-," . #'xref-go-back) - ("M-r" . #'xref-find-references))) + ("M-r" . #'xref-find-references)) + :hook + (emacs-lisp-mode . exordium--pp-output-setup)) (use-package elisp-mode :ensure nil