Skip to content

Commit

Permalink
blehook: prefer the uniq "!=" to the addition "+="
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 9, 2022
1 parent a22c25b commit fe7abd4
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions ble.pp
Expand Up @@ -2037,7 +2037,7 @@ function ble/base/install-prompt-attach {
ble/array#push PROMPT_COMMAND ble/base/attach-from-PROMPT_COMMAND
if [[ $_ble_edit_detach_flag == reload ]]; then
_ble_edit_detach_flag=prompt-attach
blehook internal_PRECMD+=ble/base/attach-from-PROMPT_COMMAND
blehook internal_PRECMD!=ble/base/attach-from-PROMPT_COMMAND
fi
else
local save_index=${#_ble_base_attach_PROMPT_COMMAND[@]}
Expand All @@ -2047,7 +2047,7 @@ function ble/base/install-prompt-attach {
ble/function#trace "$PROMPT_COMMAND"
if [[ $_ble_edit_detach_flag == reload ]]; then
_ble_edit_detach_flag=prompt-attach
blehook internal_PRECMD+="$PROMPT_COMMAND"
blehook internal_PRECMD!="$PROMPT_COMMAND"
fi
fi
}
Expand Down
2 changes: 1 addition & 1 deletion contrib
2 changes: 1 addition & 1 deletion keymap/emacs.sh
Expand Up @@ -132,7 +132,7 @@ function ble/keymap:emacs/update-mode-indicator {

ble/edit/info/default ansi "$str"
}
blehook internal_PRECMD+=ble/keymap:emacs/update-mode-indicator
blehook internal_PRECMD!=ble/keymap:emacs/update-mode-indicator

## @fn ble/prompt/backslash:keymap:emacs/mode-indicator
function ble/prompt/backslash:keymap:emacs/mode-indicator {
Expand Down
10 changes: 5 additions & 5 deletions keymap/vi.sh
Expand Up @@ -270,7 +270,7 @@ function ble/keymap:vi/complete/insert.hook {
[[ $_ble_decode_keymap == vi_imap ]] &&
ble/keymap:vi/undo/add more
}
blehook complete_insert+=ble/keymap:vi/complete/insert.hook
blehook complete_insert!=ble/keymap:vi/complete/insert.hook

function ble-decode/keymap:vi_imap/bind-complete {
ble-bind -f 'C-i' 'vi_imap/complete'
Expand Down Expand Up @@ -442,7 +442,7 @@ function ble/keymap:vi/info_reveal.hook {
_ble_keymap_vi_mode_name_dirty=
ble/keymap:vi/update-mode-indicator
}
blehook info_reveal+=ble/keymap:vi/info_reveal.hook
blehook info_reveal!=ble/keymap:vi/info_reveal.hook

bleopt/declare -v prompt_vi_mode_indicator '\q{keymap:vi/mode-indicator}'
function bleopt/check:prompt_vi_mode_indicator {
Expand Down Expand Up @@ -504,7 +504,7 @@ function ble/keymap:vi/update-mode-indicator {

ble/edit/info/default ansi "$str" # 6ms
}
blehook internal_PRECMD+=ble/keymap:vi/update-mode-indicator
blehook internal_PRECMD!=ble/keymap:vi/update-mode-indicator

## @fn ble/prompt/backslash:keymap:vi/mode-indicator
## @var[in,opt] prompt_vi_keymap
Expand Down Expand Up @@ -2416,7 +2416,7 @@ ble/array#push _ble_textarea_local_VARNAMES \
#

ble/array#push _ble_edit_dirty_observer ble/keymap:vi/mark/shift-by-dirty-range
blehook history_leave+=ble/keymap:vi/mark/history-onleave.hook
blehook history_leave!=ble/keymap:vi/mark/history-onleave.hook

## @fn ble/keymap:vi/mark/history-onleave.hook
function ble/keymap:vi/mark/history-onleave.hook {
Expand Down Expand Up @@ -2454,7 +2454,7 @@ function ble/keymap:vi/mark/update-mark-history {
_ble_keymap_vi_mark_hindex=$h
fi
}
blehook history_change+=ble/keymap:vi/mark/history-change.hook
blehook history_change!=ble/keymap:vi/mark/history-change.hook
## @fn ble/keymap:vi/mark/history-change.hook 'delete' index...
## @fn ble/keymap:vi/mark/history-change.hook 'clear'
## @fn ble/keymap:vi/mark/history-change.hook 'insert' beg len
Expand Down
4 changes: 2 additions & 2 deletions lib/core-complete.sh
Expand Up @@ -6167,8 +6167,8 @@ function ble/complete/menu/clear {
fi
return 0
}
blehook widget_bell+=ble/complete/menu/clear
blehook history_leave+=ble/complete/menu/clear
blehook widget_bell!=ble/complete/menu/clear
blehook history_leave!=ble/complete/menu/clear

## @fn ble/complete/menu/get-footprint
## @var[out] footprint
Expand Down
2 changes: 1 addition & 1 deletion lib/core-syntax.sh
Expand Up @@ -7464,7 +7464,7 @@ function ble/highlight/layer:syntax/textarea_render_defer.hook {
_ble_syntax_word_defer_umin=-1
_ble_syntax_word_defer_umax=-1
}
blehook textarea_render_defer+=ble/highlight/layer:syntax/textarea_render_defer.hook
blehook textarea_render_defer!=ble/highlight/layer:syntax/textarea_render_defer.hook

#%#----------------------------------------------------------------------------
#%# old test samples
Expand Down
2 changes: 1 addition & 1 deletion lib/init-msleep.sh
Expand Up @@ -24,5 +24,5 @@ function ble/util/msleep/.load-compiled-builtin {
ble/bin/cp "$builtin_path" "$builtin_runpath" || return 1

enable -f "$builtin_runpath" msleep || return 1
blehook unload+='enable -d ble/builtin/msleep &>/dev/null'
blehook unload!='enable -d ble/builtin/msleep &>/dev/null'
}
4 changes: 2 additions & 2 deletions note.txt
Expand Up @@ -1878,8 +1878,6 @@ bash_tips

* complete: progcomp 引数について https://github.com/scop/bash-completion/issues/790

* blehook HOOK+= を HOOK!= に統一する。

2022-07-20

* konsole drag&drop
Expand Down Expand Up @@ -6562,6 +6560,8 @@ bash_tips

2022-08-29

* 2022-08-23 blehook HOOK+= を HOOK!= に統一する [#D1871]

* 2022-08-14 nix develop が保存された EPOCHREALTIME を復元しようとしている [#D1870]
https://discourse.nixos.org/t/nix-print-dev-env-command-shows-some-assinments-to-readonly-variables/20916
https://github.com/NixOS/nix/pull/6800
Expand Down
2 changes: 1 addition & 1 deletion src/color.sh
Expand Up @@ -65,7 +65,7 @@ function ble/color/initialize-term-colors {
bleopt term_true_colors="$value"
fi
}
blehook term_DA2R+=ble/color/initialize-term-colors
blehook term_DA2R!=ble/color/initialize-term-colors


function ble-color-show {
Expand Down
8 changes: 4 additions & 4 deletions src/def.sh
Expand Up @@ -85,10 +85,10 @@ blehook/declare complete_insert

# for compatibility:
function blehook/.compatibility-ble-0.3 {
blehook keymap_load+='ble/util/invoke-hook _ble_keymap_default_load_hook'
blehook keymap_emacs_load+='ble/util/invoke-hook _ble_keymap_emacs_load_hook'
blehook keymap_vi_load+='ble/util/invoke-hook _ble_keymap_vi_load_hook'
blehook complete_load+='ble/util/invoke-hook _ble_complete_load_hook'
blehook keymap_load!='ble/util/invoke-hook _ble_keymap_default_load_hook'
blehook keymap_emacs_load!='ble/util/invoke-hook _ble_keymap_emacs_load_hook'
blehook keymap_vi_load!='ble/util/invoke-hook _ble_keymap_vi_load_hook'
blehook complete_load!='ble/util/invoke-hook _ble_complete_load_hook'
}
function blehook/.compatibility-ble-0.3/check {
if ble/is-array _ble_keymap_default_load_hook ||
Expand Down
12 changes: 6 additions & 6 deletions src/edit.sh
Expand Up @@ -2579,7 +2579,7 @@ function ble-edit/attach/.attach {
fi

ble/builtin/trap/install-hook WINCH readline
blehook internal_WINCH-+=ble-edit/attach/TRAPWINCH
blehook internal_WINCH!=ble-edit/attach/TRAPWINCH

ble-edit/adjust-PS1
ble-edit/adjust-READLINE
Expand Down Expand Up @@ -6403,7 +6403,7 @@ function ble-edit/exec:gexec/.TRAPERR {
fi
return 0
}
blehook internal_ERR+='ble-edit/exec:gexec/.TRAPERR'
blehook internal_ERR!='ble-edit/exec:gexec/.TRAPERR'

# ble-edit/exec:gexec/TERM
#
Expand Down Expand Up @@ -6460,7 +6460,7 @@ function ble-edit/exec:gexec/.begin {

# C-c に対して
ble/builtin/trap/install-hook INT # 何故か改めて実行しないと有効にならない
blehook internal_INT+='ble-edit/exec:gexec/.TRAPINT'
blehook internal_INT!='ble-edit/exec:gexec/.TRAPINT'
ble-edit/exec:gexec/.TRAPDEBUG/restore
}
function ble-edit/exec:gexec/.end {
Expand Down Expand Up @@ -7279,7 +7279,7 @@ function ble-edit/undo/history-change.hook {
((_ble_edit_undo_hindex+=len)) ;;
esac
}
blehook history_change+=ble-edit/undo/history-change.hook
blehook history_change!=ble-edit/undo/history-change.hook

## @fn ble-edit/undo/.get-current-state
## @var[out] str ind
Expand Down Expand Up @@ -7542,7 +7542,7 @@ function ble-edit/history/history-message.hook {
ble/edit/info/immediate-default
fi
}
blehook history_message+=ble-edit/history/history-message.hook
blehook history_message!=ble-edit/history/history-message.hook

#
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -9772,7 +9772,7 @@ if [[ $bleopt_internal_suppress_bash_output ]]; then
ble/builtin/trap/invoke USR1
}
blehook/declare internal_USR1
blehook internal_USR1+=ble-edit/io/TRAPUSR1
blehook internal_USR1!=ble-edit/io/TRAPUSR1
ble/builtin/trap/install-hook USR1

function ble-edit/io/check-ignoreeof-message {
Expand Down
6 changes: 3 additions & 3 deletions src/history.sh
Expand Up @@ -423,7 +423,7 @@ if ((_ble_bash>=40000)); then
[[ $opt_async ]] && ! ble/util/idle/IS_IDLE && return 148
done
}
blehook history_reset_background+=_ble_history_load_resume=0
blehook history_reset_background!=_ble_history_load_resume=0
else
function ble/history:bash/load/.generate-source {
if ble/builtin/history/is-empty; then
Expand Down Expand Up @@ -828,7 +828,7 @@ if ((_ble_bash>=30100)); then
((_ble_bash>=40000)) &&
ble/util/idle.push 'ble/history:bash/resolve-multiline async'

blehook history_reset_background+=_ble_history_mlfix_resume=0
blehook history_reset_background!=_ble_history_mlfix_resume=0

function ble/history:bash/resolve-multiline/readfile {
local filename=$1
Expand Down Expand Up @@ -1179,7 +1179,7 @@ function ble/builtin/history/array#insert-range {
for i in "${!out[@]}"; do ARR[i]=${out[i]}; done'
builtin eval -- "${script//ARR/$array_name}"
}
blehook history_change+=ble/builtin/history/change.hook
blehook history_change!=ble/builtin/history/change.hook
function ble/builtin/history/change.hook {
local kind=$1; shift
case $kind in
Expand Down
2 changes: 1 addition & 1 deletion src/util.hook.sh
Expand Up @@ -726,7 +726,7 @@ function ble/builtin/trap/.TRAPRETURN {
esac
return 0
}
blehook internal_RETURN+=ble/builtin/trap/.TRAPRETURN
blehook internal_RETURN!=ble/builtin/trap/.TRAPRETURN

# user trap handler 専用の $?, $_ の記録。
_ble_builtin_trap_user_lastcmd=
Expand Down
2 changes: 1 addition & 1 deletion src/util.sh
Expand Up @@ -5215,7 +5215,7 @@ function ble/term/.initialize {
fi

ble/string#reserve-prototype "$_ble_term_it"
blehook term_DA2R+=ble/term/DA2R.hook
blehook term_DA2R!=ble/term/DA2R.hook
}
ble/term/.initialize

Expand Down

0 comments on commit fe7abd4

Please sign in to comment.