[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 702859f319 278/313: Cleanup strings contai
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 702859f319 278/313: Cleanup strings containing bash commands. |
Date: |
Sat, 3 Dec 2022 10:59:37 -0500 (EST) |
branch: elpa/bash-completion
commit 702859f319fe482e4ef0c6e6dc3db2f9252b0d54
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Cleanup strings containing bash commands.
Let's go for a consistent style that generates single-line bash
commands, separated by ;, written in elisp as multiple strings put
together by concat. This seems to be the most practical format and the
most commonly used.
Also defines a constant for the special PS1 value.
---
bash-completion.el | 92 ++++++++++++++++++++++++++++++------------------------
1 file changed, 51 insertions(+), 41 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 874dacaee0..660c1fbb86 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -302,6 +302,9 @@ Bash processes.")
(defconst bash-completion-special-chars "[^-0-9a-zA-Z_./\n=]"
"Regexp of characters that must be escaped or quoted.")
+(defconst bash-completion--ps1 "'\t$?\v'"
+ "Value for the special PS1 prompt set for completions, quoted.")
+
(eval-when-compile
(unless (or (and (= emacs-major-version 24) (>= emacs-minor-version 3))
(>= emacs-major-version 25))
@@ -395,15 +398,14 @@ returned."
" eval $__EMACS_COMPLETE_WRAPPER;"
" n=$?;"
" if [[ $n = 124 ]]; then"
- (bash-completion--side-channel-data
- "wrapped-status" "124")
+ (bash-completion--side-channel-data "wrapped-status" "124")
" return 1; "
" fi; "
(when (>= bash-major-version 4)
- (concat " if [[ -n \"${_EMACS_COMPOPT}\" ]]; then"
- (bash-completion--side-channel-data
- "compopt" "${_EMACS_COMPOPT}")
- " fi;"))
+ (concat
+ " if [[ -n \"${_EMACS_COMPOPT}\" ]]; then"
+ (bash-completion--side-channel-data "compopt"
"${_EMACS_COMPOPT}")
+ " fi;"))
" return $n;"
"}")
process)
@@ -1176,18 +1178,20 @@ is set to t."
;; bash if the current version of bash does not
;; support these options, the commands will fail
;; silently and be ignored.
- "shopt -u checkjobs\n"
- "shopt -u mailwarn\n"
- "export MAILCHECK=-1\n"
- "export -n MAIL\n"
- "export -n MAILPATH\n"
- "unset HISTFILE\n"
+ "shopt -u checkjobs;"
+ "shopt -u mailwarn;"
+ "export MAILCHECK=-1;"
+ "export -n MAIL;"
+ "export -n MAILPATH;"
+ "unset HISTFILE;"
;; User's profiles can turn line editing back on,
;; so make sure it's off
- "set +o emacs\n"
+ "set +o emacs;"
"set +o vi\n"))
- (bash-completion-send "PROMPT_COMMAND='' PS1='\t$?\v'" process
bash-completion-initial-timeout)
+ (bash-completion-send
+ (concat "PROMPT_COMMAND='' PS1=" bash-completion--ps1)
+ process bash-completion-initial-timeout)
(bash-completion--setup-bash-common process)
(push (cons remote process) bash-completion-processes)
(setq cleanup nil)
@@ -1233,37 +1237,43 @@ completion in these cases."
;; from commands run by prompts.
(comint-send-string
process
- "set +o emacs; set +o vi; \
-if [[ -z \"$__emacs_complete_ps1\" ]]; then \
- __emacs_complete_ps1=\"$PS1\"\
- __emacs_complete_pc=\"$PROMPT_COMMAND\"; \
-fi; \
-PS1='' PROMPT_COMMAND=''; history &>/dev/null -d $((HISTCMD - 1))\n")
+ (concat
+ "set +o emacs;"
+ "set +o vi;"
+ "if [[ -z \"$__emacs_complete_ps1\" ]]; then"
+ " __emacs_complete_ps1=\"$PS1\";"
+ " __emacs_complete_pc=\"$PROMPT_COMMAND\";"
+ "fi;"
+ "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_pre_command {
- if [[ -z \"$__emacs_complete_ps1\" ]]; then
- __emacs_complete_ps1=\"$PS1\"
- __emacs_complete_pc=\"$PROMPT_COMMAND\"
- fi
- PROMPT_COMMAND=__emacs_complete_prompt
- history &>/dev/null -d $((HISTCMD - 1))
-}; \
-function __emacs_complete_prompt {
- PS1='\t$?\v'
- PROMPT_COMMAND=__emacs_complete_recover_prompt
-}; \
-function __emacs_complete_recover_prompt {
- local r=$?
- PS1=\"${__emacs_complete_ps1}\"
- PROMPT_COMMAND=\"${__emacs_complete_pc}\"
- unset __emacs_complete_ps1 __emacs_complete_pc
- if [[ -n \"$PROMPT_COMMAND\" ]]; then
- (exit $r); eval \"$PROMPT_COMMAND\"
- fi
-}; __emacs_complete_pre_command" process)
+ (concat
+ "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 &>/dev/null -d $((HISTCMD - 1));"
+ "};"
+ "function __emacs_complete_prompt {"
+ " PS1=" bash-completion--ps1 ";"
+ " PROMPT_COMMAND=__emacs_complete_recover_prompt;"
+ "};"
+ "function __emacs_complete_recover_prompt {"
+ " local r=$?;"
+ " PS1=\"${__emacs_complete_ps1}\";"
+ " PROMPT_COMMAND=\"${__emacs_complete_pc}\";"
+ " unset __emacs_complete_ps1 __emacs_complete_pc;"
+ " if [[ -n \"$PROMPT_COMMAND\" ]]; then"
+ " (exit $r); eval \"$PROMPT_COMMAND\";"
+ " fi;"
+ "};"
+ "__emacs_complete_pre_command")
+ process)
(bash-completion--setup-bash-common process))
process))))
- [nongnu] elpa/bash-completion a0a5816ce4 245/313: Attempt to make in-process execution more robust., (continued)
- [nongnu] elpa/bash-completion a0a5816ce4 245/313: Attempt to make in-process execution more robust., ELPA Syncer, 2022/12/03
- [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 <=
- [nongnu] elpa/bash-completion 19d4fec42f 280/313: Use && instead of ; after cd, so completion fails if cd fails., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c584d4936b 281/313: Explicitly ignore error from the history command., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion de033933bd 282/313: Chain function definitions with && during setup., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e24a596631 283/313: Make integration tests stabler., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 51c7770758 284/313: Fix and update README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c6decb1d6c 285/313: Avoid escaping all non-ASCII characters., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4c216c4eea 286/313: Add an integration test to cover multiple completion results., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8f877dc2ce 287/313: Let bash compute COMP_POINT, always at the end of COMP_LINE., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 377969faa7 288/313: Fix typos in README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 72e9fce93d 291/313: Properly apply filter passed to the dynamic completion function., ELPA Syncer, 2022/12/03