emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/eat 9e129f33a2: Don't enter prompt mode after exit till ne


From: ELPA Syncer
Subject: [nongnu] elpa/eat 9e129f33a2: Don't enter prompt mode after exit till new prompt
Date: Sat, 16 Sep 2023 18:59:07 -0400 (EDT)

branch: elpa/eat
commit 9e129f33a2c21cd6021e529f4091f62d414fbd76
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Don't enter prompt mode after exit till new prompt
    
    * eat.el (eat--inhibit-prompt-mode): New variable.
    * eat.el (eat--post-prompt, eat--post-cont-prompt): Check
    'eat--inhibit-prompt-mode' before switching to prompt mode.
    * eat.el (eat--before-new-prompt): New function.
    * eat.el (eat--handle-uic): Support "before new prompt"
    sequence.
    * eat.el (eat-emacs-mode, eat-semi-char-mode, eat-char-mode):
    Set 'eat--inhibit-prompt-mode' to t if prompt mode is enabled.
    * eat.el (eat-mode): Make 'eat--inhibit-prompt-mode'
    buffer-local.
    * integration/bash (__eat_prompt_command):
    * integration/zsh (__eat_precmd):
    Send the "before new prompt" sequence.
---
 eat.el           | 36 +++++++++++++++++++++++++++---------
 integration/bash |  2 ++
 integration/zsh  |  2 ++
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/eat.el b/eat.el
index 1040e1bdd5..4ef38a8e75 100644
--- a/eat.el
+++ b/eat.el
@@ -4943,6 +4943,9 @@ return \"eat-color\", otherwise return \"eat-mono\"."
 (defvar eat--shell-prompt-mark-overlays nil
   "List of overlay used to put marks before shell prompts.")
 
+(defvar eat--inhibit-prompt-mode nil
+  "Non-nil means don't enter prompt mode.")
+
 (defun eat-reset ()
   "Perform a terminal reset."
   (interactive)
@@ -5083,12 +5086,14 @@ If HOST isn't the host Emacs is running on, don't do 
anything."
       (put-text-property (1- (point)) (point)
                          'eat--shell-prompt-end t)))
   (setq eat--shell-prompt-begin nil)
-  (when eat-enable-native-shell-prompt-editing
+  (when (and eat-enable-native-shell-prompt-editing
+             (not eat--inhibit-prompt-mode))
     (eat--prompt-mode +1)))
 
 (defun eat--post-cont-prompt ()
   "Enter prompt mode."
-  (when eat-enable-native-shell-prompt-editing
+  (when (and eat-enable-native-shell-prompt-editing
+             (not eat--inhibit-prompt-mode))
     (eat--prompt-mode +1)))
 
 (defun eat--correct-shell-prompt-mark-overlays (buffer)
@@ -5174,6 +5179,10 @@ BUFFER is the terminal buffer."
     ;; We'll update the mark later when the prompt appears.
     (setq eat--shell-command-status code)))
 
+(defun eat--before-new-prompt ()
+  "Allow entering prompt mode."
+  (setq eat--inhibit-prompt-mode nil))
+
 (defun eat--get-shell-history (hist format)
   "Get shell history from HIST in format FORMAT."
   (pcase hist
@@ -5259,7 +5268,9 @@ BUFFER is the terminal buffer."
          (let format (zero-or-more (not ?\;)))
          ?\; (let hist (zero-or-more anything))
          string-end)
-     (eat--get-shell-history hist format))))
+     (eat--get-shell-history hist format))
+    ("e;J"
+     (eat--before-new-prompt))))
 
 (defun eat-previous-shell-prompt (&optional arg)
   "Go to the previous shell prompt.
@@ -5655,8 +5666,10 @@ EVENT is the mouse event."
              (/= (eat-term-end eat--terminal) (point-max)))
     (user-error "Can't switch to Emacs mode from prompt mode when\
  input is non-empty"))
-  (setq eat--prompt-mode-previous-mode 'dont-restore)
-  (eat--prompt-mode -1)
+  (when eat--prompt-mode
+    (setq eat--prompt-mode-previous-mode 'dont-restore)
+    (eat--prompt-mode -1)
+    (setq eat--inhibit-prompt-mode t))
   (eat--semi-char-mode -1)
   (eat--char-mode -1)
   (setq buffer-read-only t)
@@ -5673,8 +5686,10 @@ EVENT is the mouse event."
     (user-error "Can't switch to semi-char mode from prompt mode when\
  input is non-empty"))
   (setq buffer-read-only nil)
-  (setq eat--prompt-mode-previous-mode 'dont-restore)
-  (eat--prompt-mode -1)
+  (when eat--prompt-mode
+    (setq eat--prompt-mode-previous-mode 'dont-restore)
+    (eat--prompt-mode -1)
+    (setq eat--inhibit-prompt-mode t))
   (eat--char-mode -1)
   (eat--semi-char-mode +1)
   (eat--grab-mouse nil eat--mouse-grabbing-type)
@@ -5690,8 +5705,10 @@ EVENT is the mouse event."
     (user-error "Can't switch to char mode from prompt mode when\
  input is non-empty"))
   (setq buffer-read-only nil)
-  (setq eat--prompt-mode-previous-mode 'dont-restore)
-  (eat--prompt-mode -1)
+  (when eat--prompt-mode
+    (setq eat--prompt-mode-previous-mode 'dont-restore)
+    (eat--prompt-mode -1)
+    (setq eat--inhibit-prompt-mode t))
   (eat--semi-char-mode -1)
   (eat--char-mode +1)
   (eat--grab-mouse nil eat--mouse-grabbing-type)
@@ -6177,6 +6194,7 @@ END if it's safe to do so."
           eat--shell-prompt-begin
           eat--shell-prompt-mark
           eat--shell-prompt-mark-overlays
+          eat--inhibit-prompt-mode
           eat--prompt-mode-previous-mode
           eat--prompt-input-ring
           eat--prompt-input-ring-index
diff --git a/integration/bash b/integration/bash
index 3118e128e1..e760942dd1 100644
--- a/integration/bash
+++ b/integration/bash
@@ -24,6 +24,8 @@ __eat_prompt_command () {
     printf '\e]51;e;H;%i\e\\' "$__eat_exit_status"
   fi
   __eat_current_command=""
+  # Inform that a new prompt is going to be printed.
+  printf '\e]51;e;J\e\\'
   # Send the current working directory, for directory tracking.
   printf '\e]51;e;A;%s;%s\e\\' "$(printf "%s" "$HOSTNAME" | base64)" \
          "$(printf "%s" "$PWD" | base64)"
diff --git a/integration/zsh b/integration/zsh
index 2e30d58a86..28480a1a48 100644
--- a/integration/zsh
+++ b/integration/zsh
@@ -25,6 +25,8 @@ __eat_precmd () {
     printf '\e]51;e;H;%i\e\\' "$__eat_exit_status"
   fi
   __eat_current_command=""
+  # Inform that a new prompt is going to be printed.
+  printf '\e]51;e;J\e\\'
   # Send the current working directory, for directory tracking.
   printf '\e]51;e;A;%s;%s\e\\' "$(printf "%s" "$HOST" | base64)" \
          "$(printf "%s" "$PWD" | base64)"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]