branch: elpa/bash-completion
commit ea5cc15b9925071fc863246b721f4dca9983aeb3
Author: Stephane Zermatten <[email protected]>
Commit: Stephane Zermatten <[email protected]>
Let status code of compgen through when in single-process mode.
(bash-completion-send) is supposed to return the status of the
command. However, when running in single-process mode, a command was
executed after the main command, so the status returned was the status
of that second command.
This change transforms __emacs_complete_post_command into
__bash_complete_pre_command.
This change also silences errors from the history command, which is
how this issue came to light, as errors from history made it look like
the compgen command failed.
---
bash-completion.el | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index b9c2d4c571..a30379cd94 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1238,18 +1238,18 @@ if [[ -z \"$__emacs_complete_ps1\" ]]; then \
__emacs_complete_ps1=\"$PS1\"\
__emacs_complete_pc=\"$PROMPT_COMMAND\"; \
fi; \
-PS1='' PROMPT_COMMAND=''; history -d $((HISTCMD - 1))\n")
+PS1='' PROMPT_COMMAND=''; history &>/dev/null -d $((HISTCMD - 1))\n")
;; The following is a bootstrap command for
;; bash-completion-send itself.
(bash-completion-send
- "function __emacs_complete_post_command {
+ "function __emacs_complete_pre_command {
if [[ -z \"$__emacs_complete_ps1\" ]]; then
__emacs_complete_ps1=\"$PS1\"
__emacs_complete_pc=\"$PROMPT_COMMAND\"
fi
PROMPT_COMMAND=__emacs_complete_prompt
- history -d $((HISTCMD - 1))
+ history &>/dev/null -d $((HISTCMD - 1))
}; \
function __emacs_complete_prompt {
PS1='\t$?\v'
@@ -1263,7 +1263,7 @@ function __emacs_complete_recover_prompt {
if [[ -n \"$PROMPT_COMMAND\" ]]; then
(exit $r); eval \"$PROMPT_COMMAND\"
fi
-}" process)
+}; __emacs_complete_pre_command" process)
(bash-completion--setup-bash-common process))
process))))
@@ -1502,12 +1502,11 @@ Return the status code of the command, as a number."
(send-string (if bash-completion-use-separate-processes
#'process-send-string
#'comint-send-string))
- (post-command (if bash-completion-use-separate-processes
- "\n"
- "; __emacs_complete_post_command;\n")))
+ (pre-command (unless bash-completion-use-separate-processes
+ "__emacs_complete_pre_command; ")))
(with-current-buffer (bash-completion--get-buffer process)
(erase-buffer)
- (funcall send-string process (concat commandline post-command))
+ (funcall send-string process (concat pre-command commandline "\n"))
(unless (bash-completion--wait-for-regexp process "\t-?[[:digit:]]+\v"
timeout)
(error (concat
"Timeout while waiting for an answer from "