From fc1554f55c5463b2c26a62907b08115697bb71ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Fri, 9 Jan 2026 09:16:16 -0700 Subject: [PATCH] feat(emacs): handle repl --- .../users/msyds/emacs/lisp/syd/emacs-lisp.el | 3 +- .../home/users/msyds/emacs/lisp/syd/handle.el | 29 +++++++++++++------ .../home/users/msyds/emacs/lisp/syd/popups.el | 4 ++- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/modules/home/users/msyds/emacs/lisp/syd/emacs-lisp.el b/modules/home/users/msyds/emacs/lisp/syd/emacs-lisp.el index a38d58b..75a24cc 100755 --- a/modules/home/users/msyds/emacs/lisp/syd/emacs-lisp.el +++ b/modules/home/users/msyds/emacs/lisp/syd/emacs-lisp.el @@ -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) diff --git a/modules/home/users/msyds/emacs/lisp/syd/handle.el b/modules/home/users/msyds/emacs/lisp/syd/handle.el index 9a73a0f..8c7947e 100755 --- a/modules/home/users/msyds/emacs/lisp/syd/handle.el +++ b/modules/home/users/msyds/emacs/lisp/syd/handle.el @@ -72,11 +72,11 @@ (defun syd-handle-docs* (identifier) (interactive (list (symbol-name (symbol-at-point)))) (if-let* ((b (save-excursion - (save-window-excursion - (syd-handle-docs identifier))))) + (save-window-excursion + (syd-handle-docs identifier))))) (display-buffer b) - (message "Couldn't find documentation on %S" - (substring-no-properties identifier)))) + (error "Couldn't find documentation on %S" + (substring-no-properties identifier)))) ;;; REPL handler @@ -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)))) + (syd-handle-repl)))) + (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 diff --git a/modules/home/users/msyds/emacs/lisp/syd/popups.el b/modules/home/users/msyds/emacs/lisp/syd/popups.el index a248b81..ceb155d 100755 --- a/modules/home/users/msyds/emacs/lisp/syd/popups.el +++ b/modules/home/users/msyds/emacs/lisp/syd/popups.el @@ -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))