[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 58447c67bf 206/313: Merge the send functio
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 58447c67bf 206/313: Merge the send functions |
Date: |
Sat, 3 Dec 2022 10:59:31 -0500 (EST) |
branch: elpa/bash-completion
commit 58447c67bf7141da6a5678865ceda852f4fb548d
Author: montag451 <montag451@laposte.net>
Commit: montag451 <montag451@laposte.net>
Merge the send functions
---
bash-completion.el | 98 +++++++++++++++++++-----------------------------------
1 file changed, 35 insertions(+), 63 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 90d537100f..9afcfc222c 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1321,63 +1321,58 @@ 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--wait-for-output (process output-regex timeout)
+(defun bash-completion--wait-for-prompt (process output-regexp timeout)
(let ((no-timeout t))
(while (and no-timeout
- (not (re-search-backward output-regex nil t)))
+ (not (re-search-backward output-regexp nil t)))
(setq no-timeout (accept-process-output process timeout)))
no-timeout))
-(defun bash-completion--send-separate-process (commandline &optional process
timeout)
+(defun bash-completion-send (commandline &optional process timeout)
+ "Send a command to the bash completion process.
- ;; (message commandline)
- (let ((process (or process (bash-completion-require-process)))
- (timeout (or timeout bash-completion-process-timeout)))
- (with-current-buffer (bash-completion--get-buffer process)
- (erase-buffer)
- (process-send-string process (concat commandline "\n"))
- (while (not (progn (goto-char 1) (search-forward "\v" nil t)))
- (unless (accept-process-output process timeout)
- (error (concat
- "Timeout while waiting for an answer from "
- "bash-completion process.\nProcess output: <<<EOF\n%sEOF")
- (buffer-string))))
- (let* ((control-v-position (point))
- (control-t-position (progn (search-backward "\t" nil t) (point)))
- (status-code (string-to-number
- (buffer-substring-no-properties
- (1+ control-t-position) (1- control-v-position)))))
- (delete-region control-t-position (point-max))
- ;; (message "status: %d content: \"%s\""
- ;; status-code
- ;; (buffer-substring-no-properties
- ;; (point-min) (point-max)))
- (if (string=
- "124"
- (bash-completion--parse-side-channel-data "wrapped-status"))
- 124
- status-code)))))
+COMMANDLINE should be a bash command, without the final newline.
+
+PROCESS should be the bash process, if nil this function calls
+`bash-completion-require-process' which might start a new process
+depending on the value of
+`bash-completion-use-separate-processes'.
+
+TIMEOUT is the timeout value for this operation, if nil the value of
+`bash-completion-process-timeout' is used.
+
+Once this command has run without errors, you will find the
+result of the command in the bash completion process buffer or in
+`bash-completion-output-buffer' if
+`bash-completion-use-separate-processes' is nil.
-(defun bash-completion--send-same-process (commandline &optional process
timeout)
+Return the status code of the command, as a number."
(let ((process (or process (bash-completion-require-process)))
(timeout (or timeout bash-completion-process-timeout))
- (prompt-regex comint-prompt-regexp)
- (comint-preoutput-filter-functions '(bash-completion--output-filter)))
+ (prompt-regexp (if bash-completion-use-separate-processes
+ "\t-?[[:digit:]]+\v"
+ comint-prompt-regexp))
+ (comint-preoutput-filter-functions
+ (if bash-completion-use-separate-processes
+ comint-preoutput-filter-functions
+ '(bash-completion--output-filter))))
(with-current-buffer (bash-completion--get-buffer process)
(erase-buffer)
(comint-send-string process (concat
commandline
- "; echo -e \"\v$?\""
- "; history -d -1\n"))
- (unless (bash-completion--wait-for-output process prompt-regex timeout)
+ (when (not
bash-completion-use-separate-processes)
+ "; echo -e \"\v$?\"; history -d -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)))
- (search-backward "\v")
- (let* ((status-code (string-to-number
- (buffer-substring-no-properties
- (1+ (point)) (line-end-position)))))
+ (when (not bash-completion-use-separate-processes)
+ (search-backward "\v"))
+ (let ((status-code (string-to-number
+ (buffer-substring-no-properties
+ (1+ (point)) (line-end-position)))))
(delete-region (point) (point-max))
(if (string=
"124"
@@ -1385,29 +1380,6 @@ and would like bash completion in Emacs to take these
changes into account."
124
status-code)))))
-(defun bash-completion-send (commandline &optional process timeout)
- "Send a command to the bash completion process.
-
-COMMANDLINE should be a bash command, without the final newline.
-
-PROCESS should be the bash process, if nil this function calls
-`bash-completion-require-process' which might start a new process
-depending on the value of
-`bash-completion-use-separate-processes'.
-
-TIMEOUT is the timeout value for this operation, if nil the value of
-`bash-completion-process-timeout' is used.
-
-Once this command has run without errors, you will find the
-result of the command in the bash completion process buffer or
-`bash-completion-output-buffer' is
-`bash-completion-use-separate-processes' is nil.
-
-Return the status code of the command, as a number."
- (if bash-completion-use-separate-processes
- (bash-completion--send-separate-process commandline process timeout)
- (bash-completion--send-same-process commandline process timeout)))
-
(defun bash-completion--get-output (process)
"Return the output of the last command sent through `bash-completion-send'."
(with-current-buffer (bash-completion--get-buffer process) (buffer-string)))
- [nongnu] elpa/bash-completion 666244383e 296/313: Workaround for command-line being echoed., (continued)
- [nongnu] elpa/bash-completion 666244383e 296/313: Workaround for command-line being echoed., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abb72c36b8 297/313: Merge branch 'master' of github.com:szermatt/emacs-bash-completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e35943f37e 299/313: Fix backward-compatibility issue on 24.3: avoid using alist-get., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abbe3bc268 301/313: Cleanup implementation of bash-completion-debug., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ca4fbce016 305/313: Turn off bash completion when non-bash prompts are detected., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abe93ae2f6 308/313: Fix whitespace (#47), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion df635e79fd 310/313: Replace deprecated `cl` package with `cl-lib` (#50), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8e9c20dbfe 313/313: Replace or quote certain single quotes in docstrings (#55), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion aa9bea48ba 022/313: fix position, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6aedd69000 164/313: Delete duplicates when extracting candidates. fixes #26, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 58447c67bf 206/313: Merge the send functions,
ELPA Syncer <=
- [nongnu] elpa/bash-completion d6c28d3132 302/313: Add a troubleshooting section to README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d550256e3f 306/313: Disable flakey test for now., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a8f7de1e91 173/313: Merge remote-tracking branch 'montag451/remote-shell-support-rebase', ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 9521f79b33 176/313: Display the emacs command run by the tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fc3f762d16 177/313: Track and support options -o default, filenames and nospace., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c6df9be78d 182/313: Store the alist as process property., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fefe5ae88e 191/313: Introduce bash-completion-remote-prog., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d99ad71050 199/313: Add a new option to disable the use of separate processes to perform completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ce59fb017a 202/313: Fallback to the use of a separate process if an error occurs, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 24f78df106 203/313: Improve output handling, ELPA Syncer, 2022/12/03