From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9649 invoked from network); 18 Aug 2023 04:43:00 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 Aug 2023 04:43:00 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1692333780; b=evz7lC9AosyzaX1tN3TonVPZoIGBq9w4qIbdIsQAmopgPg/a34c2WCgj19KjLHxUFt1aoy5h0g S1jHyf6hfBHx1OR/BxQDkypPcZMDq6BmoyS6EiSJhqGV3Du1sTlNqLUc4i+pknyYmD1q6YUzCT 3z6zDvOzCGld+FwNsd6CDrTdst1afWBrpjiIBWC0iNojRtaBMZ3pTGaK9m9qoPHHLMKRVdBmyU qS7paTPHKpagpgHCvRGLqeQMyYOxauVrNSavqKEBuXoYjvYKTA7fTMiOuF5F1tF/quPu1urVFZ NLdvmj9BS1+XWq9wSMB3d6iSm4Q+a1IROWbtva2rO6QGqw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f177.google.com) smtp.remote-ip=209.85.208.177; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1692333780; bh=43AZdBOwAqxQJMaOZi2ziri7zKWDmhIwJHy3IWnpOUQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=l2YHCC3mr9gxeAtR3tYczJANNHCl88VO+KH48+Lvyu8NelqdxjlUyoYUBan5FFKJ06ijpF0r3w yp+3S+4nYP/JnTj6digvqe7pA3t59kIFRDJXH63hIAskxrcJyLf7yORRIHRqZKN9CNwBPV2q/p 4Y0SjNS2aoeEXvQUiQhiPUF3E+gaauISnFcKbQ0IF6iRrm8jLgYYabxbHEJk0UQ5HVTwTZN6V4 nCfergsAuHLCHWoHNJBLC9AZqATqjVYxJFDGup0CttgBIaEij3kVNU5R1qLFI7CcHg/TNWlm1s 4JZkee12gEZsaEv9vwmJRbCeDpwXaYO0JhX2j0EwnWBdfQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=5W+KXp4LKUCvyHmgraOJ66FWffsp91x5vyUIdGdQMYs=; b=ThAWD5FP+gDBB61ZZkf+pZFfYX w7UsLqhuz2c0eOQs29T2ffOY29MbABU1YwKCi9aG/BivYIixAUmMbZzh2VETt9VZDHYHlWylYrpqK BxC1oFki7Ssmc/UoVwwnPixilXUwDsdPQjKVqK1C78WVPjp5eQLVAv+BOCz2xGUlRR97RyAIEgU0J aphlxLPR9K+nTxxwldCQRf55Kg6DIvJyQnDNOACkkCYhhO2+QQZDV4hcxHFV4AEmtLzjQfT+Pk3N1 CTCqx/0nm/8bfe/lSEgZ3mdO1hle/Dl+eDB+7ci8BGO1OFFsZ9TtfHjsIVdn1S1p4ww6ojNlH2D2u ZQVU4U0Q==; Received: by zero.zsh.org with local id 1qWrK6-0007ue-Q1; Fri, 18 Aug 2023 04:42:58 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f177.google.com) smtp.remote-ip=209.85.208.177; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-lj1-f177.google.com ([209.85.208.177]:46524) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qWrJV-0007Ev-Gc; Fri, 18 Aug 2023 04:42:22 +0000 Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2b9b5ee9c5aso7317241fa.1 for ; Thu, 17 Aug 2023 21:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20221208.gappssmtp.com; s=20221208; t=1692333740; x=1692938540; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5W+KXp4LKUCvyHmgraOJ66FWffsp91x5vyUIdGdQMYs=; b=pdNgcW02op62dExdyjKCLDvpXyDDfv2ab5VRXYClXg7TOZz8fdUZCTGu1YbR941bpg 7hIIQAGIqV6Y7r6lrh4YCg9q59C6EIF03cHWKBHzcbGe40vQu1bXzmLrTk9sd9ccCe8w 8VLv4BhFpSGKnQqE5StIwOt/Q5ZDgZ+LTP+JFI9KtxU0g+oSGv0zRfp1DlboLs/iGk3d fBK0sLsC+lzB5zRSMweMYKfSE6OQrI8juI4bgRHcdzXYa5gLcdljQ2RauppHZvII1rxn AG77AIDftYJ5bH5eCQJgf00drwYAH/x0rEVl/1860PhCdzjm2WFuk9+eLm4R7y8ClouF OBzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692333740; x=1692938540; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5W+KXp4LKUCvyHmgraOJ66FWffsp91x5vyUIdGdQMYs=; b=d/McUqMALiq4ISZ4Uax6daVLfg0xOhsJEJC6anznYNmB8XzqJw9qZKMslpOBFTxlT9 qYXFamH1hqeQ9WzmMyywARg85QX8DCeVk04Bx7w6rVw8UnM7I0+X7anmb976BFSdVcVK 688ApRhbUYM9gyee31HHXd6l8XgJOaKQ2gStFiRlSjhvh1PXbYXfpyvMHQf4WnqhmxhR l8bZ7oiSeKtp86jlppSheu5nnI/NHKjaAbn9aQ9n+RBVWujEHl2Y5+iRT9bcPeZHWOZi JvSJvO62ihR5aaDnLZEX8vnNVq+shjT1n0bkgQhC+nHw2mR/6zFXtSIBGUnTtIPJF5r1 I8kg== X-Gm-Message-State: AOJu0Yx/gQtcA6kBPoYjrLA3RV3GfRjcHvZ1JGF7SIIns690zfYCrBSX h0WhuOSPLRbdL5s/9mp05pTiAMq5gHsIZnvOwX/mqw== X-Google-Smtp-Source: AGHT+IGF9iDa3YCU/3UmN+yxFtDSdxxoDixc0WrVpe62G1Ep2atApJzRH6+omYYuwmYvdboC3a0DmbEWIMmrDZM+okQ= X-Received: by 2002:a2e:84ce:0:b0:2b5:8bb9:4dd6 with SMTP id q14-20020a2e84ce000000b002b58bb94dd6mr935085ljh.12.1692333739757; Thu, 17 Aug 2023 21:42:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Thu, 17 Aug 2023 21:42:08 -0700 Message-ID: Subject: Re: widget function must have zle codes To: Budi Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29168 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Thu, Aug 17, 2023 at 6:27=E2=80=AFPM Budi wrote: > > bindkey -s "^m" "\e[H 2>/dev/null [[ $- =3D~ x ]]&&{ set +x;echo Trace > OFF ;} ||{ set -x;echo Trace ON;};print -s '\e[F'\r\e[A" To the best of my ability to interpret that ... literally: binding-for-ctrl-m () { zle .beginning-of-line zle -I { if [[ -o xtrace ]]; then { set +x; echo Trace OFF } else { set -x; echo Trace ON } fi zle .end-of-line zle .accept-and-hold } 2>/dev/null } zle -N binding-for-ctrl-m bindkey ^m binding-for-ctrl-m This "works" but there's a problem not of your making: ZLE widgets are not allowed to change the global setting of XTRACE -- it is always saved on entry to ZLE and restored again on exit -- so the set -x or +x in the widget is useless. Before I fix that, let me point out that the beginning/end-of-line motions are not needed, I included them just to translate as closely as possible. Even with bind -x in bash the \e[H is not needed; I'm not sure about the \e[F. The "zle -I" is what tells zle that some other output is coming, so it should get out of the way and then repaint when it gets control again. bind -x does that too, at least in some simple experiments. To avoid the XTRACE problem, if I'm following correctly what you expect the \e[F\r\e[A part to accomplish, the shortest solution is probably: binding-for-ctrl-m() { zle -I print Trace ON eval "() { setopt localoptions xtrace; $BUFFER }" print Trace OFF } If you actually require the set -x to take global effect but be invisible to the history etc., it gets a lot more complicated, so I won't go there yet. As a last note, "print -s" writes to the history list, not to the editor, so you would never use that for editor control keystrokes. If you really need to send the key binding for an action instead of calling it with "zle widget-name", that's what "zle -U" is for, but anything sent that way is not looked at until the current widget returns.