Better evil/REPL support
This commit is contained in:
parent
4882df4847
commit
2503232edf
9 changed files with 69 additions and 15 deletions
|
@ -70,5 +70,35 @@ If ARG is nil this function calls `recompile', otherwise it calls
|
|||
(insert (current-kill 0)))))
|
||||
(t (quickrun-replace-region beg end))))
|
||||
|
||||
(defvar narf--repl-buffer nil)
|
||||
;;;###autoload (autoload 'narf:repl "defuns-quickrun" nil t)
|
||||
(evil-define-command narf:repl (&optional bang)
|
||||
:repeat nil
|
||||
(interactive "<!>")
|
||||
(if (and narf--repl-buffer (buffer-live-p narf--repl-buffer))
|
||||
(if (popwin:popup-window-live-p)
|
||||
(popwin:select-popup-window)
|
||||
(popwin:pop-to-buffer narf--repl-buffer))
|
||||
(rtog/toggle-repl (if (use-region-p) 4))
|
||||
(setq narf--repl-buffer (current-buffer))))
|
||||
|
||||
;;;###autoload (autoload 'narf:repl-eval "defuns-quickrun" nil t)
|
||||
(evil-define-operator narf:repl-eval (&optional beg end bang)
|
||||
:type inclusive
|
||||
:repeat nil
|
||||
(interactive "<r><!>")
|
||||
(let ((region-p (use-region-p))
|
||||
(selection (s-trim (buffer-substring-no-properties beg end))))
|
||||
(narf:repl bang)
|
||||
(when (and region-p beg end)
|
||||
(let* ((buf narf--repl-buffer)
|
||||
(win (get-buffer-window buf)))
|
||||
(unless (eq buf popwin:popup-buffer)
|
||||
(popwin:pop-to-buffer buf nil t))
|
||||
(when (and narf--repl-buffer (buffer-live-p narf--repl-buffer))
|
||||
(with-current-buffer narf--repl-buffer
|
||||
(goto-char (point-max))
|
||||
(insert selection)))))))
|
||||
|
||||
(provide 'defuns-quickrun)
|
||||
;;; defuns-quickrun.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue