From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id c5d53ed3 for ; Mon, 11 Nov 2019 15:41:29 +0000 (UTC) Received: (qmail 17191 invoked by alias); 11 Nov 2019 15:41:21 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44908 Received: (qmail 800 invoked by uid 1010); 11 Nov 2019 15:41:21 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f65.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25628. spamassassin: 3.4.2. Clear:RC:0(209.85.166.65):SA:0(-2.0/5.0):. Processed in 0.898638 secs); 11 Nov 2019 15:41:21 -0000 X-Envelope-From: roman.perepelitsa@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.65 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EM4yVLfxBoIjLO2DiefyaGgqfk/7ej7e1BsySEkqByY=; b=cyohmghwvVxDLXpTu5od+N9w0+WiZCfvUSolF6+cjx+mlgbaW4WbrLz7PLdMkM2j9Z Vm9OMmPGP3AOH5m0r8K/SLxVqfNdH16S2DFKCNPRRt9tztpufNNtcstUvXBceqIIk9Bb eOtHKpShdXFpD+9JFs4AJY8D3WNXocD5UgBI4mNFBr78eA9yYIDgHVxWxQdiRHkIx6nb LDrYYV58IlaPZtD/j6WIb0vQCvtcvU1Ck8cI3HNcEjMO8a/DsjXWbKBI+LPt5zCFBAiQ BO+VOQmB5q3MUzcl08nowIo63+J0rCk1NSgKNsMi20JzOhj5NMwXwtKuYiUuOjF5Ik/7 12ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EM4yVLfxBoIjLO2DiefyaGgqfk/7ej7e1BsySEkqByY=; b=Awrv6c8q3Qabs1IfU0qEkkZupBpWPUdQv1V+Dzq2/0vL2UZISJOpqGIA37OOZ9P4vu lFSkli+X0mmQUML+x9rknkUk+OHIZ5HhBekTUZxPeUubhdpPY8RNJqsCCf8u5PpPpBv3 GB3z24Fglz6y0Q3NT3HptNeBEm2Bvn/vXXNb3beDt2KhwIPFK678Lxma3P1YeZ6p82FI A63wz8XReFuiWrSJDOOR+Hr5uLyRu4x0PqkO5bk6k3O+VlN3Sy2RwaDJ+RdIswQP2zD8 WG+ea6TsU43T5/kwI2XvZoRWPXzt3US2qqooymAsMR7RU+AGFWEHKcQXwBEe2zBJSPbz 748w== X-Gm-Message-State: APjAAAWdXZ6QPksRy0mQQk1kHz2DxWEV/Hsm3SfiaWVgvFKKL7D/FKy9 T4GAVdJfmTgU4ACFzrdMZl5ViPVhUeVpkU56FMKI/X6wquc= X-Google-Smtp-Source: APXvYqzC6IfYJGNfTqAnKOI1JVMeCsbRRPaxsZjsyEQMczPpTxmETOO6WFSU8ddte+qQlIjBvnQKWErXNRRG0paZzQY= X-Received: by 2002:a5d:8953:: with SMTP id b19mr26207744iot.168.1573486846867; Mon, 11 Nov 2019 07:40:46 -0800 (PST) MIME-Version: 1.0 References: <1573484293.4561.8.camel@samsung.com> In-Reply-To: <1573484293.4561.8.camel@samsung.com> From: Roman Perepelitsa Date: Mon, 11 Nov 2019 16:40:35 +0100 Message-ID: Subject: Re: [BUG] Crash when accessing WIDGETSTYLE from SIGINT trap To: Peter Stephenson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" On Mon, Nov 11, 2019 at 3:58 PM Peter Stephenson wrote: > > On Mon, 2019-11-11 at 15:38 +0100, Roman Perepelitsa wrote: > > Crash at zle_params.c:436 due to bindk being null: > > > > Widget widget = bindk->widget; > > Looks to me like returning the empty string in that case would be fine? I don't know. I haven't sent a patch because I'm not sure whether the fix should be right there in get_widgetstyle or somewhere earlier so that bindk is not null to begin with. I should've explained what I'm trying to do. I want to use a long prompt for the current command line and a short prompt for complete commands. Sort of like transient_rprompt option but instead of hiding just right prompt I want to hide most of left prompt too. Here's a short demo: https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/transient-prompt.gif. Here's how I'm doing it: - Set long prompt in precmd. - Set short prompt in zle-line-finish and on SIGINT. The code: set-long-prompt() { PROMPT='%~%# ' } precmd_functions=(set-long-prompt) set-short-prompt() { if [[ $PROMPT != '%# ' ]]; then PROMPT='%# ' zle .reset-prompt fi } zle-line-finish() { set-short-prompt } zle -N zle-line-finish trap 'set-short-prompt; return 130' INT One issue with this code is that after hitting Ctrl-C, set-long-prompt doesn't get called, so I end up with a short current prompt. I don't know why this happens but apparently I can work around this by adding another precmd hook before set-current-prompt. This extra hook won't be called after Ctrl-C but set-current-prompt will. do-nothing() {} precmd_functions=(do-nothing set-current-prompt) Unfortunately, there are a few other cases where hitting Ctrl-C will result in the current prompt ending up short rather than long. For example, if I this Ctrl-C after typing this: autoload -U compinit compinit zstyle ':completion:*' menu select grep -i If I didn't trap SIGINT, Ctrl-C would simply close the completion menu here without reexpanding prompt. But now prompt will become short. To deal with this issue I tried changing my trap so that it doesn't reset prompt if SIGINT arrives during completions: trap '[[ $WIDGETSTYLE == .expand-or-complete ]] || set-complete-prompt return 130' INT Unfortunately it crashes zsh as I've described in the original email. It also doesn't really solve the problem. If I press Ctrl-S to trigger fwd-i-search and then hit Ctrl-C, I'll end up with short prompt, too. fwd-i-search is not a completion widget, so the condition in my trap doesn't help. What I really want is to follow the same logic as transient_rprompt but instead of hiding right prompt I want to change left prompt. Any hints on how I should do this? I feel like I'm digging in the wrong direction. Roman.