-
Notifications
You must be signed in to change notification settings - Fork 8
/
run-command-runner-eat.el
68 lines (50 loc) · 2.18 KB
/
run-command-runner-eat.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; run-command-runner-eat.el --- term-mode runner -*- lexical-binding: t -*-
;; Copyright (C) 2020-2023 Massimiliano Mirra
;; Author: Massimiliano Mirra <hyperstruct@gmail.com>
;; URL: https://github.com/bard/emacs-run-command
;; This file is not part of GNU Emacs
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; For a full copy of the GNU General Public License
;; see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Runner for `run-command' based on `eat-mode'.
;;; Code:
(require 'run-command-core)
(declare-function eat-mode "ext:eat")
(defun run-command-runner-eat (command-line buffer-base-name output-buffer)
"Command runner based on `eat-mode'.
Executes COMMAND-LINE in buffer OUTPUT-BUFFER. Name the process BUFFER-BASE-NAME."
(require 'eat)
(with-current-buffer output-buffer
(let ((eat-semi-char-non-bound-keys '([C-next] [C-prior])))
(eat-mode)
(eat-exec
output-buffer
buffer-base-name
shell-file-name
nil
(list "-c" command-line)))))
(define-advice eat--t-erase-in-disp
(:around
(original-eat--t-erase-in-disp n)
run-command-runner-eat-erase-advice)
"Advice to force clearing scrollback.
Commands in watch mode often ask the terminal to erase from home
position (first row, first column) to end of display, leaving
scrollback untouched. This makes it hard to scroll up and find
the beginning of last run's output. Hence we force clearing
scrollback, so user only has to scroll to beginning of buffer to
find the beginning of last run's output."
(if (and (boundp 'run-command--command-spec) (eq n 2))
(funcall original-eat--t-erase-in-disp 3)
(funcall original-eat--t-erase-in-disp n)))
;;;; Meta
(provide 'run-command-runner-eat)
;;; run-command-runner-eat.el ends here