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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15746 invoked from network); 11 Nov 2021 01:42:17 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Nov 2021 01:42:17 -0000 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:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:Reply-To:Cc: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=4NBOz3UYrjEZJ45MK+MeTbWuYgiCQCA+coRBMdV1RYw=; b=Wmyp2s854ReXhNMfZ4w/e5ZDJy utbqHozmRASpNAijkJ83pjkLC3onKNuTWesvjeKehxWkrOUm+LztwW8yULY9in0AodJ+EBBuJZdJk wSvnb2eJHuPo+DVxqCrC4JN0ZcimW7naOZvaNebNgo1nhkxGMnK/ocJPKjPYfsuyp0H4mbpHUkFs9 KewQ6RtsGaiPwdfMh2CjWQ62Pi/iyNVp7jZ+/z7MDMJB5Uly4KNF+H1X1OUSHnAll7TcgZt5WcF+C BJTPpdac3ruL7U29ouKll3PinPm6q2vDlcG5UM5r41JPN3+G5vgdHr/8raCA+kC3ub4siXN3KKCsL GrhWrPIg==; Received: from authenticated user by zero.zsh.org with local id 1mkz6V-0000kp-9Z; Thu, 11 Nov 2021 01:42:15 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mkz6F-0000TB-L2; Thu, 11 Nov 2021 01:41:59 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mkz6E-000KGn-HS; Thu, 11 Nov 2021 02:41:58 +0100 In-reply-to: From: Oliver Kiddle References: To: Marlon Richert , Zsh hackers list Subject: Re: [BUG] Any type of file in command position gets misleadingly completed as 'executable file' MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <77919.1636594918.1@hydra> Date: Thu, 11 Nov 2021 02:41:58 +0100 Message-ID: <77920-1636594918.537752@n8BC.rFQv.eL6F> X-Seq: 49562 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: Marlon Richert wrote: > % foo^D > executable file > foo/ > % touch bar > % bar^D > executable file > bar I was about to say I cannot reproduce this and you must have something in a system rc file. However, I can reproduce it by putting . in $PATH. Is that perhaps the case? If so, I wouldn't think that's a particularly clever idea. Bart Schaefer wrote: > On Wed, Nov 10, 2021 at 2:01 PM Marlon Richert wrote: > > > > The problem is in _files and it is two-fold: > > * _files always adds '*:all-files', which ignores the pattern passed > > with the -g flag. > > There's a comment: > # People prefer to have directories shown on first try as default. > # Even if the calling function didn't use -/. > > In fact the actual assumption is that most people prefer to have > SOMETHING completed rather than nothing, unless they've specifically > requested otherwise. I'm fairly sure that's where the consensus was at the time. If you press tab you expect something. Globs specified in completions may not always be perfect. With some other setup like a plugin that does continuous completion after each key then I can see it being less desirable. > You can change this behavior by > > zstyle ":completion:*" file-patterns ... Where the all-files fallback is less ideal is where other things are completed alongside files, e.g for: _alternative 'files:file:_files -g "*.png(-.)"' 'others:other:(one two three)' You can avoid that by using _complete twice. I've never used the feature to call _complete twice because it used to be too slow but I should perhaps reconsider: zstyle ':completion:*::::' completer ... _complete _complete:-all ... zstyle ':completion:*' file-patterns '%p:globbed-files *(-/):directories' zstyle ':completion:*:complete-all:*' file-patterns '*:all-files' > > * Even though _files passes its file pattern tags to _next_label, if > > _files was passed a tag and/or description, it _always_ prefers these > > over the ones returned by _next_label's call to _description. It was never intended that file-patterns would divide matches into separate groups by default. It doesn't "always" prefer them. Only when the [[ -n "$end" ]] condition is set. That corresponds to the value in file-patterns including a description, e.g. *(-/):directories:directory Without this, it'd be using empty descriptions. However, it is surely a bug that $end is not reinitialised with each iteration of the for loop. That makes it difficult to use the description we were passed for the globbed-files but to put the globbed-files first and directories second. It also looks like a bug that the recursive-files style is only implemented where $end is set. I'll put together a patch for those two points tomorrow. And add an example to the documentation. > > (As an aside, the docs speak of an > > 'other-files' tag used when zstyle list-directories-first is set, but > > this is never actually offered. Let's remove that, too.) > > It appears "other-files" was (inadvertently?) removed by workers/36165 > (Oliver, back in 2015). That was intentional. Leaving it in the documentation wasn't. Oliver diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 89b918d60..a8beece2d 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -979,11 +979,6 @@ kindex(other-accounts, completion tag) item(tt(other-accounts))( used to look up the tt(users-hosts) style ) -kindex(other-files, completion tag) -item(tt(other-files))( -for the names of any non-directory files. This is used instead -of tt(all-files) when the tt(list-dirs-first) style is in effect. -) kindex(packages, completion tag) item(tt(packages))( for packages (e.g. tt(rpm) or installed tt(Debian) packages) @@ -1978,9 +1973,7 @@ kindex(list-dirs-first, completion style) item(tt(list-dirs-first))( This is used by file completion. If set, directories to be completed are listed separately from and before completion for other files, -regardless of tag ordering. In addition, the tag tt(other-files) -is used in place of tt(all-files) for the remaining files, to indicate -that no directories are presented with that tag. +regardless of tag ordering. ) kindex(list-grouped, completion style) item(tt(list-grouped))(