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=-4.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21086 invoked from network); 30 Dec 2020 00:47:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 30 Dec 2020 00:47:55 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1609289275; b=fM0uHYBWTIN3Dn1h8ROmdGcArp6y8qJh7k+sRSrR9BqFTN5TwIm+qRR8KGwSXagRSD/XXMR0e5 kiuLodB03uwNaiZ0QXfwsJhPtAGp1ocYrLMymHmXdGREJDef+zDXCXO6XXzi4wg7MlJ4OhOqtj s1xuFhoqnc0A6fe1YRvvzmgXvHj94LBYpGX+scUr3RFAiLf0nnH2An+UHtrIVCkJjjnsCiRzqv SA+Fldw6BvXmLz2qxXewPe5ao9BlswHg7ZlFZiFQgswjEboKWrfwZb5tGRD8cMjxjfiiOA/wUH kD8+4MXmccvolpsLHH4FGUozSMUyIG92qYVw9P4J5i6zsw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta01.eastlink.ca) smtp.remote-ip=24.224.136.30; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1609289275; bh=5ccC506xl+z1vWC+o6T67bn2qoJ9BOlpCUM8qq37GR0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:To:Subject:DKIM-Signature; b=yjt38n+keWiMvIVa3cS+vhbcX89yfVoFjinmw5El67kSquVEBlUBrxC6AF+VW4jUfNgJXa1vEb sjh5S3ekwJTZn41JmDV91Jyw4u1+4mQHQS1CLS1bWHeWv8byil05VJBAuop5U72vM0+r31qGR3 uWUZWoOHoiGHvcQn7jsJy+4Vrv5sbep+ugC/lkcSEZlNXQpWJu2DuFYitvSRB62HFks0FwSSVp Ne2E0TzT9Xvhw/jqDAG41Srl0Wh80Ei/G07ytLO94+LEFd99a13yHHH/wvHHpCVF5lDjrX7c4W bkxBRsRVrLXxDlfHF4QQr6et+gjn4GjfYRs+cKO3vqzVEQ==; 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-transfer-encoding: Content-type:In-reply-to:MIME-version:Date:Message-id:From:References:To: Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=BKx9tW72QmXOmyQGUaxSEH1bzQmHDFzzpBgtY8a6ScY=; b=H9zi4+oBHPaNONsv8rSRUCn4Xr VbUqFv3Qx49zh3xZ6ylXbNt9no5pKLsCCN1jEFcdIqvMp89sF7XBKcaVAg/Bxhr7jkbLnYn7ZwvAP tFt3JAyT9vgp5L3+Yj5SxOCtLsEZxdloBTk6Vczq99PWNwz9T73EP+eO5fBTZ4BmzUaQ1GMP/pSzd 4Cl3QIK5PCYIO1g+kCR5tTvRbmZ7d12lOngno4yVODoeNvcQfihiHrYnRqnE2Cglmq7L3k7vcx88I HrGOQzw0meCOL70XD9Y48+r8U7FIS3Ibb6lf1mmHFrO4GFN7DWCulmS604U2I4r5A+0tDG4HWLm1H gQvCacRg==; Received: from authenticated user by zero.zsh.org with local id 1kuPPj-000FJw-VI; Wed, 30 Dec 2020 00:32:32 +0000 Authentication-Results: zsh.org; iprev=pass (mta01.eastlink.ca) smtp.remote-ip=24.224.136.30; dmarc=none header.from=eastlink.ca; arc=none Received: from mta01.eastlink.ca ([24.224.136.30]:37625) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1kuPP9-000EwV-Nb; Wed, 30 Dec 2020 00:31:56 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta01.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0QM400FS5MSZ59B0@mta01.eastlink.ca> for zsh-users@zsh.org; Tue, 29 Dec 2020 20:31:53 -0400 (AST) Received: from [192.168.0.3] ([24.207.90.194]) by Eastlink with ESMTP id uPP7kTpdQ6iEuuPP7kYKOG; Tue, 29 Dec 2020 20:31:53 -0400 X-Authority-Analysis: v=2.4 cv=HcDR8gI8 c=1 sm=1 tr=0 ts=5febca79 a=zv49KfEsxEDzuN5AGO7r0Q==:117 a=zv49KfEsxEDzuN5AGO7r0Q==:17 a=IkcTkHD0fZMA:10 a=avzQcn0Mg8sdVN2Fe0MA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddvvddgvdefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepkedvueeuffefhfdvueeiteffvddtvdejgeeujeekieduheeiteeiheegtedvhfefnecukfhppedvgedrvddtjedrledtrdduleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdeltddrudelgedphhgvlhhopegludelvddrudeikedrtddrfegnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrgh X-Vade-Score: 0 X-Vade-State: 0 X-EL-IP-NOAUTH: 24.207.90.194 Subject: Re: completion within a function To: zsh-users@zsh.org References: <819ec6fe-5af2-2e97-c5bb-f434b1de86d7@eastlink.ca> From: Ray Andrews Message-id: <520ce98a-4394-726d-3d12-8ef414e881c9@eastlink.ca> Date: Tue, 29 Dec 2020 16:31:52 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 8bit Content-language: en-US X-Seq: 26269 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: On 2020-12-29 1:48 p.m., Bart Schaefer wrote: > >> func () >> { >> code >> cd $1 [TAB] >> code >> code >> } >> >> ... so that I can automatically execute a completion within a function. > Where does the TAB come from? That's what I'm asking.  How could I simulate the effect of completing on $1 within the function automatically?  Or perhaps:     new_var=$( complete_it $1 ) where 'complete _it' is a function that does just what TAB would do on the command line. > > I think what you're actually asking is how to apply the contextual > completion "rules" defined for a command ("cd" in this case) to a > parameter expansion. There really is not any way to do that > "automatically" because completion is tightly bound to having the ZLE > line editor active. It could be done the way that the test suite > emulates completion, but that's exceptionally convoluted, especially > error handling. Geez, I'd have thought that it would just be a question of digging up the right completer.  But as you say. > 'vared' is a variable editor no? Does it do more than I think? > If you were to write > > func() > { > code > vared 1 > cd $1 > code > code > } > > Then at the point vared is invoked, func would pause, wait for the > user to press TAB or whatever, and then after accept-line is executed, > continue with whatever result. Cool.  That's bound to be useful even if not right now.  I had no idea it could be used within a function like that. NEXT MSG: local dirs=( $1*(-/N) ) Marvelous. If I was 20 I'd devote the next 10 years to reading the manual and have the health to survive it. The thing is that zsh code is so terse that you can't go searching for answers unless you already know where to look. Anyway, that line of yours does it all exactly as I want. Thanks Bart.