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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29834 invoked from network); 18 Aug 2023 01:28:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 Aug 2023 01:28:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1692322099; b=jYbEOXrySg5s6yghvRu3QulffDT2ccta8Vm0J+5VfUBQCRTa5zdyhBOiqC26tXRn3CGd3qWUDu 9ZGUw/GhLfOyuNQC0Iq+1OWh0csvmw7AIfEqotfEnUOzhUmwVLTMYFi4XXhT3DBEUVOO2kA0n7 E8fa9stf4zgR50iPJA8y213ko26jV1cCRf1KMHTTP8CBiNK3m2LVJFPYiw6IuujRWzVpxo7SZe UzayeGjoV+mtjFMxQdZ6Njz7beiHEZg+HhPK/baRi7ImuNk/BCJZKbgRGYaO4SdddrZVi+GGkR eONbmxy/3CVRBIqvAbgLekeZqshSqTr25uHw2ER+Idnr5w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f41.google.com) smtp.remote-ip=209.85.128.41; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1692322099; bh=gnKMvbzep0NQAQMH7ZSCDu8VMG7QsGf1QDhgTAJjDiQ=; 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:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=KkgEJguw/r/zxeYXB7OKr9IP1MXgOJ3J7XzRO5XcuLBBTcSLsrr/jj1dAsVkl0iGMZGdztSMof 2FvdqTNdptFZA86A88MjCUIll0NALVb33RVGDY1uKthfa2pNWNRh2qHWA6/m3KHelMtH8JnWvZ MIwuc3Wluza0z1a7Dt8u4H4XPv6JpcKJu6zNvJSJI5sptfNtxu0otmWqW6mRjXynHULbRynf+t Zq1WJ3ngpt4onLHtM4p49mMHdvF3L+FrItmbLLb1WioyVEmBVI3rfJ7Kjzc6PoFrBZVyriiLkO Uc7sGJfs0RhK5HUfxG4wWOIFzg7/wk5cjSyodcXUDA527Q==; 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:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=bIY6sUjQaMG9bfH1g/k1FWD7grKclTB5/TPLh27Iutw=; b=K8Xj5s+HYuIdFVsx0NoMJ/wmlL kkfT4iZd+9/nWG0s+HMb0dfMmIbYj1PxYbf0d9DwUtbRwKiE9RkVjsX5HRsrsHmu8mHJfKpgP3QbS p/wqPHe+MwXtUT2rkU7RtA3/6L8LiDHMmk4BleEwJfYO9359jIb+c2u7U7S+HYeCzRIdy54NDNDxy BGIKLWAWsT0ntKnca77gJNFO6m6dRQLz4sua7xa21LyS+h6WbvNKsTh9UTk9PvjKeplfY4hE9008s E+v0RkpXR6XP9QYr6sJS1dVC8OqwhahaZ96/2pUTK3VU+YoijSoZN29/Vtsak/fExebwUkGsP4epP Eg13yobg==; Received: by zero.zsh.org with local id 1qWoHi-000Otm-4G; Fri, 18 Aug 2023 01:28:18 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f41.google.com) smtp.remote-ip=209.85.128.41; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wm1-f41.google.com ([209.85.128.41]:57608) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qWoH7-000O9z-Kc; Fri, 18 Aug 2023 01:27:43 +0000 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-3fe4ad22eb0so4236695e9.3 for ; Thu, 17 Aug 2023 18:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692322061; x=1692926861; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bIY6sUjQaMG9bfH1g/k1FWD7grKclTB5/TPLh27Iutw=; b=VeJI2htnsate0ash2ZDpyjqjh+wXwRcF6l/SicbuPMCVN8hjaJbOMbKm3erJybiLuj +RGAwEiAaYgCDOVi2dVm+fv5uo67I2BwEeiBmmgduWdER6j3+rnSsaG/hwn5OXS7uhL/ IUnEKQ/WlskDVo75Sk0YVBdW1pAWPuc8OvbgAUE6SKFiK/IJYwFq4o92Nd70G09Mv8yp Ruw7muCzrjUvNI73rC7NaAXM9ysfDT4dNpYbgoXLmveLm52aw7zi8jKWhZ4RjMT5zpBD hJH+uMRITyJweS36Q11R7/t+qKGI0O+Z2Wdz+ZhwEARls/bfYxfY7C5+6TCq1Hkn/8rR RPhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692322061; x=1692926861; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bIY6sUjQaMG9bfH1g/k1FWD7grKclTB5/TPLh27Iutw=; b=f2LfetXcLtiVtVuX2g228FaKq+OhiZb+GeLQuLtXVUCZaidNA9nghpsZz+0yG9chED 9QnUeJSXNufaUOmwKB4lAVBuDVSp6+JRBZthEHqw1tcYyvqBO4pWUQJb8n6Fa8AAN1g0 UyFg/rYR/6ZQ/LuwcD3X+og2IT+pZTCAzEh2zhhERG95PLCyL+REpPyeZoGspYALXugA sNxmoo+g3rjfbkUpQGgrg6sIBuT9EvtY+AW3SbYmcVLHarcaw/4bXPNfgpXk/xBU+xET Uvg3GSR+hMLEK0edctjJnfIKOH5teJQp99IQnCGZztuHxCIVsoasXmBInjjCX7cA4UXL WxDQ== X-Gm-Message-State: AOJu0YzylLtmOJabr2y+6OKA5bglMQwZmLCCOEa219RND++X0oRvZ18Q AqM+JMp4QDV7rBfmv+4bBUzIsNwbXOeaVDwGwTDtpDyR X-Google-Smtp-Source: AGHT+IEAJRUP/JBzzntneAnf3/oNUtPgqEIHKeRQ6U9wNWgF/SjHsFhJaUJDxwSd+gSdmOk2cI3WXMXzJEvp6EnsBEA= X-Received: by 2002:a05:600c:291:b0:3fe:10d8:e7fa with SMTP id 17-20020a05600c029100b003fe10d8e7famr1016541wmk.41.1692322060983; Thu, 17 Aug 2023 18:27:40 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6020:174:b0:290:25e9:9dde with HTTP; Thu, 17 Aug 2023 18:27:40 -0700 (PDT) In-Reply-To: References: From: Budi Date: Fri, 18 Aug 2023 08:27:40 +0700 Message-ID: Subject: Re: widget function must have zle codes To: Bart Schaefer Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29165 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: original simpe aim, to nullify any std output in bind -s, (Bash bind-x default) 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" How is the precise correct one ? On 8/18/23, Bart Schaefer wrote: > On Thu, Aug 17, 2023 at 5:11=E2=80=AFPM Budi wrote= : >> >> How can;t this work >> a widget function having zle codes > > I'm not entirely sure what you're attempting to accomplish here. > >> t:1: bad pattern: e[H > > You're getting that specific error because you haven't quoted the > string properly, but I don't think it would do what you want anyway. > It looks like you're trying to extrapolate Roman's "bind-x" example to > a case it wasn't meant to cover. One would not normally create a > widget by assigning to the functions[] array, Roman did that > specifically in order to construct a new function body from the values > in the positional parameters of the "bind-x" function. > > Further, it's the "zle -N" command that creates a widget, the function > is the widget implementation. Neither of them works without the > other. > > In ZLE widgets, you don't normally refer to an action by it's key > binding, instead you refer to it by its widget name, and use the "zle" > command to run it. So instead of $'\e[H' (which would be the correct > quoting you were after), you would write > zle beginning-of-line > (or whatever action you wanted). Each built-in widget has a special > name starting with a "." that you can use to avoid calling some > user-defined replacement implementation, so you might see examples > like > zle .beginning-of-line > >> functions[t]=3D"zle -I; \e[H 2>/dev/null echo Test preceding word" > > I can't tell what you're expecting to have happen with that "echo". > If you meant for "Test preceding word" to become part of the line > being edited, you need to assign that to one of the BUFFER, LBUFFER, > or RBUFFER variables (please see the doc). > > I strongly suggest you look at some of the examples in Functions/Zle/ > in the distribution. Many are a bit esoteric but most have extensive > explanatory comments. The easiest to understand might be > Functions/Zle/history-search-end > Functions/Zle/down-line-or-beginning-search > Functions/Zle/up-line-or-beginning-search > Note these files are function bodies only, they expect to be turned > into actual widgets by (for example) > autoload history-search-end > Zle -N history-search-end > > There's also > Functions/Zle/vi-pipe > but note that its setup commentary forgot to mention the "zle -N vi-pipe" > part. >