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 4828 invoked from network); 2 Apr 2021 00:51:15 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Apr 2021 00:51:15 -0000 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:Message-ID:Date: Content-Transfer-Encoding:Content-ID:Content-Type:MIME-Version:Subject:To: References:From:In-reply-to:cc:Reply-To:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=HWpb8iI+1q9n2JsHJwzmNVebcEaCMXQ33ubCXIpNMik=; b=GQeu0tEqp4wcowyYWHPlEnRFBy QgRbhAHBWwZ0sBoa+fpJwU/21dYQTieURKztF6apxus6ShmZ8YBnhvyh0A+Y3w1bCYluvZylqGgEC t7kYarTzE9MVfVhgfpUfS77v8lLr/P3g2DUf/JyWsKrk9H+MkziX0TLAoyVhViG0IzFzhOAM1qtH+ bwRy0oyhVc3xJaigFTsOWzpmgVqOObnXCZQ6IWCz62AdkqKk5RJuxfYc7W8RCEABXoFWSsI5sIzej zZrNx27ezdC+rMQ8xrv0vyf+M6j+Zki2+GqMOJawqa5k0E1T5Te+izmVEKbEwaiaI7GZMvWkuXwpX lNDT1+1Q==; Received: from authenticated user by zero.zsh.org with local id 1lS81k-0008AF-Mr; Fri, 02 Apr 2021 00:51:08 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lS81U-00081N-7e; Fri, 02 Apr 2021 00:50:52 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.93.0.4) (envelope-from ) id 1lS81T-0004qJ-RL; Fri, 02 Apr 2021 02:50:51 +0200 cc: Zsh hackers list In-reply-to: From: Oliver Kiddle References: <20210329073913.GP18178@tarpaulin.shahaf.local2> <20210329171120.GA6044@tarpaulin.shahaf.local2> <20210329181452.GB6044@tarpaulin.shahaf.local2> To: Marlon Richert Subject: Re: Feature Patch: Use completion to view parameter values MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <16989.1617321223.1@hydra> Content-Transfer-Encoding: 8bit Date: Fri, 02 Apr 2021 02:50:51 +0200 Message-ID: <18618-1617324651.844569@tLsN.0hLE.FeTt> X-Seq: 48374 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 29 Mar, Marlon Richert wrote: > When completing parameters and > `zstyle -t ":completion:${curcontext}:parameters" extra-verbose`, > display values of non-special parameters as descriptions. Incidentally, we actually already do this for array elements (with the verbose style) but not for associative array elements. Numeric indices are rather less meaningful so that only needing the verbose style while this uses extra-verbose is probably sensible. Following is a review of the patch: > -local expl pattern fakes faked tmp i pfilt > +local MATCH MBEGIN MEND \ > + disp dopt expl fakes faked i matches pattern pfilt sep tmp It isn't important but I tend to split these up by type and use `local -a' or `local -i'. Setting the right type can avoid certain issues such as += using the declared type. > +_tags parameters > +( _tags && _requested parameters ) || > + return I'm not entirely sure this is needed. Tag loop nesting isn't especially ideal and helpers like _parameters are only called from places that already have one. But it perhaps needs a little testing. I'm aware that the old function had this in the form of _wanted. > -_wanted parameters expl parameter \ > - compadd "$@" -Q - \ Note the old function was passing "$@" which you've lost. This does matter. Passed descriptions get thrown away, similarly pressing [ to auto-remove space suffixes on arrays. "$@" is typically passed before "$expl[@]". The use of double indentation for continuation lines in the removed lines is intentional by the way, see Etc/completion-style-guide > +_description parameters expl parameter > +compadd "$expl[@]" -O matches - \ > + "${(@M)${(@k)parameters[(R)${pattern[2]}~*local*]}:#${~pfilt}*}" \ > + "$fakes[@]" \ > + "${(@)${(@M)faked:#${~pattern[2]}}%%:*}" The faked parameters are not going to have a value. You can just add a separate compadd for them right at the end (take care over return status then). It will also then need to check if any faked parameters are duplicates of real ones otherwise they'll appear twice. > + > +if zstyle -t ":completion:${curcontext}:parameters" extra-verbose; then > + zstyle -s ":completion:${curcontext}:parameters" list-separator sep || > + sep=-- > + zformat -a disp " $sep " \ > + ${matches[@]:/(#m)*/"${MATCH}:${${parameters[$MATCH]:#*special*}:+${(Pkv@q+)MATCH}}"} We should probably also honour the typeset -H flag so the pattern would need to be *(hideval|special)* By not using _describe, this has the advantage that if the values are all short, it can use columns. Unfortunately, many variables force it to be a single column and then many lines have only a single short parameter on their own. Compounding this, the parameters ! - ? @ * # $ and 0 get sorted near the top each getting a whole line. _describe does the matches with a description first with the -l option to compadd and then adds in undescribed matches. Perhaps this can be presented better even if the parameters need to be spliced up. For my own setup, I'd likely limit this style to when at least a few characters have been typed which would avoid this; something like: zstyle -e ':completion:*:parameters' extra-verbose 'reply=( $(( ($#PREFIX+$#SUFFIX) > 2 )) )' The formatting for arrays, associative arrays and empty strings could perhaps also be nicer. Perhaps that's something for a future update. > -0:-F doesn't break _sequence > +0:-F doesn’t break _sequence This is a somewhat separate change. Do we want to be using unicode here? And, thanks. This looks useful. Oliver