@@ -1218,45 +1218,52 @@ completion in these cases."
12181218 ; ; interfere with bash-completion-send detecting the end
12191219 ; ; of a command. It disables prompt to avoid interference
12201220 ; ; from commands run by prompts.
1221- (comint-send-string
1222- process
1223- (concat
1224- " set +o emacs;"
1225- " set +o vi;"
1226- " if [[ -z \" $__emacs_complete_ps1\" ]]; then"
1227- " __emacs_complete_ps1=\" $PS1\" ;"
1228- " __emacs_complete_pc=\" $PROMPT_COMMAND\" ;"
1229- " fi;"
1230- " PS1='' PROMPT_COMMAND='';"
1231- " history &>/dev/null -d $((HISTCMD - 1)) || true\n " ))
1232-
1233- ; ; The following is a bootstrap command for
1234- ; ; bash-completion-send itself.
1235- (bash-completion-send
1236- (concat
1237- " function __emacs_complete_pre_command {"
1238- " if [[ -z \" $__emacs_complete_ps1\" ]]; then"
1239- " __emacs_complete_ps1=\" $PS1\" ;"
1240- " __emacs_complete_pc=\" $PROMPT_COMMAND\" ;"
1241- " fi;"
1242- " PROMPT_COMMAND=__emacs_complete_prompt;"
1243- " history &>/dev/null -d $((HISTCMD - 1)) || true;"
1244- " } &&"
1245- " function __emacs_complete_prompt {"
1246- " PS1=" bash-completion--ps1 " ;"
1247- " PROMPT_COMMAND=__emacs_complete_recover_prompt;"
1248- " } &&"
1249- " function __emacs_complete_recover_prompt {"
1250- " local r=$?;"
1251- " PS1=\" ${__emacs_complete_ps1}\" ;"
1252- " PROMPT_COMMAND=\" ${__emacs_complete_pc}\" ;"
1253- " unset __emacs_complete_ps1 __emacs_complete_pc;"
1254- " if [[ -n \" $PROMPT_COMMAND\" ]]; then"
1255- " (exit $r); eval \" $PROMPT_COMMAND\" ;"
1256- " fi;"
1257- " } &&"
1258- " __emacs_complete_pre_command" )
1259- process)
1221+ (let* ((history-unclutter-cmd
1222+ (concat
1223+ " if [[ ${BASH_VERSINFO[0]} -eq 5 && ${BASH_VERSINFO[1]} -ge 1 || ${BASH_VERSINFO[0]} -gt 5 ]]; then"
1224+ " history -d $HISTCMD &>/dev/null || true;"
1225+ " else"
1226+ " history -d $((HISTCMD - 1)) &>/dev/null || true;"
1227+ " fi" )))
1228+ (comint-send-string
1229+ process
1230+ (concat
1231+ " set +o emacs;"
1232+ " set +o vi;"
1233+ " if [[ -z \" $__emacs_complete_ps1\" ]]; then"
1234+ " __emacs_complete_ps1=\" $PS1\" ;"
1235+ " __emacs_complete_pc=\" $PROMPT_COMMAND\" ;"
1236+ " fi;"
1237+ " PS1='' PROMPT_COMMAND='';"
1238+ history-unclutter-cmd " \n " ))
1239+
1240+ ; ; The following is a bootstrap command for
1241+ ; ; bash-completion-send itself.
1242+ (bash-completion-send
1243+ (concat
1244+ " function __emacs_complete_pre_command {"
1245+ " if [[ -z \" $__emacs_complete_ps1\" ]]; then"
1246+ " __emacs_complete_ps1=\" $PS1\" ;"
1247+ " __emacs_complete_pc=\" $PROMPT_COMMAND\" ;"
1248+ " fi;"
1249+ " PROMPT_COMMAND=__emacs_complete_prompt;"
1250+ " " history-unclutter-cmd " ;"
1251+ " } &&"
1252+ " function __emacs_complete_prompt {"
1253+ " PS1=" bash-completion--ps1 " ;"
1254+ " PROMPT_COMMAND=__emacs_complete_recover_prompt;"
1255+ " } &&"
1256+ " function __emacs_complete_recover_prompt {"
1257+ " local r=$?;"
1258+ " PS1=\" ${__emacs_complete_ps1}\" ;"
1259+ " PROMPT_COMMAND=\" ${__emacs_complete_pc}\" ;"
1260+ " unset __emacs_complete_ps1 __emacs_complete_pc;"
1261+ " if [[ -n \" $PROMPT_COMMAND\" ]]; then"
1262+ " (exit $r); eval \" $PROMPT_COMMAND\" ;"
1263+ " fi;"
1264+ " } &&"
1265+ " __emacs_complete_pre_command" )
1266+ process))
12601267 (bash-completion--setup-bash-common process))
12611268 process))))
12621269
0 commit comments