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 31b63be2 for ; Thu, 14 Nov 2019 00:26:32 +0000 (UTC) Received: (qmail 5821 invoked by alias); 13 Nov 2019 16:11:52 -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: 44911 Received: (qmail 29975 invoked by uid 1010); 13 Nov 2019 16:11:52 -0000 X-Qmail-Scanner-Diagnostics: from mail-il1-f173.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.173):SA:0(-2.0/5.0):. Processed in 1.493294 secs); 13 Nov 2019 16:11:52 -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.173 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:content-transfer-encoding; bh=xregVOCknnVTToVZj+jTGtA4I4c4EwOYZKE8cIMZ+Y4=; b=G5QDf6gPYi+mMhu8GvMNBQfkOIZq4WsLEnzbs2zAdX87BCgeXuIpIzZYEcKMngWFKW wfBjwcL1EcdKYW5xNmVDIqkNxY/Mme/f0Hl/k28wpev6TZ9wLY7/QaK2MSHbV2j896Fx ybqAcNLF0wa6Bo9Wva3/Kt4BvZxC9UzhiLdM4QOpAfn9f9S7NBwjpJzRET6RmGNVi8ol ozGXo25EzpAItQYbwiHqno7/XAVuz61w+STjSOADWnjxzyjQ94D8d5UzX1T7RfItACd5 Fj6MaKmJRuy4YJzUZomXGNxCMuFeAGcyWROiMjTIDWQvRSw0C17YNpJiq9uYwiUVnG57 WP4Q== 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:content-transfer-encoding; bh=xregVOCknnVTToVZj+jTGtA4I4c4EwOYZKE8cIMZ+Y4=; b=G00UCuSC/jE4jc3X5y/w2i5ozPkn0WtkYKXFIcKa8oPEVP+TN2x+lp7l6huu9eP/YL HPw82arkk7Bz5qcUG5EeItVn8vDjxRB94VdJgQ1/y4DQrx+7ThegmmJd2MmVMtEnM/kJ ueaLSLFMlFBc/LmOKlRMcD76IzTVojxzbPpaQezLZPHqlG/wEEJ8JmbJeACHLc3oLDaN Xbq0LBGBRRdonnyjTQwnx0dJDSiiBEyykg5tszMPV51hWqGfQ5vqfWaoDWrY10Nqxizn /WBQBIph3O/uiyjmpHBujM5a/h3Eg3sXXg2I3as6biWxwTLRn+PkYiMhYbjpgpdhQHXw vInw== X-Gm-Message-State: APjAAAWAbmQhc3JuHBt5L5BsWIbPmDNyWCEaBRmrhm2iKA56V4Y6uHh0 clOh0zHqjO1TKXRoGomslV3yw67WIXzHsZ3LTac= X-Google-Smtp-Source: APXvYqyYEDb9GiEDoXHYoP6v+NTN62mkO2/3Sc++WYF3ysssAKcRGpPLUTzkGWOfiOzRNgESh3tgisbq7BZ0dYm256Y= X-Received: by 2002:a92:1705:: with SMTP id u5mr4889063ill.151.1573661476229; Wed, 13 Nov 2019 08:11:16 -0800 (PST) MIME-Version: 1.0 References: <1573484293.4561.8.camel@samsung.com> In-Reply-To: From: Roman Perepelitsa Date: Wed, 13 Nov 2019 17:11:04 +0100 Message-ID: Subject: Re: [BUG] Crash when accessing WIDGETSTYLE from SIGINT trap To: Mikael Magnusson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Nov 12, 2019 at 3:56 PM Mikael Magnusson wrote: > Have you tried restoring the long prompt in zle-line-init instead? No, I haven't. zle-line-init is a bit too late. Prompt is already expanded and printed out at that point. I could still change PROMPT there and call `zle reset-prompt` but it would be slower than changing PROMPT in precmd. As I mentioned, I've found a workaround for the bug that causes the first element of precmd_functions to get skipped over after Ctrl-C, so the part of my code that restores long prompt works correctly in all cases where I've tried it. The unresolved problem is that my code calls set-short-prompt in some cases when it shouldn't after Ctrl-C. zle can effectively be in two states and I don't know how to distinguish between the two when my SIGINT trap triggers. Normal state: Keyboard input goes into BUFFER. When Ctrl-C is pressed in this state, new prompt is created. When my SIGINT trap triggers, I want to shorten prompt. Before Ctrl-C: /tmp% echo hello=E2=96=88 After Ctrl-C: /tmp% echo hello /tmp% =E2=96=88 Modal state: Keyboard input goes into some place other than BUFFER. When Ctrl-C is pressed, zle state changes to normal but a new prompt is not created. When my SIGINT trap triggers, I want to do nothing. (This is where my current code works incorrectly because it always shortens prompt on SIGINT.) Before Ctrl-C: /tmp% grep - zsh: do you wish to see all 180 possibilities (45 lines)? =E2=96=88 After Ctrl-C: /tmp% grep -=E2=96=88 Before Ctrl-C: /tmp% echo hello bck-i-search: hell=E2=96=88 After Ctrl-C: /tmp% =E2=96=88 How can I distinguish between these states? How can I figure out from within a SIGINT trap whether zle will or won't create new prompt after my trap function returns? Roman.