2019-04-21 19:59:44 -04:00
|
|
|
;;; tools/eval/config.el -*- lexical-binding: t; -*-
|
2017-02-13 16:57:08 -05:00
|
|
|
|
2017-03-04 18:28:51 -05:00
|
|
|
;; remove ellipsis when printing sexps in message buffer
|
|
|
|
(setq eval-expression-print-length nil
|
|
|
|
eval-expression-print-level nil)
|
2017-02-13 16:57:08 -05:00
|
|
|
|
2017-05-07 02:27:54 +02:00
|
|
|
|
2018-05-14 01:22:33 +02:00
|
|
|
;;
|
2018-09-07 19:36:16 -04:00
|
|
|
;; Packages
|
2017-02-13 16:57:08 -05:00
|
|
|
|
2019-10-23 21:39:19 -04:00
|
|
|
(set-popup-rule!
|
|
|
|
(lambda (bufname _)
|
|
|
|
(when (boundp '+eval-repl-mode)
|
|
|
|
(buffer-local-value '+eval-repl-mode (get-buffer bufname))))
|
|
|
|
:ttl (lambda (buf)
|
|
|
|
(unless (plist-get +eval-repl-plist :persist)
|
|
|
|
(when-let (process (get-buffer-process buf))
|
|
|
|
(set-process-query-on-exit-flag process nil)
|
|
|
|
(kill-process process)
|
|
|
|
(kill-buffer buf))))
|
|
|
|
:size 0.25 :quit nil)
|
|
|
|
|
|
|
|
|
2018-10-19 21:58:41 -04:00
|
|
|
(after! quickrun
|
2018-01-08 16:18:16 -05:00
|
|
|
(setq quickrun-focus-p nil)
|
|
|
|
|
2018-06-18 02:26:05 +02:00
|
|
|
(set-popup-rule! "^\\*quickrun" :size 0.3 :ttl 0)
|
2017-02-13 16:57:08 -05:00
|
|
|
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +eval--quickrun-auto-close-a (&rest _)
|
2017-02-28 12:12:09 -05:00
|
|
|
"Allows us to silently re-run quickrun from within the quickrun buffer."
|
2019-07-22 23:29:51 +02:00
|
|
|
:before '(quickrun quickrun-region)
|
2019-06-25 21:38:16 +02:00
|
|
|
(when-let (win (get-buffer-window quickrun--buffer-name))
|
2017-03-04 18:28:51 -05:00
|
|
|
(let ((inhibit-message t))
|
|
|
|
(quickrun--kill-running-process)
|
2017-02-13 16:57:08 -05:00
|
|
|
(message ""))
|
2017-03-04 18:28:51 -05:00
|
|
|
(delete-window win)))
|
2017-02-13 16:57:08 -05:00
|
|
|
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +eval--quickrun-fix-evil-visual-region-a ()
|
2019-05-17 16:01:46 -04:00
|
|
|
"Make `quickrun-replace-region' recognize evil visual selections."
|
2019-07-22 23:29:51 +02:00
|
|
|
:override #'quickrun--outputter-replace-region
|
2019-05-17 16:01:46 -04:00
|
|
|
(let ((output (buffer-substring-no-properties (point-min) (point-max))))
|
|
|
|
(with-current-buffer quickrun--original-buffer
|
|
|
|
(cl-destructuring-bind (beg . end)
|
|
|
|
;; Because `deactivate-mark', the function, was used in
|
|
|
|
;; `quickrun--region-command-common' instead of `deactivate-mark',
|
|
|
|
;; the variable, the selection is disabled by this point.
|
|
|
|
(if (bound-and-true-p evil-local-mode)
|
|
|
|
(cons evil-visual-beginning evil-visual-end)
|
|
|
|
(cons (region-beginning) (region-end)))
|
|
|
|
(delete-region beg end)
|
|
|
|
(insert output))
|
|
|
|
(setq quickrun-option-outputter quickrun--original-outputter))))
|
|
|
|
|
2019-07-28 14:52:59 +02:00
|
|
|
(add-hook! 'quickrun-after-run-hook
|
2019-07-22 23:29:51 +02:00
|
|
|
(defun +eval-quickrun-shrink-window-h ()
|
|
|
|
"Shrink the quickrun output window once code evaluation is complete."
|
|
|
|
(when-let (win (get-buffer-window quickrun--buffer-name))
|
|
|
|
(with-selected-window (get-buffer-window quickrun--buffer-name)
|
|
|
|
(let ((ignore-window-parameters t))
|
|
|
|
(shrink-window-if-larger-than-buffer))))))
|
|
|
|
|
2019-07-28 14:52:59 +02:00
|
|
|
(add-hook! 'quickrun-after-run-hook
|
2019-07-22 23:29:51 +02:00
|
|
|
(defun +eval-quickrun-scroll-to-bof-h ()
|
|
|
|
"Ensures window is scrolled to BOF on invocation."
|
|
|
|
(when-let (win (get-buffer-window quickrun--buffer-name))
|
|
|
|
(with-selected-window win
|
|
|
|
(goto-char (point-min)))))))
|