From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12316 invoked by alias); 13 Jun 2018 02:55:56 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23474 Received: (qmail 11274 invoked by uid 1010); 13 Jun 2018 02:55:56 -0000 X-Qmail-Scanner-Diagnostics: from mail-io0-f170.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.223.170):SA:0(-1.9/5.0):. Processed in 0.477055 secs); 13 Jun 2018 02:55:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_PASS,T_DKIMWL_WL_MED,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=UNbwZC4m7YnGFNI6kuY9+XiHM88hEN/KsSUgaKr9RHI=; b=wdgREQnsENaKANVH3/PVZZyGKgs6t3Za9FAFeL6WpipEFF5gtA9LBAQStitcTegHMy uEK7hVOR8rfQGwD0rWlMKGlwfjVS3NPAdVEsGUNH6eWPKWzdwh9gABig7Z1xxYmtTHN9 4dUFr1EsUjt6uKXT1GoZKsw8Q1zMNsslrLeeAqapXJ6L190cv8HEx+Zd/OUkbZoW4oIA Cmuzn0WKrE/O5RlFGKfhHlhZbvuqlmrRIAuaS1tpsHMhygzYA/72iPfmC2phHZGqzusz 3pSkVZnuxpzyGQmNsXjFqAIk/Jgf2fMTUL+N8/KoLlviWGycOuPj1qkK3ZMiIVBtpZyD gHfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=UNbwZC4m7YnGFNI6kuY9+XiHM88hEN/KsSUgaKr9RHI=; b=YPcSy/uVRP6ov9WqT9q7iaLf71M35BQ8fKBE8k/t9/81Q1QmG61Tjq6NKD7I11T0ML wkIZQmU+yYwt4a7/WLipDISQux+vN5wmo4VcrlEJnQ/P1ORqRRjcUbXWTQlRub4HehAs Nfd92bEIURPKl1KOrmJjfd2cJ5IDlgQ6LgZZo57KgPdrLykxWgvSOr559+FvGRGe4YMw J87YVwdHsms1ME6XpKQK99PPtWDGKZtSdBuLhISFW2fWfE5+15VfxD7gXvhyjHRXwBVn hCVSXf4axV9d8hTFdw9FXPACjJ9gfPF+4R4bnsexVQIBshHa3DFhlTegVDtEI/DBYWy5 rjFg== X-Gm-Message-State: APt69E3kLzweqFCbeWPNK7BQ4VXfSiJtJ6f6KAFy4/D7WIxVvgX6VRVd aNiqItQps9FRG0W8Ntq+nnaDmAjpWW4= X-Google-Smtp-Source: ADUXVKLbIq1BaRzhAeUxWJSk/HFygf88ld/GEigrjpbf5e05ITDmSw/GGXC3EDfFkplVEWHqeXQHAA== X-Received: by 2002:a6b:5808:: with SMTP id m8-v6mr2967138iob.219.1528858553885; Tue, 12 Jun 2018 19:55:53 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: populate next comand line from precmd From: dana In-Reply-To: Date: Tue, 12 Jun 2018 21:55:52 -0500 Cc: Pier Paolo Grassi Content-Transfer-Encoding: 7bit Message-Id: References: To: zsh X-Mailer: Apple Mail (2.3273) On 12 Jun 2018, at 20:44, Pier Paolo Grassi wrote: >hello, I was wondering if it is somehow possibile to populate the command >line within the precmd function. What I am trying to achieve is: from a >normal function (not a zle widget) I would like to set some variable, to be >read in the precmd function where it is used to populate the next command >line and also set the cursor position. Maybe print's -z option would help, at least partially? -z Push the arguments onto the editing buffer stack, separated by spaces. Example: % precmd_insert_args() { > # Check some variable, whatever > [[ $history[$((HISTCMD - 1))] == *bar* ]] && { > print 'Saw bar' > print -z : inserted args '' > } > return 0 > } % precmd_functions+=( precmd_insert_args ) % : foo # Condition not met % : bar Saw bar % : inserted args I say 'partially' because i'm not sure if you can affect the cursor position (besides inserting things in front of it, obv) from outside of a widget. dana