From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 5793E21754 for ; Tue, 2 Apr 2024 09:46:29 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1712043989; b=pd6GfBGzbXcG2pUnTydZJRHptiT6hSzreffy5MX0gjClJba0/zELhQBLde+pLPww0z+Ud+rFdK b1a12R884QxHMuVwAL1+ZMM0XAtmouuMc92LfpVCA2SEf9NWItFCFc0t8PbbjJCZSCQexX10AR b9fcOy5mL1A9C0hMnoAw7SFHfkDgS6k49GMVDvUsU6VYFmBFsjJyraFMRxb9Kxpg4l62ZsvTVm 62I3nctc4BQ3yu+lx8xAv1O9S3UZK3qY2ot8+FGFj427kSoMwYzmBqxC1aSSAQaZg+TzqEtAB9 IlkHSNa5bnbmBxclqFRG2sDcwYxoHkiLHGaJkEAa5uLemQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f43.google.com) smtp.remote-ip=209.85.166.43; dkim=pass header.d=gmail.com header.s=20230601 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=1712043989; bh=dwZHo3ifEsGH21WgpHtIuOOB7OuDYQi55OqBhV5z7Bs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=r4zVTW2YlaWrx9PSGlp1oz1gTJDn9Y01tB+THojCPj1NokY0t7A/hPA/euZVWjs1fq9e5E3agF X10ZwvbgGLEBIs1ZUHeMw76mwJR8KN3J0inpMGxiIc8USpW+lipiD8zawE3c9MV3+Dd3MQANGN ehheEcy5UTBfjTV54s393GTO3PEBKA+RB28EHrJXfRK48Hm7rFeTmmoW0vSwpmrqiRban6ax0O O8xCOQl8s+0jwspErQudsHGFzlfxIB2Bfv2uv1Ry8I/4nwBHtxofGALnihWn5gZMICULEjw2oT vM3/ObC2v/xCUcW3Pbg9jQSIVQ6XnxCGug4QdW5P/jE+6g==; 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:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ygT7VI28199UcAXbUM2DK1YN1zqowV18QCmriGgT54Y=; b=Mo2jnCXj6NqqrRsRenrDMkxE3I Dj6fMu0K4Ktu/DyczECM8xrTgUXVEuUqUriK3SnVxpQfyMq4qC89AzGYcXtbHwOoSlrd8lmqR45xD ZHuPLEGVGrCbwdxg9/yPDwN+EOWwKkgNuI6fMou9ncIeX4NqnPWUwNUTFOMTnitGFnpNkJQwf/VRc Cawl+A1XuQLdOaCxV4Pj+QvH1ZxdwY8g6SswgmwSkADZRZV4SMhDXisD417qM6XVq7t2R6J0YH6Q4 r3YAU+1WWp12gBVLlhJt9D8/xTNTgkU66QD7EZYEIk1wTUbbj5GZW+dmyeZZFYDSLE0c4NG+MCEVQ d2eX9yNA==; Received: by zero.zsh.org with local id 1rrYqj-000Nuj-8o; Tue, 02 Apr 2024 07:46:29 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f43.google.com) smtp.remote-ip=209.85.166.43; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f43.google.com ([209.85.166.43]:38938) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rrYqJ-000NF2-Qj; Tue, 02 Apr 2024 07:46:04 +0000 Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-7d0ab7842b4so37580739f.0 for ; Tue, 02 Apr 2024 00:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712043962; x=1712648762; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=ygT7VI28199UcAXbUM2DK1YN1zqowV18QCmriGgT54Y=; b=F5wKtJVHG6HtpUa9G2a9iV69a3jT8IRWou2ksUVc6JagC2z/H3VqawIsMWDF113jup HaeuSAUX4nQ1w3v4NZYgGRQhTy7NsGcmYPqBYSqICJf/JeMnLtAcXYyki10FUz5Klw99 37jjKKOg3v3w6p5Y9XIqkVsdVA2kIX7aJpqSJ7ms1YhTV2gHB0M89rhSHD42ZxVJgBVx Hboj2L9UfE3AqBp/MCZqLVnqRGcy6VENmrPIA3vQMrhGBAwv5wahoZ4JB6w2k+f4dqU/ 4vSFG+jImJ1O38dlOipWG5GE8o14UOjZma6LShrFMtkV6v9JU9Uz2s5/5oqbyLZj/XMH 2YLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712043962; x=1712648762; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ygT7VI28199UcAXbUM2DK1YN1zqowV18QCmriGgT54Y=; b=WFKzpsM8KB2doSf5YQJR7VFnckjIGuafBNxX3bUDscCOc8vsm62stDvH6D8DD8Mjyb Qddqjw8if+afami3KsdQuRcGn7xUuS1q8mPHTkCnLl+D6Z0ypv3WAr280R6EjtzhohMA qhYdFFCapaC4OCmdOCV6D4Zhhic1jN60oXbi+LRQeQZE8kks2V1QNM4LqQCwKDlimmsT w2N+ICNMr0NZyxXf5u2+z7CSb8o7grxqtZWnoX5jIk/f4VVA0siaV/YguxBhznhNAj0J Mn8QbvPnNr1Ww/KrSwUQHmWUEqGxsUm5k62DslyURwClk+oLUXV1gDlkq2F81RoMmiXp 9aog== X-Gm-Message-State: AOJu0YxvjDnYd4Xh07nhoLX/gulCGG8Hd/kfXahvbfLPuWDkeskA2Tcq cn66E4udrDJ0yqE5ZmyXKxnB3F3JvbzlMnnqEmH1EaebRmXzu2Dgry64b9TF6GWagAxdjnqho8i fXrsqV+4LvrV0dzAgPkI39EWJh3z4MsMnpz4= X-Google-Smtp-Source: AGHT+IH3/Jt+qbTAkdC7p6yg2QaE4dr8ioaNGSP9Kqf6ILPavglwwovpq1YzbzG9HtCKK5DOfnYcrM3+KbEcesuVNZU= X-Received: by 2002:a92:6503:0:b0:368:8d92:3262 with SMTP id z3-20020a926503000000b003688d923262mr10678142ilb.2.1712043962589; Tue, 02 Apr 2024 00:46:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marlon Richert Date: Tue, 2 Apr 2024 10:45:26 +0300 Message-ID: Subject: Re: [bug?] How to make _expand behave like the expand-word or list-expand widgets? To: Zsh Users Content-Type: multipart/alternative; boundary="0000000000003aecfb0615184cbb" X-Seq: 29760 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: --0000000000003aecfb0615184cbb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This actually seems to do what I want: _expand() { local -a expl local expansion expansion=3D"${(b)$( eval print -r -- $words[CURRENT] )}" 2> /dev/null = || return 1 _description expansions expl expansion compadd -QU "$expl[@]" -- $expansion } This code can of course cause undesirable side effects when expanding certain special parameters and command substitutions, but _expand suffers from this, too. Is there a way to locally disable special parameters and command substitutions? Are there any other drawbacks to this approach? Why isn't _expand doing something like this? On Tue, Apr 2, 2024 at 10:12=E2=80=AFAM Marlon Richert wrote: > I would expect _expand to behave by default like expand-word or > list-expand, but it doesn't. > > For example, given default shell options, if `foo=3D*`, then expand-word > and list-expand will complete `$foo` to `*` and `$~foo` to the files > matched by `*` as a glob expression. > > However, no matter what zstyle options I set, _expand will either > complete both of these to `\*` or both of these to the files globbed by > `*`. > > By default, I would expect _expand to complete expressions in the same > way as the shell substitutes them when evaluating the command line. > > Is there a combination of zstyles that makes _expand complete `$foo` to > its literal value and `$~foo` to the files globbed by its value? > > If not, then I would like to see this being added somehow and preferably > be made the default behavior. > > --0000000000003aecfb0615184cbb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This actually seems to do what I want:

<= div class=3D"gmail_default" style=3D"">=C2=A0 _expand() {
=C2=A0 =C2=A0 local -a expl
=C2=A0 =C2= =A0 local expansion
=C2=A0 =C2=A0 expansion=3D"${(b)$( eval print -= r -- $words[CURRENT] )}" 2> /dev/null || return 1
=C2=A0 =C2=A0 = _description expansions expl expansion
=C2=A0 =C2=A0 compadd -QU "$= expl[@]" -- $expansion
=C2=A0 }

This code can of course cau= se undesirable side effects when expanding certain special parameters and c= ommand substitutions, but=C2=A0_expand=C2= =A0suffers from this, too.

= Is there a way to locally disa= ble special parameters and command substitutions? Are there any other drawbacks to this approach? = Why isn't _expand doing something like this?


On= Tue, Apr 2, 2024 at 10:12=E2=80=AFAM Marlon Richert <marlon.richert@gmail.com> wrote:
=
I would expect _expand to behave by= default like expand-word or list-expand, but it doesn't.

For example, given default shell options, if = `foo=3D*`,= then expand-word and list-expand will complete `= $foo`=C2=A0to `*` and `$~foo` to the f= iles matched by `*` as a glob expression.

How= ever,=C2=A0no matter wh= at zstyle options I set,=C2=A0_expand = will either complete both of these to=C2=A0`\*` or both of these to the fil= es globbed by `*`.=C2=A0
=
By default, I would = expect _expand to complete=C2=A0expressions in the same way as the shell subst= itutes them when evaluating the command line.=C2=A0

Is there a combination of zstyles that makes _expand complete `$foo`= to its literal value and `$~foo` to the files globbed by its value?=

If not, then I would like to see this being added s= omehow and preferably be made the=C2=A0default behavior.
<= br>
--0000000000003aecfb0615184cbb--