[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/eat 2c6afa4dc0 4/9: Add shell prompt navigation commands
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/eat 2c6afa4dc0 4/9: Add shell prompt navigation commands |
Date: |
Tue, 6 Dec 2022 13:58:46 -0500 (EST) |
branch: elpa/eat
commit 2c6afa4dc0506054de717260d12fbf936317da47
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
Add shell prompt navigation commands
* eat.el (eat--post-prompt): Add special text property on the
last character of shell prompt.
* eat.el (eat-previous-shell-prompt, eat-next-shell-prompt):
New command.
* eat.el (eat-mode-map): Bind 'eat-previous-shell-prompt' and
'eat-next-shell-prompt' to 'C-c C-p' and 'C-c C-n'
respectively.
---
eat.el | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/eat.el b/eat.el
index 824277e028..e00bf649a7 100644
--- a/eat.el
+++ b/eat.el
@@ -4279,7 +4279,10 @@ If HOST isn't the host Emacs is running on, don't do
anything."
(list 'eat--before-string before-str
'eat--shell-prompt-mark-id identifier
'eat--shell-prompt-mark-overlay ov))
- (push ov eat--shell-prompt-mark-overlays)))
+ (push ov eat--shell-prompt-mark-overlays))
+ ;; Put a text property to allow previous or next prompts.
+ (put-text-property (1- (point)) (point)
+ 'eat--shell-prompt-end t))
(setq eat--shell-prompt-begin nil)))))
(defun eat--update-shell-prompt-mark-overlays (buffer)
@@ -4351,6 +4354,40 @@ BUFFER is the terminal buffer."
;; We'll update the mark later when the prompt appears.
(setq eat--shell-command-status code)))
+(defun eat-previous-shell-prompt (&optional arg)
+ "Go to the previous shell prompt.
+
+When numeric prefix argument, ARG, is given, go to ARGth previous
+shell prompt."
+ (interactive "p")
+ (dotimes (_ (or arg 1))
+ (let ((previous (previous-single-property-change
+ (point) 'eat--shell-prompt-end)))
+ (goto-char (or previous (point-min)))
+ (when (get-text-property (point) 'eat--shell-prompt-end)
+ (setq previous (previous-single-property-change
+ (point) 'eat--shell-prompt-end))
+ (goto-char (or previous (point-min))))
+ (unless previous
+ (user-error "No previous prompt")))))
+
+(defun eat-next-shell-prompt (&optional arg)
+ "Go to the next shell prompt.
+
+When numeric prefix argument, ARG, is given, go to ARGth next shell
+prompt."
+ (interactive "p")
+ (dotimes (_ (or arg 1))
+ (let ((next (next-single-property-change
+ (point) 'eat--shell-prompt-end)))
+ (goto-char (or next (point-max)))
+ (when (get-text-property (point) 'eat--shell-prompt-end)
+ (goto-char (or (next-single-property-change
+ (point) 'eat--shell-prompt-end)
+ (point-max))))
+ (unless next
+ (user-error "No next prompt")))))
+
;;;;; Input.
@@ -4548,6 +4585,8 @@ ARG is passed to `yank-pop', which see."
(define-key map [?\C-c ?\M-d] #'eat-char-mode)
(define-key map [?\C-c ?\C-j] #'eat-semi-char-mode)
(define-key map [?\C-c ?\C-k] #'eat-kill-process)
+ (define-key map [?\C-c ?\C-p] #'eat-previous-shell-prompt)
+ (define-key map [?\C-c ?\C-n] #'eat-next-shell-prompt)
map)
"Keymap for Eat mode.")
- [nongnu] elpa/eat updated (d35864ca6b -> 693940c733), ELPA Syncer, 2022/12/06
- [nongnu] elpa/eat 693940c733 9/9: * README.org: Add shell integration instructions, ELPA Syncer, 2022/12/06
- [nongnu] elpa/eat 8188f71562 8/9: * eat-tests.el (eat-test-set-cwd): Update test, ELPA Syncer, 2022/12/06
- [nongnu] elpa/eat 62a09caef1 7/9: * eat.el (eat--t-term): Fix initial value of 'cwd', ELPA Syncer, 2022/12/06
- [nongnu] elpa/eat a04999011f 3/9: Annotate shell prompts, ELPA Syncer, 2022/12/06
- [nongnu] elpa/eat e287487b42 6/9: Document everything about shell integration, ELPA Syncer, 2022/12/06
- [nongnu] elpa/eat 2c6afa4dc0 4/9: Add shell prompt navigation commands,
ELPA Syncer <=
- [nongnu] elpa/eat 9caa496e45 1/9: Tighter shell integration, ELPA Syncer, 2022/12/06
- [nongnu] elpa/eat b42687f146 5/9: Fix prompt navigation when annotation is disabled, ELPA Syncer, 2022/12/06
- [nongnu] elpa/eat b4d07cb474 2/9: Add shell commands run in Eat to Emacs history, ELPA Syncer, 2022/12/06