lang/common-lisp: conform to new conventions
This commit is contained in:
parent
a146e61728
commit
02f2ad1e8d
2 changed files with 29 additions and 20 deletions
|
@ -1,7 +1,7 @@
|
||||||
;;; lang/common-lisp/autoload/common-lisp.el -*- lexical-binding: t; -*-
|
;;; lang/common-lisp/autoload/common-lisp.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;;;###autoload
|
;;;###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."
|
"In normal-state or motion-state, last sexp ends at point."
|
||||||
(if (and (not evil-move-beyond-eol)
|
(if (and (not evil-move-beyond-eol)
|
||||||
(or (evil-normal-state-p) (evil-motion-state-p)))
|
(or (evil-normal-state-p) (evil-motion-state-p)))
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
(sp-local-pair "'" "'" :actions nil)
|
(sp-local-pair "'" "'" :actions nil)
|
||||||
(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."
|
"Kill processes and leftover buffers when killing the last sly buffer."
|
||||||
(unless (cl-loop for buf in (delq (current-buffer) (buffer-list))
|
(unless (cl-loop for buf in (delq (current-buffer) (buffer-list))
|
||||||
if (and (buffer-local-value 'sly-mode buf)
|
if (and (buffer-local-value 'sly-mode buf)
|
||||||
|
@ -53,27 +53,29 @@
|
||||||
if (buffer-local-value 'sly-mode buf)
|
if (buffer-local-value 'sly-mode buf)
|
||||||
collect buf)))))
|
collect buf)))))
|
||||||
|
|
||||||
(defun +common-lisp|init-sly ()
|
(add-hook 'sly-mode-hook
|
||||||
"Attempt to auto-start sly when opening a lisp buffer."
|
(defun +common-lisp-init-sly-h ()
|
||||||
(cond ((or (doom-temp-buffer-p (current-buffer))
|
"Attempt to auto-start sly when opening a lisp buffer."
|
||||||
(sly-connected-p)))
|
(cond ((or (doom-temp-buffer-p (current-buffer))
|
||||||
((executable-find inferior-lisp-program)
|
(sly-connected-p)))
|
||||||
(let ((sly-auto-start 'always))
|
((executable-find inferior-lisp-program)
|
||||||
(sly-auto-start)
|
(let ((sly-auto-start 'always))
|
||||||
(add-hook 'kill-buffer-hook #'+common-lisp|cleanup-sly-maybe nil t)))
|
(sly-auto-start)
|
||||||
((message "WARNING: Couldn't find `inferior-lisp-program' (%s)"
|
(add-hook 'kill-buffer-hook #'+common-lisp--cleanup-sly-maybe-h nil t)))
|
||||||
inferior-lisp-program))))
|
((message "WARNING: Couldn't find `inferior-lisp-program' (%s)"
|
||||||
(add-hook 'sly-mode-hook #'+common-lisp|init-sly)
|
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
|
"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
|
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
|
installed through an external script (bin/doom), `load-file-name' is set to
|
||||||
bin/doom while packages at compile-time (not a runtime though)."
|
bin/doom while packages at compile-time (not a runtime though)."
|
||||||
|
:before #'sly-check-version
|
||||||
(unless sly-protocol-version
|
(unless sly-protocol-version
|
||||||
(setq sly-protocol-version (sly-version nil (locate-library "sly.el"))))
|
(setq sly-protocol-version (sly-version nil (locate-library "sly.el"))))
|
||||||
(advice-remove #'sly-check-version #'+common-lisp*refresh-sly-version))
|
(advice-remove #'sly-check-version #'+common-lisp*refresh-sly-version))
|
||||||
(advice-add #'sly-check-version :before #'+common-lisp*refresh-sly-version)
|
|
||||||
|
|
||||||
(map! :localleader
|
(map! :localleader
|
||||||
:map lisp-mode-map
|
:map lisp-mode-map
|
||||||
|
@ -138,14 +140,20 @@ bin/doom while packages at compile-time (not a runtime though)."
|
||||||
(when (featurep! :editor evil +everywhere)
|
(when (featurep! :editor evil +everywhere)
|
||||||
(add-hook 'sly-mode-hook #'evil-normalize-keymaps)
|
(add-hook 'sly-mode-hook #'evil-normalize-keymaps)
|
||||||
(add-hook 'sly-popup-buffer-mode-hook #'evil-normalize-keymaps)
|
(add-hook 'sly-popup-buffer-mode-hook #'evil-normalize-keymaps)
|
||||||
|
|
||||||
(unless evil-move-beyond-eol
|
(unless evil-move-beyond-eol
|
||||||
(advice-add #'sly-eval-last-expression :around #'+common-lisp*sly-last-sexp)
|
(dolist (fn '(sly-eval-last-expression
|
||||||
(advice-add #'sly-pprint-eval-last-expression :around #'+common-lisp*sly-last-sexp)
|
sly-pprint-eval-last-expression
|
||||||
(advice-add #'sly-eval-print-last-expression :around #'+common-lisp*sly-last-sexp)
|
sly-eval-print-last-expression
|
||||||
(advice-add #'sly-eval-last-expression-in-repl :around #'+common-lisp*sly-last-sexp))
|
sly-eval-last-expression-in-repl))
|
||||||
|
(advice-add fn :around #'+common-lisp--sly-last-sexp-a)))
|
||||||
(set-evil-initial-state!
|
(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)
|
'normal)
|
||||||
|
|
||||||
(evil-define-key 'insert sly-mrepl-mode-map
|
(evil-define-key 'insert sly-mrepl-mode-map
|
||||||
[S-return] #'newline-and-indent
|
[S-return] #'newline-and-indent
|
||||||
[backspace] #'sp-backward-delete-char
|
[backspace] #'sp-backward-delete-char
|
||||||
|
@ -239,6 +247,7 @@ bin/doom while packages at compile-time (not a runtime though)."
|
||||||
"q" 'quit-window
|
"q" 'quit-window
|
||||||
"r" 'sly-xref-retract)))
|
"r" 'sly-xref-retract)))
|
||||||
|
|
||||||
|
|
||||||
(use-package! sly-repl-ansi-color
|
(use-package! sly-repl-ansi-color
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue