tools/eval: make +overlay display errors too
This commit is contained in:
parent
213a6fda86
commit
68ffc3cf96
1 changed files with 21 additions and 12 deletions
|
@ -68,23 +68,32 @@ buffer rather than an overlay on the line at point or the minibuffer.")
|
||||||
(with-selected-window win
|
(with-selected-window win
|
||||||
(goto-char (point-min))))))
|
(goto-char (point-min))))))
|
||||||
|
|
||||||
;; Display evaluation results in an overlay next to the cursor. If the output
|
;; Display evaluation results in an overlay at the end of the current line. If
|
||||||
;; is more than 4 lines long, it is displayed in a popup.
|
;; the output is more than `+eval-popup-min-lines' (4) lines long, it is
|
||||||
|
;; displayed in a popup.
|
||||||
(when (featurep! +overlay)
|
(when (featurep! +overlay)
|
||||||
|
(defadvice! +eval--show-output-in-overlay-a (fn)
|
||||||
|
:filter-return #'quickrun--make-sentinel
|
||||||
|
(lambda (process event)
|
||||||
|
(funcall fn process event)
|
||||||
|
(with-current-buffer quickrun--buffer-name
|
||||||
|
(when (> (buffer-size) 0)
|
||||||
|
(+eval-display-results
|
||||||
|
(string-trim (buffer-string))
|
||||||
|
quickrun--original-buffer)))))
|
||||||
|
|
||||||
|
;; Suppress quickrun's popup window because we're using an overlay instead.
|
||||||
(defadvice! +eval--inhibit-quickrun-popup-a (buf cb)
|
(defadvice! +eval--inhibit-quickrun-popup-a (buf cb)
|
||||||
:override #'quickrun--pop-to-buffer
|
:override #'quickrun--pop-to-buffer
|
||||||
(setq quickrun--original-buffer (current-buffer))
|
(setq quickrun--original-buffer (current-buffer))
|
||||||
(with-current-buffer buf
|
(save-window-excursion
|
||||||
|
(with-current-buffer (pop-to-buffer buf)
|
||||||
(setq quickrun-option-outputter #'ignore)
|
(setq quickrun-option-outputter #'ignore)
|
||||||
(funcall cb)))
|
(funcall cb))))
|
||||||
|
|
||||||
(advice-add #'quickrun--recenter :override #'ignore)
|
;; HACK Without this, `+eval--inhibit-quickrun-popup-a' throws a
|
||||||
(add-hook! 'quickrun-after-run-hook
|
;; window-live-p error because no window exists to be recentered!
|
||||||
(defun +eval-display-in-popup-overlay-h ()
|
(advice-add #'quickrun--recenter :override #'ignore)))
|
||||||
(+eval-display-results
|
|
||||||
(with-current-buffer quickrun--buffer-name
|
|
||||||
(string-trim (buffer-string)))
|
|
||||||
quickrun--original-buffer)))))
|
|
||||||
|
|
||||||
|
|
||||||
(use-package! eros
|
(use-package! eros
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue