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=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 21228 invoked from network); 25 Jan 2021 15:07:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Jan 2021 15:07:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1611587259; b=cwGPleYoO5Op3VCbvT8iJO8lRh0m3KNypIs2rv+f0tAcuv5kNZCL7i+mbvigW5Q09LRAAV+3Io AEzuEyHjwyyQKmyFGPhtGG1lcY0dDDwMkA1lAU7nGhE2H0/13QtS0NwARk8n7U9rz0ksN5EyZm Ti10xpGOOwf03emVF4JvGkjgOs1k8373gT8R8NWjTOToUjQebNpRpv2GJ9L0IpDkYnNuNymegC IfFh7mYaVpEbdD6JWPt0aza57ZUKeakm2Nez8Yqe7cpRgcBzF77cNUJAavrgdwCqRU7n0pXlrj CQE3LHWIzzWi7VxcjCoOMT6IqZa0doCiDvN1hcuYMV4GaQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1611587259; bh=J+NqkBbEKDbdA1iL3nOxyVX9/flfg7DR2fsGNLHzf+o=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=0eYH1zPh162Y056II2LTVhn79Ai0RNCySPCA7twnvPh8qHKT3TFYZbphourjQsNo2L3Tshp2TZ +lJ2dRG9SvUpCfbyBvuvRy8Lmz9RYQ2aBB37yAcVS6GYMjMJ3heli9PHfGkQliXR4y6EAGDg/6 HMWzHRrlPhaiUAGUfJRRgsbnHGJFt4JKVP2baKB+BhRmxLpy6fA0mM+Er8Q32f5KvcgIBuaN90 FSDiTx6xbb/ighqpNGk4HMgWXnORfkKoXQebG6O4tCOZazp75OIsz193JFx3I8i3mt90wSoPuq QtUwDi0I5mM75OC4n4BeboUuNz+NtUvYxO6r69YvpQZNAw==; 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:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=sUmemPjoD2AS225fZnzP5OvqBb31h7K2BS4thvalQbo=; b=jnRyNyI9gFV+ginRaQzxkHRRHH UB7gtGlUVuzMQtB8Q2ZrZLZ8p1YwcX4OWP2XAkKuHz6lPjT8Qq3kx2njJ5drx5oCRVRvNRS/3Ytjy 3NNjy4fFwQDHr+X7YB9ereTcCTdRzoTR9XqnoWtFYPqf9Bb8uTky/dMYWhI/ltgjPYYjpYCJzm2OZ 8zqbn9F7CkaoqJfhDk0CCIkig+epKiNtJd3arPzT6fbHaYcf+nsv95Gacie+/YpwlS6F7iGRIX6cf nUprKcHy38vmwTiLariOgyVPE9Ln37mMtkaT/mEfy25ud0W1E36Amopr/fO+RsgV9gX0Xzdd/KKIQ myPty6NQ==; Received: from authenticated user by zero.zsh.org with local id 1l43St-000HWF-0k; Mon, 25 Jan 2021 15:07:39 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:48422) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1l43SY-000HMZ-Tb; Mon, 25 Jan 2021 15:07:20 +0000 Received: from [212.54.57.82] (helo=smtp3.tb.ukmail.iss.as9143.net) by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1l43SY-0000zl-Gi for zsh-workers@zsh.org; Mon, 25 Jan 2021 16:07:18 +0100 Received: from oxbe20.tb.ukmail.iss.as9143.net ([172.25.160.151]) by smtp3.tb.ukmail.iss.as9143.net with ESMTP id 43SYlCKoMugL843SYlAYrO; Mon, 25 Jan 2021 16:07:18 +0100 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-workers@zsh.org X-SourceIP: 172.25.160.151 X-CNFS-Analysis: v=2.4 cv=K9PnowaI c=1 sm=1 tr=0 ts=600edea6 a=Ip+kZtMD4PYul4iMASbA3A==:117 a=DeGUKtW0en8A:10 a=IkcTkHD0fZMA:10 a=zAZwVUNnDPoA:10 a=pGLkceISAAAA:8 a=Tx4oLkxwjCiWsmcmz0AA:9 a=QEXdDO2ut3YA:10 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1611587238; bh=J+NqkBbEKDbdA1iL3nOxyVX9/flfg7DR2fsGNLHzf+o=; h=Date:From:To:In-Reply-To:References:Subject; b=0Uf26rhoJ5Oweut4ifIwAiAlBs4aTQjNVEckPoip4Rhqdayf7kDBhkyiKNWAavDrq eAP1vwMm6wTms43yJvln0QpaL3/LJGispnY+YevKBRMXqgmIsrTc3BnvEdiBDN2LXM L2vXRVJewKWxlhas8KyI1JJUAg1kILSObwpuda7eu3/Tt4xHvFjFfxJ2y9QPIDxaTk LoZ+L20TICvbYNLvGW4qkzBDJEY6C+49OXSNGbBEOzSY2IDTtV6VOhOOVp7YQFS8ND ptBDr1tnhcbBRjhG38E3/vrr5CofZGoKC5hDKP5VTD0cwMOKn4YiekCNmfFp7+llWq b2hSZqi852jxg== Date: Mon, 25 Jan 2021 15:07:18 +0000 (GMT) From: Peter Stephenson To: Marlon Richert , Zsh hackers list Message-ID: <1857440792.3267285.1611587238431@mail2.virginmedia.com> In-Reply-To: References: Subject: Re: Bug report: Completion for dynamically named dirs fails when $SUFFIX is not empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev72 X-Originating-IP: 165.225.81.25 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfH71IAEKURmOj2TTjDl41URpMh/Cxgr9ve8o/fWokpnSzqKqi7MJBMcDPSkCu/5KnTbSD1htLzi4mz7PRTHDCji2CoopUIX2C6upsou9paEPcjlJ95c9 B3QGN5BentYt9/jjoh3wX31mRAXfv41z5AgAwhdXNsxcHWOXbtqs0OvymRYp7se6FCAX+fVlZQrvnrYb7GOD/7kEFZmwmtRrQkCy8dR3Z+n2ehTQKWKn0wdM lTeIe1BMoXIQkE9Ehsomha01sAsE/wndni1IqNiiCfI= X-Seq: 47873 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: > On 21 January 2021 at 14:37 Marlon Richert wrote: > % cd $(mktemp -d) > % ZDOTDIR=$PWD HOME=$PWD zsh -f > % autoload -Uz compinit > % compinit > % zsh_directory_name() { [[ $1 == c ]] && compadd -S ']' foo } > > Given the above setup, when > > 1. $LBUFFER is `cd ~[` or `cd ~[fo`, > 2. $RBUFFER is empty, and > 3. I press ^I, > 4. then $LBUFFER becomes `cd ~[foo]`. > > 1. $LBUFFER is `cd ~[`, > 2. $RBUFFER is `fo` or `]`, and > 3. I press ^I, > 4. then completion beeps and the buffer remains unchanged. > > `functions -t _complete` shows that the problem is caused by > $compstate[context] becoming `tilde` instead of `subscript` as soon as > $SUFFIX is non-empty, which causes _complete() to not call _subscript(), > which is the only point of entry to _dynamic_directory_name(). The following is somewhere near, but this is quite complex and somewhat at odds with completion in other contexts --- it's not clear to me whether or not I should need that special diversion in _main_complete but currently I do. (Your compadd -S ']' is going to add too many ']'s in this case, I think, but that's a separate problem.) pws diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index 6b2cf2bcf..2bcbd2118 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -94,8 +94,18 @@ if [[ -z "$compstate[quote]" ]]; then if [[ -o equals ]] && compset -P 1 '='; then compstate[context]=equal elif [[ "$PREFIX" != */* && "$PREFIX[1]" = '~' ]]; then - compset -p 1 - compstate[context]=tilde + if [[ "$PREFIX" = '~['[^\]]## ]]; then + # Inside ~[...] should be treated as a subscript. + compset -p 2 + # To be consistent, we ignore all but the contents of the square + # brackets. + compset -S '\]*' + compstate[context]=subscript + [[ -n $_comps[-subscript-] ]] && $_comps[-subscript-] && return + else + compset -p 1 + compstate[context]=tilde + fi fi fi diff --git a/Completion/Zsh/Context/_subscript b/Completion/Zsh/Context/_subscript index 0c9a89ad5..0d9632864 100644 --- a/Completion/Zsh/Context/_subscript +++ b/Completion/Zsh/Context/_subscript @@ -1,6 +1,8 @@ #compdef -subscript- -local expl ind osuf=']' flags sep +local expl ind osuf flags sep + +[[ $ISUFFIX = *\]* ]] || osuf=\] if [[ "$1" = -q ]]; then compquote osuf diff --git a/Functions/Chpwd/zsh_directory_name_cdr b/Functions/Chpwd/zsh_directory_name_cdr index cb72e4600..b653e7c38 100644 --- a/Functions/Chpwd/zsh_directory_name_cdr +++ b/Functions/Chpwd/zsh_directory_name_cdr @@ -16,8 +16,10 @@ elif [[ $1 = c ]]; then typeset -a keys values values=(${${(f)"$(cdr -l)"}/ ##/:}) keys=(${values%%:*}) + local addsuffix + [[ $ISUFFIX = *\]* ]] || addsuffix='-S]' _describe -t dir-index 'recent directory index' \ - values -V unsorted -S']' + values -V unsorted $addsuffix return fi fi diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 8c0534708..1622d8a6b 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1067,6 +1067,7 @@ redrawhook(void) int old_incompfunc = incompfunc; char *args[2]; Thingy lbindk_save = lbindk, bindk_save = bindk; + struct modifier zmod_save = zmod; refthingy(lbindk_save); refthingy(bindk_save); @@ -1094,6 +1095,7 @@ redrawhook(void) * restore lastcmd manually so that we don't mess up the global state */ lastcmd = lastcmd_prev; + zmod = zmod_save; } }