Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: TRAPINT breaks consecutive menu-complete



On Sat, Feb 08, 2025 at 12:27:17 +0100, Tomasz Pala wrote:

> $ echo $? [tab tab ctrl-c enter]
> $
>
> Note the last command was not executed at all..!

I've actually realized this is the reason some of my tests were not
reproducible... The commands from buffer were not executed at all after
enter, if _previous_ action was terminated by ctrl-c. And _this_ is
really bad...

> So - TRAPINT must return 1+ to stop completion, and at the same time
> return value from TRAPINT influences consecutive action (let it be next
> completion, or accept-line...).

function TRAPINT { zle send-break; return 1; }

seems to do the job - except when send-break SEGVs:

$ ls [tab tab tab ctrl-c] - OK
$ ls [tab tab       ctrl-c] - SEGV
$ ls [tab tab alt-a ctrl-c] - SEGV

(which was already reported). 
So - I cannot find any condition for send-break to succeed, nor
substitute send-break with anything less invasive.

As ctrl-c sends INT via line discipline, I cannot bindkey it to
something else (nevertheless, different binding with widget defined to
kill -s INT $$ immediately breaks current line, so there seems to be no
way to terminate menu-selection only and withdraw completions:

function break1 { zle send-break / undo; }
zle -N break2 break1
bindkey -M menuselect '^f' break2

) - i.e. I didn't find a way to emulate SIGINT for menu-selection...

> I would expect completion to _handle_ INT (by stopping own execution),
> therefore return 0 for "parent" ("normal" mode). After all, since
> completion in nested mode and might receive various signals, these
             iS nested mode
> return codes are irrelevant for current buffer editor, aren't they?

I think this is the right approach.

Currently zle -C behaves differently than zle -N. In order to fix this I
should replace all the completion widgets with user-defined ones.

Unless there is a way to redefine menu-selection globally, to always
return 0 after being terminated?

-- 
Tomasz Pala <gotar@xxxxxxxxxxxxx>




Messages sorted by: Reverse Date, Date, Thread, Author