Skip to content

Commit

Permalink
Add bqn-comint-use-overlay
Browse files Browse the repository at this point in the history
Show inline results using overlays, instead of just the minibuffer.
  • Loading branch information
slotThe committed Sep 8, 2024
1 parent 80f6be6 commit aead84e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions bqn-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

;; Author: Marshall Lochbaum <[email protected]>
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.1"))
;; Package-Requires: ((emacs "26.1") (eros "0.1.0"))
;; URL: https://github.com/museoa/bqn-mode
;; SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -304,6 +304,15 @@ BQN buffers (or recreate them)."
:type 'boolean
:group 'bqn)

(defcustom bqn-comint-use-overlay nil
"Should BQN use overlays for all `bqn-comint-eval-*' style functions?
If this is nil, print the result in the minibuffer instead."
:type 'boolean
:group 'bqn
:set (lambda (sym val)
(when val (require 'eros))
(set-default-toplevel-value sym val)))

;;;###autoload
(defun bqn-comint-buffer ()
"Run an inferior BQN process inside Emacs and return its buffer."
Expand Down Expand Up @@ -413,9 +422,14 @@ bqn-comint-process-session and echoes the result."
(error "Attempt to evaluate empty region to %s" bqn-comint--process-name))
(when (and bqn-comint-flash-on-send (pulse-available-p))
(pulse-momentary-highlight-region start end))
(let ((region (buffer-substring-no-properties start end))
(process (get-buffer-process (bqn-comint-buffer))))
(message "%s" (bqn--comint-call-process-silently process region))))
(let* ((region (buffer-substring-no-properties start end))
(process (get-buffer-process (bqn-comint-buffer)))
(response (bqn--comint-call-process-silently process region)))
(if bqn-comint-use-overlay
(eros--make-result-overlay response
:where end
:duration eros-eval-result-duration)
(message "%s" response))))

(defun bqn-comint-eval-dwim ()
"Evaluate the active region or the current line, displaying the result."
Expand Down

0 comments on commit aead84e

Please sign in to comment.