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 19718 invoked from network); 29 Apr 2022 14:55:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Apr 2022 14:55:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1651244101; b=oPfMZfoflxME8BGt0cWNaSUMg6d3zPfrRZVUME2PyW3XBDQMtz1IetT5WNEfVuEAHgDpnmd/GY Mk7Dbmrt8aW1XtTga/ArvqS7piPgzbrEkWsAHkEpHoUiG1QvUFHL/WwkI4CcInSIKQ4EtQPsoy m3dOJ0/luQobxhG6tFN+1nUYgSs+oymi/j2cMjuGEfzx15MYWty31PfQPLa91gICxsWMvBwViG 3x0xIPLPIdM2RLm2zsScGosuacswjRiPOgKpQ3if3kTHtxN5jPyLaB/QiO4uDnsKnHYesyfLI+ eaJSwtrIa7woOKpbrE7MtHm6ZDqDwhjWPlv3gBe2PCm6Rg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f54.google.com) smtp.remote-ip=209.85.166.54; dkim=pass header.d=gmail.com header.s=20210112 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=1651244101; bh=n3+MKuOwXdwOx8wdXZvUqlEAiPP4bU4BDYk5U3cWyM8=; 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=W8pT42oHAyxxtldCuZoybH9zQm2keUyWAZ1jLi9UpIPabBzROFOpxqMrvSL/N35uj74w4+fS/X uiff3qkInnx7B+5BAZUCu2wjWTzs4Wd7C9ey1fjnoXiuv04fOsbLXmHFIz2DFWtHhFlJ/2Okbn 2Q+y+HpZVumRpAxpW8jBnYDOv9yGUkX2J0nRESfRtF69iqWoeCkKdMSEH26zlLrDVxndHYkrw3 tjHyNLknlAe0h2J6CdxTh1R4ZOPQxLyGiy0pzvmsD+CxWE846EBpOZOO3HvpcFy2FZqIzzrej9 zYh/+qjy/aeCMYaYOLK7LqIkpJDTerOyrFNv6vlWyCEJww==; 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-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=EECpSP9b3r8y8QxMh5dY01i9jaAQS1yRW+My/y2QdEM=; b=IOTNQMbm2o7E93KcN7vVTMnSpu DmDkzK7Qsp5WRpi5cHsdn3uU82oY6upNDyXGSivdSyU4n2j7AeDAhj8pyH0dGL6v3WjuHK49Tr3O2 PcPjlluHtlkkDHLbp/bu6BCBZTMHvnKLUKBH1gkYC+Czxy8xcZ7Y+iWaTp7raRITpqFCuI2svRlU/ qBRiuaX39BRTsaiugiuUHOXXNeJ14hC0AD2NCpOWcx/8gNOMBN7Ef0J6mWGWFvv1b827eQsTrrGoL P5dqrZqr1PAFxydpYQlpxg/FiiWQkE2/WFhuna9TtiK+NuI33EPNMYZfBlMrIIzCPdTbnZOYp0w7/ /ctNdOhg==; Received: from authenticated user by zero.zsh.org with local id 1nkS1N-0007gh-0Q; Fri, 29 Apr 2022 14:55:01 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f54.google.com) smtp.remote-ip=209.85.166.54; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f54.google.com ([209.85.166.54]:44557) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nkS0e-0006xo-7y; Fri, 29 Apr 2022 14:54:16 +0000 Received: by mail-io1-f54.google.com with SMTP id e194so9974106iof.11 for ; Fri, 29 Apr 2022 07:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EECpSP9b3r8y8QxMh5dY01i9jaAQS1yRW+My/y2QdEM=; b=RnzsyyjWVuQTYL08uDTsvxdtDkASF5dPb2JgacOda1rCXjZQWBURW0BK7G9/mf5ZQk QxRF7UZPneaNGiz8SLiz6wGM+MyKi1yQbRxaGF0JOv5fqxtpJejfSbHlrSHAAs5opYUg 2kOCSqmr5nXbv25zuWrkYQPCxjGuKWoGh3wuv1yVkqErC5eKfiHSnApyYH9e2AvkPWRQ 7s79EPDQ9bVYnSuykNPjRCNGIP9BFol5TLCXM2rVtOdwgumUlM+wTvoeXG1dM3onIbmk 0igAlQCmY7opw1VidDyAK1/dnpkxjww+jaDZQnUJkYUDkZ2U1VS1XsO9mFVRLawK38Gw yc5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EECpSP9b3r8y8QxMh5dY01i9jaAQS1yRW+My/y2QdEM=; b=Pqg0Zx+DpKPIchl0ZA+rFfLrgljDvaNPr9KcGsI33YebrneGmaNLVEnj6Djb5d8NKm Qn5IjWEdRyEthaTATF+rvn0VChgGtl6DM6TgZ5Q/o9HRNnRKO947jGlijSvwc0FqIaK0 RVla0X7xPYMC3X9yV8D2rTsC8xErSQtls5Ptov0xbvnFG7Fo9psrqAVjgiQ8jIIZEmpr luch+D/BtbmkXGVPa9+wqdSdh4ccLOhCwp10l4yBdZdHEEJUq36HXlhDbzvMAGc2HayL +fMiUvAVTy8i8Vzv8UAfCJ3C5WlOb9hmbx+zSCurvficNQA0buBOHqxOt50lNUd6rWvi YqiA== X-Gm-Message-State: AOAM5318FKlZzeyvNF/KPleSDXn7rymqqRYIETBRxBmD/vpI9aBZcX8T 4xc8VJ/UDdmu1LkiS7SasKEC22ZFpFV+oVN+/mLwBeNJYvDJZA== X-Google-Smtp-Source: ABdhPJy2Zh8MJhK+teIDtj839l0VvmyPnLEaqoRgMuUtvqaeGw+8BeWISvnGhk3pGb2VW2CiBpiyzSXTReba6c5rA58= X-Received: by 2002:a05:6638:1356:b0:323:aa22:8cc9 with SMTP id u22-20020a056638135600b00323aa228cc9mr17025271jad.72.1651244055006; Fri, 29 Apr 2022 07:54:15 -0700 (PDT) MIME-Version: 1.0 References: <747863791.139295.1651238910118@mail2.virginmedia.com> <1558792630.141539.1651242336328@mail2.virginmedia.com> In-Reply-To: <1558792630.141539.1651242336328@mail2.virginmedia.com> From: Pier Paolo Grassi Date: Fri, 29 Apr 2022 16:53:38 +0200 Message-ID: Subject: Re: prepopulate BUFFER To: Peter Stephenson Cc: Zsh-Users List Content-Type: multipart/alternative; boundary="00000000000056137f05ddcc37e8" X-Seq: 27710 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: --00000000000056137f05ddcc37e8 Content-Type: text/plain; charset="UTF-8" thanks, I ended doing it like this: zle-line-init(){ [[ -n $__precmd_buffer ]] && { BUFFER=$__precmd_buffer CURSOR=$__precmd_cursor } } and storing the current line and cursor position with: set_precmd_buffer() { __precmd_buffer=$BUFFER __precmd_cursor=$CURSOR } zle -N set_precmd_buffer set_precmd_buffer bindkey "^X^[e" set_precmd_buffer best regards! Pier Paolo Grassi Il giorno ven 29 apr 2022 alle ore 16:25 Peter Stephenson < p.w.stephenson@ntlworld.com> ha scritto: > > On 29 April 2022 at 15:18 Pier Paolo Grassi > wrote: > > actually I have another question, is there a similar way of setting the > > initial cursor position like I would do setting the CURSOR var in zle > > widgets? > > As long as something else hasn't already taken over zle-line-init, you > can do something like > > zle-line-init() { > if (( set_cursor )); then > (( CURSOR = set_cursor )) > set_cursor=0 > fi > } > zle -N zle-line-init > > then you can use it like > > print -z "foo bar"; typeset -gi set_cursor=4 > > pws > --00000000000056137f05ddcc37e8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
thanks, I ended doing it like this:

