mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-08-10 10:01:14 +10:00
Updating Doom Emacs.
This commit is contained in:
@@ -3,27 +3,22 @@
|
||||
;;;###autoload
|
||||
(defun +eval-display-results-in-popup (output &optional _source-buffer)
|
||||
"Display OUTPUT in a popup buffer."
|
||||
(if (with-temp-buffer
|
||||
(insert output)
|
||||
(>= (count-lines (point-min) (point-max))
|
||||
+eval-popup-min-lines))
|
||||
(let ((output-buffer (get-buffer-create "*doom eval*"))
|
||||
(origin (selected-window)))
|
||||
(with-current-buffer output-buffer
|
||||
(setq-local scroll-margin 0)
|
||||
(erase-buffer)
|
||||
(insert output)
|
||||
(goto-char (point-min))
|
||||
(if (fboundp '+word-wrap-mode)
|
||||
(+word-wrap-mode +1)
|
||||
(visual-line-mode +1)))
|
||||
(when-let (win (display-buffer output-buffer))
|
||||
(fit-window-to-buffer
|
||||
win (/ (frame-height) 2)
|
||||
nil (/ (frame-width) 2)))
|
||||
(select-window origin)
|
||||
output-buffer)
|
||||
(message "%s" output)))
|
||||
(let ((output-buffer (get-buffer-create "*doom eval*"))
|
||||
(origin (selected-window)))
|
||||
(with-current-buffer output-buffer
|
||||
(setq-local scroll-margin 0)
|
||||
(erase-buffer)
|
||||
(insert output)
|
||||
(goto-char (point-min))
|
||||
(if (fboundp '+word-wrap-mode)
|
||||
(+word-wrap-mode +1)
|
||||
(visual-line-mode +1)))
|
||||
(when-let (win (display-buffer output-buffer))
|
||||
(fit-window-to-buffer
|
||||
win (/ (frame-height) 2)
|
||||
nil (/ (frame-width) 2)))
|
||||
(select-window origin)
|
||||
output-buffer))
|
||||
|
||||
;;;###autoload
|
||||
(defun +eval-display-results-in-overlay (output &optional source-buffer)
|
||||
@@ -42,8 +37,14 @@
|
||||
(funcall (if (or current-prefix-arg
|
||||
(with-temp-buffer
|
||||
(insert output)
|
||||
(>= (count-lines (point-min) (point-max))
|
||||
+eval-popup-min-lines))
|
||||
(or (>= (count-lines (point-min) (point-max))
|
||||
+eval-popup-min-lines)
|
||||
(>= (string-width
|
||||
(buffer-substring (point-min)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(line-end-position))))
|
||||
(window-width))))
|
||||
(not (require 'eros nil t)))
|
||||
#'+eval-display-results-in-popup
|
||||
#'+eval-display-results-in-overlay)
|
||||
|
||||
@@ -37,8 +37,10 @@ recognized:
|
||||
"Alist mapping major modes to interactive runner functions.")
|
||||
|
||||
;;;###autodef
|
||||
(defun set-eval-handler! (mode command)
|
||||
"Define a code evaluator for major mode MODE with `quickrun'.
|
||||
(defun set-eval-handler! (modes command)
|
||||
"Define a code evaluator for major mode MODES with `quickrun'.
|
||||
|
||||
MODES can be list of major mode symbols, or a single one.
|
||||
|
||||
1. If MODE is a string and COMMAND is the string, MODE is a file regexp and
|
||||
COMMAND is a string key for an entry in `quickrun-file-alist'.
|
||||
@@ -50,17 +52,18 @@ recognized:
|
||||
4. If MODE is not a string and COMMANd is a symbol, add it to
|
||||
`+eval-runners', which is used by `+eval/region'."
|
||||
(declare (indent defun))
|
||||
(cond ((symbolp command)
|
||||
(push (cons mode command) +eval-runners))
|
||||
((stringp command)
|
||||
(after! quickrun
|
||||
(push (cons mode command)
|
||||
(if (stringp mode)
|
||||
quickrun-file-alist
|
||||
quickrun--major-mode-alist))))
|
||||
((listp command)
|
||||
(after! quickrun
|
||||
(quickrun-add-command
|
||||
(or (cdr (assq mode quickrun--major-mode-alist))
|
||||
(string-remove-suffix "-mode" (symbol-name mode)))
|
||||
command :mode mode)))))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(cond ((symbolp command)
|
||||
(push (cons mode command) +eval-runners))
|
||||
((stringp command)
|
||||
(after! quickrun
|
||||
(push (cons mode command)
|
||||
(if (stringp mode)
|
||||
quickrun-file-alist
|
||||
quickrun--major-mode-alist))))
|
||||
((listp command)
|
||||
(after! quickrun
|
||||
(quickrun-add-command
|
||||
(or (cdr (assq mode quickrun--major-mode-alist))
|
||||
(string-remove-suffix "-mode" (symbol-name mode)))
|
||||
command :mode mode))))))
|
||||
|
||||
@@ -68,23 +68,32 @@ buffer rather than an overlay on the line at point or the minibuffer.")
|
||||
(with-selected-window win
|
||||
(goto-char (point-min))))))
|
||||
|
||||
;; Display evaluation results in an overlay next to the cursor. If the output
|
||||
;; is more than 4 lines long, it is displayed in a popup.
|
||||
;; Display evaluation results in an overlay at the end of the current line. If
|
||||
;; the output is more than `+eval-popup-min-lines' (4) lines long, it is
|
||||
;; displayed in a popup.
|
||||
(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)
|
||||
:override #'quickrun--pop-to-buffer
|
||||
(setq quickrun--original-buffer (current-buffer))
|
||||
(with-current-buffer buf
|
||||
(setq quickrun-option-outputter #'ignore)
|
||||
(funcall cb)))
|
||||
(save-window-excursion
|
||||
(with-current-buffer (pop-to-buffer buf)
|
||||
(setq quickrun-option-outputter #'ignore)
|
||||
(funcall cb))))
|
||||
|
||||
(advice-add #'quickrun--recenter :override #'ignore)
|
||||
(add-hook! 'quickrun-after-run-hook
|
||||
(defun +eval-display-in-popup-overlay-h ()
|
||||
(+eval-display-results
|
||||
(with-current-buffer quickrun--buffer-name
|
||||
(string-trim (buffer-string)))
|
||||
quickrun--original-buffer)))))
|
||||
;; HACK Without this, `+eval--inhibit-quickrun-popup-a' throws a
|
||||
;; window-live-p error because no window exists to be recentered!
|
||||
(advice-add #'quickrun--recenter :override #'ignore)))
|
||||
|
||||
|
||||
(use-package! eros
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; tools/eval/packages.el
|
||||
|
||||
(package! quickrun)
|
||||
(package! quickrun :pin "c6ce1f315b768af8688d06bc57d2eb403f875a63")
|
||||
(when (featurep! +overlay)
|
||||
(package! eros))
|
||||
(package! eros :pin "dd8910279226259e100dab798b073a52f9b4233a"))
|
||||
|
||||
Reference in New Issue
Block a user