[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion e36c91fda4 5/8: Fix history uncluttering w
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion e36c91fda4 5/8: Fix history uncluttering when Bash version is >= 5.1 |
Date: |
Sun, 15 Jan 2023 12:58:34 -0500 (EST) |
branch: elpa/bash-completion
commit e36c91fda4d35eb9d3cce4edf8b96aae0a6091a3
Author: montag451 <montag451@laposte.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Fix history uncluttering when Bash version is >= 5.1
Since Bash version 5.1, the behaviour of HISTCMD has been changed and
it breaks history uncluttering. This commit solves this problem by
checking the Bash major version and by using the appropriate command
to unclutter the history.
---
bash-completion.el | 85 +++++++++++++++++++++++++++++-------------------------
1 file changed, 46 insertions(+), 39 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 8bb1a137d9..21eca7679c 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1218,45 +1218,52 @@ completion in these cases."
;; interfere with bash-completion-send detecting the end
;; of a command. It disables prompt to avoid interference
;; from commands run by prompts.
- (comint-send-string
- process
- (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)) || true\n"))
-
- ;; The following is a bootstrap command for
- ;; bash-completion-send itself.
- (bash-completion-send
- (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)) || true;"
- "} &&"
- "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)
+ (let* ((history-unclutter-cmd
+ (concat
+ "if [[ ${BASH_VERSINFO[0]} -eq 5 && ${BASH_VERSINFO[1]} -ge
1 || ${BASH_VERSINFO[0]} -gt 5 ]]; then"
+ " history -d $HISTCMD &>/dev/null || true;"
+ "else"
+ " history -d $((HISTCMD - 1)) &>/dev/null || true;"
+ "fi")))
+ (comint-send-string
+ process
+ (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-unclutter-cmd "\n"))
+
+ ;; The following is a bootstrap command for
+ ;; bash-completion-send itself.
+ (bash-completion-send
+ (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-unclutter-cmd ";"
+ "} &&"
+ "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 updated (8e9c20dbfe -> 2d40c61f56), ELPA Syncer, 2023/01/15
- [nongnu] elpa/bash-completion 736b38a5db 1/8: Minor comment cleanups., ELPA Syncer, 2023/01/15
- [nongnu] elpa/bash-completion ba2f7e922f 4/8: Fix history uncluttering when Bash version is >= 5.1 (#57), ELPA Syncer, 2023/01/15
- [nongnu] elpa/bash-completion a14d956fd8 6/8: Attempt to fix CI., ELPA Syncer, 2023/01/15
- [nongnu] elpa/bash-completion fee17a568f 3/8: Merge branch 'cleanup', ELPA Syncer, 2023/01/15
- [nongnu] elpa/bash-completion e36c91fda4 5/8: Fix history uncluttering when Bash version is >= 5.1,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 8d6c2ec813 7/8: Merge branch 'master' of github.com:szermatt/emacs-bash-completion, ELPA Syncer, 2023/01/15
- [nongnu] elpa/bash-completion 2d40c61f56 8/8: Fix test.yml for CI., ELPA Syncer, 2023/01/15
- [nongnu] elpa/bash-completion a904c599f4 2/8: Add .elpaignore, ELPA Syncer, 2023/01/15