feat(emacs): handle repl

This commit is contained in:
2026-01-09 09:16:16 -07:00
parent b0f3dfc189
commit fc1554f55c
3 changed files with 25 additions and 11 deletions

View File

@@ -47,7 +47,8 @@
buffer)))
(syd-handle '(emacs-lisp-mode lisp-interaction-mode)
:docs #'syd-elisp-handle-docs)
:docs #'syd-elisp-handle-docs
:repl #'syd-elisp-open-repl)
(syd-add-hook '(emacs-lisp-mode-hook lisp-interaction-mode-hook)
#'syd-lisp-mode)

View File

@@ -75,7 +75,7 @@
(save-window-excursion
(syd-handle-docs identifier)))))
(display-buffer b)
(message "Couldn't find documentation on %S"
(error "Couldn't find documentation on %S"
(substring-no-properties identifier))))
@@ -84,12 +84,23 @@
(syd-define-handler-type repl ()
"Return a buffer.")
(defun syd-handle-repl* ()
(defun syd-handle-repl* (&optional beg end)
(interactive "r")
(if-let* ((b (save-window-excursion
(syd-handle-repl))))
(display-buffer b)
(message "Couldn't open a REPL for %S"
(substring-no-properties identifier))))
(let ((window (get-buffer-window b))
(prev-buffer (current-buffer)))
(popper-select-popup-at-bottom b)
(when (and beg end)
(end-of-buffer)
(insert (with-current-buffer prev-buffer
(buffer-substring-no-properties beg end)))
(with-current-buffer prev-buffer
(evil-active-region -1)))
(unless window
(end-of-buffer)
(evil-append-line 1)))
(error "Couldn't open a REPL for %S" major-mode)))
;;; Keybinds

View File

@@ -5,7 +5,9 @@
(defvar syd-new-popup-hook nil
"Ran upon display of a new popup buffer. The current buffer will be the
popup.")
popup. This differs from `popper-open-popup-hook' in that the hooks
are only ran *a single time* upon the buffer's first time being
displayed, rather than each time it is displayed.")
(defvar syd-help-popup-options
'(:select t :size 0.42 :popup t :align bottom))