[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion a0a5816ce4 245/313: Attempt to make in-pro
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion a0a5816ce4 245/313: Attempt to make in-process execution more robust. |
Date: |
Sat, 3 Dec 2022 10:59:34 -0500 (EST) |
branch: elpa/bash-completion
commit a0a5816ce444308d83ec2f69190691b674acf7bb
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Attempt to make in-process execution more robust.
When use-separate-processes is nil, this change waits for a special
string, added by bash-completion-send, instead of the prompt regexp.
This should be more robust, as prompts can change and the prompt
regexp might easily match output.
This change also removes uses of comint-last-prompt. This was an
attempt at making the prompt search more reliable, but won't work if
the prompt changes, such as a prompt that includes the history line
count.
---
bash-completion.el | 50 ++++++++++++++++----------------
test/bash-completion-integration-test.el | 5 ++--
2 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 56a6126572..cf6ede1a37 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1418,25 +1418,13 @@ and would like bash completion in Emacs to take these
changes into account."
(ansi-color-filter-region begin (point))
"")))
-(defun bash-completion--wait-for-prompt (process prompt-regexp timeout)
+(defun bash-completion--wait-for-regexp (process prompt-regexp timeout
&optional limit)
(let ((no-timeout t))
(while (and no-timeout
- (not (re-search-backward prompt-regexp nil t)))
+ (not (re-search-backward prompt-regexp limit t)))
(setq no-timeout (accept-process-output process timeout nil t)))
no-timeout))
-(when (< emacs-major-version 26)
- ;; comint-last-prompt was not available prior to Emacs 26.1, so we
- ;; always fallback to comint-prompt-regexp.
- (defvar comint-last-prompt nil))
-
-(defun bash-completion--get-prompt-regexp ()
- (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.
@@ -1458,9 +1446,7 @@ result of the command in the bash completion process
buffer or in
Return the status code of the command, as a number."
(let ((process (or process (bash-completion--get-process)))
(timeout (or timeout bash-completion-process-timeout))
- (prompt-regexp (if bash-completion-use-separate-processes
- "\t-?[[:digit:]]+\v"
- (bash-completion--get-prompt-regexp)))
+ (prompt-regexp comint-prompt-regexp)
(comint-preoutput-filter-functions
(if bash-completion-use-separate-processes
comint-preoutput-filter-functions
@@ -1474,15 +1460,29 @@ Return the status code of the command, as a number."
(concat
commandline
(unless bash-completion-use-separate-processes
- "; echo -e \"\v$?\"; history -d $((HISTCMD - 1))")
+ "; echo \"--\v$?\"; history -d $((HISTCMD - 1))")
"\n"))
- (unless (bash-completion--wait-for-prompt process prompt-regexp timeout)
- (error (concat
- "Timeout while waiting for an answer from "
- "bash-completion process.\nProcess output: <<<EOF\n%sEOF")
- (buffer-string)))
- (unless bash-completion-use-separate-processes
- (search-backward "\v"))
+ (if bash-completion-use-separate-processes
+ (unless (bash-completion--wait-for-regexp process
"\t-?[[:digit:]]+\v" timeout)
+ (error (concat
+ "Timeout while waiting for an answer from "
+ "bash-completion process with regexp %s.\nProcess output:
<<<EOF\n%sEOF")
+ prompt-regexp
+ (buffer-string)))
+ (unless (bash-completion--wait-for-regexp process "--\v" timeout)
+ (error (concat
+ "Timeout while waiting for process status\n"
+ "Process output: <<<EOF\n%sEOF")
+ (buffer-string)))
+ (let ((search-limit (point)))
+ (goto-char (point-max))
+ (unless (bash-completion--wait-for-regexp process prompt-regexp
timeout search-limit)
+ (error (concat
+ "Timeout while waiting for an answer from "
+ "bash-completion process with regexp %s.\nProcess output:
<<<EOF\n%sEOF")
+ prompt-regexp
+ (buffer-string)))
+ (goto-char search-limit)))
(let ((status-code (string-to-number
(buffer-substring-no-properties
(1+ (point))
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index 5871a751bd..8976ce0d04 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -84,9 +84,8 @@
(setq shell-buffer (shell (generate-new-buffer-name
"*bash-completion_test-with-shell*")))
(with-current-buffer shell-buffer
- (bash-completion--wait-for-prompt (get-buffer-process
shell-buffer)
-
(bash-completion--get-prompt-regexp)
- 3.0)
+ (bash-completion--wait-for-regexp
+ (get-buffer-process shell-buffer) comint-prompt-regexp 3.0)
(let ((comint-dynamic-complete-functions
'(bash-completion-dynamic-complete))
(completion-at-point-functions '(comint-completion-at-point
t)))
(progn ,@body))))
- [nongnu] elpa/bash-completion d8f02ecbb1 231/313: Merge branch 'master' into use-separate-processes-opt, (continued)
- [nongnu] elpa/bash-completion d8f02ecbb1 231/313: Merge branch 'master' into use-separate-processes-opt, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 10569a4625 232/313: Fix bash-completion-test-send., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1b7ec87915 233/313: Fix byte-compilation error under Emacs 24 and 25., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a2da7b910b 235/313: Updated README to push for bash-completion-use-separate-processes., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fd3ba68800 236/313: Force bash-completion-use-separate-processes to t in tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7f4410ebcb 237/313: Extend integration tests to cover single-process use-case., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f8c2083a14 239/313: Rename bash-completion-get-process., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c25f2203f5 240/313: Fix typo and extend note about use-separate-processes-opt., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 685ed73df0 243/313: Allow completion to replace the word being completed., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7dc20e1b09 244/313: Use separate processes in integration tests when it doesn't matter., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a0a5816ce4 245/313: Attempt to make in-process execution more robust.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion cad904abfd 247/313: Redefine quote_readline from setup-bash-common., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5447034cdc 251/313: Respect completion-ignore-case setting from .inputrc., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 42630fe6cc 254/313: Fix test case to cover substring completion., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8f33a2aac4 257/313: Better document calling bash-completion from completion-at-point., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 96d2cef799 259/313: Prepare for a 3.0 release., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4aafffe76a 260/313: Create CONTRIBUTING.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2b9eba14fa 261/313: Update README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 79ce50bec9 262/313: Update README.md title, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5e623ac270 275/313: Revert "Add test cases for TRAMP shell.", ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 702859f319 278/313: Cleanup strings containing bash commands., ELPA Syncer, 2022/12/03