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

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

[nongnu] elpa/bash-completion bb044ff2f0 213/313: Try to handle prompts


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion bb044ff2f0 213/313: Try to handle prompts with ANSI escape sequences
Date: Sat, 3 Dec 2022 10:59:31 -0500 (EST)

branch: elpa/bash-completion
commit bb044ff2f0b894efeb56dce7a29fa8ee65c07aa4
Author: montag451 <montag451@laposte.net>
Commit: montag451 <montag451@laposte.net>

    Try to handle prompts with ANSI escape sequences
---
 bash-completion.el | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index f0509058d6..ec5b2782b6 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -122,6 +122,7 @@
 ;; https://github.com/szermatt/emacs-bash-completion
 
 (require 'comint)
+(require 'ansi-color)
 (eval-when-compile (require 'cl))
 
 ;;; Code:
@@ -401,12 +402,6 @@ returned."
                     (point-min) (point-max))))
     (process-put process 'bash-major-version bash-major-version)))
 
-(defun bash-completion--output-filter (output)
-  (with-current-buffer (bash-completion--get-buffer nil)
-    (goto-char (point-max))
-    (insert output)
-    ""))
-
 ;;; ---------- Inline functions
 
 (defsubst bash-completion-tokenize-get-range (token)
@@ -1321,6 +1316,14 @@ and would like bash completion in Emacs to take these 
changes into account."
       (setq bash-completion-processes (delq entry bash-completion-processes)))
     running))
 
+(defun bash-completion--output-filter (output)
+  (with-current-buffer (bash-completion--get-buffer nil)
+    (let ((begin (point-max)))
+      (goto-char begin)
+      (insert output)
+      (ansi-color-filter-region begin (point))
+      "")))
+
 (defun bash-completion--wait-for-prompt (process prompt-regexp timeout)
   (let ((no-timeout t))
     (while (and no-timeout
@@ -1329,11 +1332,11 @@ and would like bash completion in Emacs to take these 
changes into account."
     no-timeout))
 
 (defun bash-completion--get-prompt-regexp ()
-  (if comint-use-prompt-regexp
-      comint-prompt-regexp
-    (let* ((end (comint-line-beginning-position))
-           (start (previous-property-change end)))
-      (regexp-quote (buffer-substring-no-properties start end)))))
+  (if comint-last-prompt
+      (let ((start (car comint-last-prompt))
+            (end (cdr comint-last-prompt)))
+        (regexp-quote (buffer-substring-no-properties start end)))
+    comint-prompt-regexp))
 
 (defun bash-completion-send (commandline &optional process timeout)
   "Send a command to the bash completion process.



reply via email to

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