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,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20345 invoked from network); 23 Sep 2020 11:25:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Sep 2020 11:25:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1600860319; b=sU8OzBoEMrZBvOtw8Ma83YBPJBTxU3Ob9K9nR6qkZLf6dMmbZlsNjEMfdq0u3waKJ5A14nUXQZ ktwSKREYZmebbeRgA25j270zNVd0AXT9eo1mKpm/nmcqATy3z2kS13YePzpV5GH1BuIZzcZswe kIdd+sttneBe3CvqKYaZOG8pwAb2uPRk7dplgpwsfqRteeB/vgIB7s2bPH6PlqRY2TxFcYriMs 17F1uCO2sDDCnkM5zZmhrRWqfkKRINYw+Cza+A4joCh0CfCiFYjYT+3Lock+MFNdeKtNoVXUrp h3gjq5KhuwrHMwPfPUKx4X5Vegzv6xHjhI40QxAwkyv3hQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=gmail.com header.s=20161025 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-20200801; t=1600860319; bh=qPL8l0JdqlOPeu1sMQisqoNXbGCETSgpJV8G1RAv7b8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=n/0RRQ4pBE2fk+p37BX6f6qjqW0LKMXDaiAGluD8iZaxh71K3yjcvn4JMynlEeXCTiBHvMQfua G/2oWCdMS0Nf1Kdv+BWEOHXVgF8ShmuPK7c89/ywWeM/8igCHndsLIcoAeoRYJh6/K1kdNWjvg VSSMlicHwN3faBruzWIu+SZPIoidVDO/fDMEHVzUSHdFy50uuImHggGHTH0/w8Wd8G44lDxSi1 Z21XJoFl8W/W8LP5OlXVdAmde17kMR1fgOKNPsu4AQ3fgnAwlkbl4IuacceKSOK5KwoBcLeI8N E6Ce7xo/AuwN+lBLF1oCnXLuoD6UNbYyr9v+DwzdrMjwDA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=OAyRKDuFqfOq5guftnQWcMQ0ZBIEDD9tJ8CGephepm0=; b=y30R62alGbBkIeo1AOtXfCJC6F xGy4NIZo+NIVJ6i6QLVMMkINy2ynbGt5nQeI0ahTGYQv5GHlClAtcrjS+FvmkPgR8w0sLZ6BdHOfO 9BHaUpPydHBPEE8v7S5t2AavW+2ywFpyqYx/hCTMUOA56YNfacReONQs4HnHzBh2wTtCuaZt5Tf5G 72vdmdG0gthpFPcvS/ZnbTuiFpxJXODmgC+kQr7WUGwgM1cvnL2h5Ie7QO7Z1BeKcwlOKjUd/WOmy Ur2NJaHiBqaCBLK48+MlRiB1yCcFPD3SmWEnyrjegdVLjWV2voSSfIWjidkLU1j0pfDQeWbiPZRE0 wyFgjaGQ==; Received: from authenticated user by zero.zsh.org with local id 1kL2ti-000CvF-Nj; Wed, 23 Sep 2020 11:25:18 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f51.google.com ([209.85.218.51]:47075) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kL2tM-000CXa-Ax; Wed, 23 Sep 2020 11:24:57 +0000 Received: by mail-ej1-f51.google.com with SMTP id z23so27160099ejr.13 for ; Wed, 23 Sep 2020 04:24:56 -0700 (PDT) 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=OAyRKDuFqfOq5guftnQWcMQ0ZBIEDD9tJ8CGephepm0=; b=jeodb+17QFsV5cdAlhskn5yG3QXgiE8cx5krlygFdlbuYn+g76Zbk9kJDcEpYRkzat dcLLlzhf2h4HPNdSNCfu/Snuesxj76AyvH0ercu1a9eH5BI1293NFWm14rSF4ZxeUfd7 BYVAy7zsNdFJ27at/uvUrQDeb/05vrSijls2Yrx5bgqHvoAha3iUppQ+qcpeIYHVoupd cbuqeSM03ovEM0ByVfvBWtZwjvWfOrYaSKuqc/XdpXJs4cdX9NLFoB25XI47lbK3/wsI 2belmW4kFCw85Mz+nibj7kltSDVkSd97YrBVv1nIsLJQkev8rLeMt3FrKs/9fhuP/2Mp Qc9g== 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=OAyRKDuFqfOq5guftnQWcMQ0ZBIEDD9tJ8CGephepm0=; b=N0ZfBO2NO+Vr1sY9MdNpZcmZpHLR5grvdgFHOhu9p75rQqi1p5VrZXeQrjhYQoArrY MqUHVP+G59lX4yuemGfHG0ZQt/Oz9kkhr1+APAnPzsWoUwiIXlHNXkAIO6E4vEtHLIju 17KZPyK0lepIWOgEr+9T+XFPBY1fkyEDkvC3IyAUNOel0+12qQmJTy0SacOOTzchgCW6 ud7/NfWWV8GCOFXtZhNMXoiSSj2GyuigwZYkJ5xVed+CYxu9yerp0fNxMK2wo7fmTNr/ gJh5Zk1plWghAD2yROakltgsUGzRmDYFPoBcD9VRVfPP928aMVf3v3/5QE4XW1DAqekb IoPA== X-Gm-Message-State: AOAM532vl0t+3VyzE9GL1oSOQIW4csPhf5uhao9aca6J91KIrnYgAf1I XI3dSGLGnAQEnJtWSKvjqNqadVp/M4yhZvfSDDO8ECvgHjK83Q== X-Google-Smtp-Source: ABdhPJz9X7AZaw0+XQ4af2L9qCFtOE7m/8fHjhoWkBHufJUPhkfHbHmO4fZUdefC/U4HAeWkKMrlRNOiofBgX4CEIOo= X-Received: by 2002:a17:906:a415:: with SMTP id l21mr9283210ejz.431.1600860295887; Wed, 23 Sep 2020 04:24:55 -0700 (PDT) MIME-Version: 1.0 References: <2017958989.2143187.1600860090233@mail2.virginmedia.com> In-Reply-To: <2017958989.2143187.1600860090233@mail2.virginmedia.com> From: =?UTF-8?B?UGV0ZXIgU2zDrcW+aWs=?= Date: Wed, 23 Sep 2020 13:24:38 +0200 Message-ID: Subject: Re: How to avoid infinite recursion in ZLE widgets To: Peter Stephenson Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="00000000000045b4d205aff955f9" X-Seq: 26075 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: Archived-At: --00000000000045b4d205aff955f9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable That's great! Thank you for the idea. Peter =D1=81=D1=80=D0=B5, 23. =D1=81=D0=B5=D0=BF 2020. =D1=83 13:21 Peter Stephen= son =D1=98=D0=B5 =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BE/=D0=BB=D0=B0: > > On 23 September 2020 at 09:34 Peter Sl=C3=AD=C5=BEik > wrote: > > I'd like to replicate the functionality found in some text editors - > namely > > that if you press a single or double quote, the editor inserts two of > them > > and places the cursor inside the pair. > > > > With some necessary checks for word boundaries, etc. left out, the > solution > > looks rather trivial: > > > > function insert-single-quotes() { > > zle self-insert "''" # that's "_'_'_" > > zle backward-char > > } > > The right way to insert something into the buffer at this point is using > the special variables. You can add a quote before and a quote after > the cursor using: > > insert-single-quotes() { > LBUFFER+=3D"'" > RBUFFER=3D"'$RBUFFER" > } > > pws > > --00000000000045b4d205aff955f9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
That's great!

Thank you = for the idea.

Peter

=D1=81=D1=80=D0=B5, 23. =D1= =81=D0=B5=D0=BF 2020. =D1=83 13:21 Peter Stephenson <p.w.stephenson@ntlworld.com> =D1=98=D0= =B5 =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BE/=D0=BB=D0=B0:
> On 23 September 2020 at 0= 9:34 Peter Sl=C3=AD=C5=BEik <peter.slizik@gmail.com> wrote:
> I'd like to replicate the functionality found in some text editors= - namely
> that if you press a single or double quote, the editor inserts two of = them
> and places the cursor inside the pair.
>
> With some necessary checks for word boundaries, etc. left out, the sol= ution
> looks rather trivial:
>
> function insert-single-quotes() {
>=C2=A0 =C2=A0 =C2=A0zle self-insert "''"=C2=A0 =C2=A0= # that's "_'_'_"
>=C2=A0 =C2=A0 =C2=A0zle backward-char
> }

The right way to insert something into the buffer at this point is using the special variables.=C2=A0 You can add a quote before and a quote after the cursor using:

insert-single-quotes() {
=C2=A0 =C2=A0 LBUFFER+=3D"'"
=C2=A0 =C2=A0 RBUFFER=3D"'$RBUFFER"
}

pws

--00000000000045b4d205aff955f9--