zle= -line-init(){
=C2=A0 =C2=A0 [[ -n $__precmd_buffer ]] && {
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 BUFFER=3D$__precmd_buffer
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 CURSOR=3D$__precmd_cursor
=C2=A0 =C2=A0 }
}

and storing the current line and cursor position with:

set_precmd_buffer() {
=C2=A0 =C2=A0 __precmd_buff= er=3D$BUFFER
=C2=A0 =C2=A0 __precmd_cursor=3D$CURSOR
}
zle -N set_= precmd_buffer set_precmd_buffer
bindkey "^X^[e" set_precmd_buf= fer

best regards!

Pi= er Paolo Grassi


=
Il giorno = ven 29 apr 2022 alle ore 16:25 Peter Stephenson <p.w.stephenson@ntlworld.com> ha scritto:
=
> On 29 April 20= 22 at 15:18 Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
> actually I have another question, is there a similar way of setting th= e
> initial cursor position like I would do setting the CURSOR var in zle<= br> > widgets?

As long as something else hasn't already taken over zle-line-init, you<= br> can do something like

zle-line-init() {=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (( set_cursor )); then
=C2=A0 =C2=A0 (( CURSOR =3D set_cursor ))
=C2=A0 =C2=A0 set_cursor=3D0
=C2=A0 fi
}
zle -N zle-line-init

then you can use it like

print -z "foo bar"; typeset -gi set_cursor=3D4

pws
--00000000000056137f05ddcc37e8--