tools/eval: make +overlay display errors too

This commit is contained in:
Henrik Lissner 2019-12-22 23:47:54 -05:00
parent 213a6fda86
commit 68ffc3cf96
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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