diff --git a/modules/lang/common-lisp/autoload/common-lisp.el b/modules/lang/common-lisp/autoload/common-lisp.el index 7fd720f11..cd13df8bb 100644 --- a/modules/lang/common-lisp/autoload/common-lisp.el +++ b/modules/lang/common-lisp/autoload/common-lisp.el @@ -1,7 +1,7 @@ ;;; lang/common-lisp/autoload/common-lisp.el -*- lexical-binding: t; -*- ;;;###autoload -(defun +common-lisp*sly-last-sexp (command &rest args) +(defun +common-lisp--sly-last-sexp-a (command &rest args) "In normal-state or motion-state, last sexp ends at point." (if (and (not evil-move-beyond-eol) (or (evil-normal-state-p) (evil-motion-state-p))) diff --git a/modules/lang/common-lisp/config.el b/modules/lang/common-lisp/config.el index 1691044fc..69862a2e1 100644 --- a/modules/lang/common-lisp/config.el +++ b/modules/lang/common-lisp/config.el @@ -39,7 +39,7 @@ (sp-local-pair "'" "'" :actions nil) (sp-local-pair "`" "`" :actions nil)) - (defun +common-lisp|cleanup-sly-maybe () + (defun +common-lisp--cleanup-sly-maybe-h () "Kill processes and leftover buffers when killing the last sly buffer." (unless (cl-loop for buf in (delq (current-buffer) (buffer-list)) if (and (buffer-local-value 'sly-mode buf) @@ -53,27 +53,29 @@ if (buffer-local-value 'sly-mode buf) collect buf))))) - (defun +common-lisp|init-sly () - "Attempt to auto-start sly when opening a lisp buffer." - (cond ((or (doom-temp-buffer-p (current-buffer)) - (sly-connected-p))) - ((executable-find inferior-lisp-program) - (let ((sly-auto-start 'always)) - (sly-auto-start) - (add-hook 'kill-buffer-hook #'+common-lisp|cleanup-sly-maybe nil t))) - ((message "WARNING: Couldn't find `inferior-lisp-program' (%s)" - inferior-lisp-program)))) - (add-hook 'sly-mode-hook #'+common-lisp|init-sly) + (add-hook 'sly-mode-hook + (defun +common-lisp-init-sly-h () + "Attempt to auto-start sly when opening a lisp buffer." + (cond ((or (doom-temp-buffer-p (current-buffer)) + (sly-connected-p))) + ((executable-find inferior-lisp-program) + (let ((sly-auto-start 'always)) + (sly-auto-start) + (add-hook 'kill-buffer-hook #'+common-lisp--cleanup-sly-maybe-h nil t))) + ((message "WARNING: Couldn't find `inferior-lisp-program' (%s)" + inferior-lisp-program))))) - (defun +common-lisp*refresh-sly-version (version conn) + ;; REVIEW Do we still need this? Package autoloads are now wrapped in a let + ;; block that letbinds `load-file-name' to their source. + (defadvice! +common-lisp--refresh-sly-version-a (version conn) "Update `sly-protocol-version', which will likely be incorrect or nil due to an issue where `load-file-name' is incorrect. Because Doom's packages are installed through an external script (bin/doom), `load-file-name' is set to bin/doom while packages at compile-time (not a runtime though)." + :before #'sly-check-version (unless sly-protocol-version (setq sly-protocol-version (sly-version nil (locate-library "sly.el")))) (advice-remove #'sly-check-version #'+common-lisp*refresh-sly-version)) - (advice-add #'sly-check-version :before #'+common-lisp*refresh-sly-version) (map! :localleader :map lisp-mode-map @@ -138,14 +140,20 @@ bin/doom while packages at compile-time (not a runtime though)." (when (featurep! :editor evil +everywhere) (add-hook 'sly-mode-hook #'evil-normalize-keymaps) (add-hook 'sly-popup-buffer-mode-hook #'evil-normalize-keymaps) + (unless evil-move-beyond-eol - (advice-add #'sly-eval-last-expression :around #'+common-lisp*sly-last-sexp) - (advice-add #'sly-pprint-eval-last-expression :around #'+common-lisp*sly-last-sexp) - (advice-add #'sly-eval-print-last-expression :around #'+common-lisp*sly-last-sexp) - (advice-add #'sly-eval-last-expression-in-repl :around #'+common-lisp*sly-last-sexp)) + (dolist (fn '(sly-eval-last-expression + sly-pprint-eval-last-expression + sly-eval-print-last-expression + sly-eval-last-expression-in-repl)) + (advice-add fn :around #'+common-lisp--sly-last-sexp-a))) (set-evil-initial-state! - '(sly-db-mode sly-inspector-mode sly-popup-buffer-mode sly-xref-mode) + '(sly-db-mode + sly-inspector-mode + sly-popup-buffer-mode + sly-xref-mode) 'normal) + (evil-define-key 'insert sly-mrepl-mode-map [S-return] #'newline-and-indent [backspace] #'sp-backward-delete-char @@ -239,6 +247,7 @@ bin/doom while packages at compile-time (not a runtime though)." "q" 'quit-window "r" 'sly-xref-retract))) + (use-package! sly-repl-ansi-color :defer t :init