feat(emacs): handle repl
This commit is contained in:
@@ -47,7 +47,8 @@
|
|||||||
buffer)))
|
buffer)))
|
||||||
|
|
||||||
(syd-handle '(emacs-lisp-mode lisp-interaction-mode)
|
(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-add-hook '(emacs-lisp-mode-hook lisp-interaction-mode-hook)
|
||||||
#'syd-lisp-mode)
|
#'syd-lisp-mode)
|
||||||
|
|||||||
@@ -72,11 +72,11 @@
|
|||||||
(defun syd-handle-docs* (identifier)
|
(defun syd-handle-docs* (identifier)
|
||||||
(interactive (list (symbol-name (symbol-at-point))))
|
(interactive (list (symbol-name (symbol-at-point))))
|
||||||
(if-let* ((b (save-excursion
|
(if-let* ((b (save-excursion
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(syd-handle-docs identifier)))))
|
(syd-handle-docs identifier)))))
|
||||||
(display-buffer b)
|
(display-buffer b)
|
||||||
(message "Couldn't find documentation on %S"
|
(error "Couldn't find documentation on %S"
|
||||||
(substring-no-properties identifier))))
|
(substring-no-properties identifier))))
|
||||||
|
|
||||||
|
|
||||||
;;; REPL handler
|
;;; REPL handler
|
||||||
@@ -84,12 +84,23 @@
|
|||||||
(syd-define-handler-type repl ()
|
(syd-define-handler-type repl ()
|
||||||
"Return a buffer.")
|
"Return a buffer.")
|
||||||
|
|
||||||
(defun syd-handle-repl* ()
|
(defun syd-handle-repl* (&optional beg end)
|
||||||
|
(interactive "r")
|
||||||
(if-let* ((b (save-window-excursion
|
(if-let* ((b (save-window-excursion
|
||||||
(syd-handle-repl))))
|
(syd-handle-repl))))
|
||||||
(display-buffer b)
|
(let ((window (get-buffer-window b))
|
||||||
(message "Couldn't open a REPL for %S"
|
(prev-buffer (current-buffer)))
|
||||||
(substring-no-properties identifier))))
|
(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
|
;;; Keybinds
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
(defvar syd-new-popup-hook nil
|
(defvar syd-new-popup-hook nil
|
||||||
"Ran upon display of a new popup buffer. The current buffer will be the
|
"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
|
(defvar syd-help-popup-options
|
||||||
'(:select t :size 0.42 :popup t :align bottom))
|
'(:select t :size 0.42 :popup t :align bottom))
|
||||||
|
|||||||
Reference in New Issue
Block a user