Skip to content

Commit

Permalink
Add more logging facilities
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed Jun 7, 2021
1 parent 912e7f5 commit fd801e4
Showing 1 changed file with 45 additions and 31 deletions.
76 changes: 45 additions & 31 deletions module/.autocomplete.async
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ bindkey -s -M menuselect '^S' '^G^S'

# Start names with `.` to avoid getting wrapped by syntax highlighting.
zle -N .autocomplete.async.pty.zle-widget
zle -C .autocomplete.async.pty.completion-widget list-choices .autocomplete.async.pty.completion-widget
zle -C .autocomplete.async.pty.completion-widget list-choices \
.autocomplete.async.pty.completion-widget
zle -N .autocomplete.async.complete.fd-widget
zle -C ._list_choices list-choices .autocomplete.async.list-choices.completion-widget
zle -N .autocomplete.async.timeout.fd-widget
Expand Down Expand Up @@ -249,54 +250,67 @@ bindkey -s -M menuselect '^S' '^G^S'
}

.autocomplete.async.pty() {
setopt $_autocomplete__options
setopt NO_completeinword; [[ -z $curcontext ]] ||
setopt completeinword

setopt promptsubst
builtin setopt promptsubst
PS1= RPS1=
PS4=$_autocomplete__ps4

local hooks=( chpwd periodic precmd preexec zshaddhistory zshexit )
unset ${^hooks}_functions &>/dev/null
$hooks[@] () { : }
local hook; for hook in isearch-exit isearch-update line-pre-redraw line-init line-finish \
history-line-set keymap-select; do
zle -N zle-$hook .autocomplete.async.pty.no-op
done
() {
builtin setopt $_autocomplete__options
builtin setopt NO_completeinword; [[ -z $curcontext ]] ||
builtin setopt completeinword

local hooks=( chpwd periodic precmd preexec zshaddhistory zshexit )
builtin unset ${^hooks}_functions &>/dev/null

$hooks[@] () {
:
}

local hook; for hook in isearch-exit isearch-update line-pre-redraw line-init line-finish \
history-line-set keymap-select; do
builtin zle -N zle-$hook .autocomplete.async.pty.no-op
done

typeset -gH lbuffer=$1 rbuffer=$2
typeset -gH lbuffer=$1 rbuffer=$2

bindkey $'\t' .autocomplete.async.pty.zle-widget
local __tmp__
vared __tmp__
builtin bindkey $'\t' .autocomplete.async.pty.zle-widget
local __tmp__
builtin vared __tmp__
} "$@" 2>&$_autocomplete__log_fd
}

.autocomplete.async.pty.no-op() {
:
}

.autocomplete.async.pty.zle-widget() {
LBUFFER=$lbuffer
RBUFFER=$rbuffer
zle .autocomplete.async.pty.completion-widget -w 2>&$_autocomplete__log_fd
() {
LBUFFER=$lbuffer
RBUFFER=$rbuffer
builtin zle .autocomplete.async.pty.completion-widget -w
} "$@" 2>&$_autocomplete__log_fd
}

.autocomplete.async.pty.completion-widget() {
local curcontext=${curcontext:-${WIDGET}:::}
unset 'compstate[vared]'
local +h -a comppostfuncs=( .autocomplete.async.pty.message )
{ .autocomplete.async.list-choices.main-complete
} always {
print -rNC1 - '' '' "$compstate[nmatches]" "${(q+)_message_}" ''
}
compstate[insert]=''
compstate[list]=''
compstate[list_max]=0
() {
local curcontext=${curcontext:-${WIDGET}:::}
unset 'compstate[vared]'
local +h -a comppostfuncs=( .autocomplete.async.pty.message )
{
.autocomplete.async.list-choices.main-complete
} always {
builtin print -rNC1 - '' '' "$compstate[nmatches]" "${(q+)_message_}" ''
}
compstate[insert]=''
compstate[list]=''
compstate[list_max]=0
} "$@" 2>&$_autocomplete__log_fd
}

.autocomplete.async.pty.message() {
typeset -gH _message_=$mesg
() {
typeset -gH _message_=$mesg
} "$@" 2>&$_autocomplete__log_fd
}

.autocomplete.async.complete.fd-widget() {
Expand Down

0 comments on commit fd801e4

Please sign in to comment.