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 3174 invoked from network); 9 Apr 2021 19:11:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Apr 2021 19:11:46 -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-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=hv9NUSlsxXVfOMsBemvx/KXgZh7aRHD0NP4ndTkFJZI=; b=rgyQ067a/9mhz4G1up5KVShqy8 B3qaWsnqwjZZLr3Dk94cmCbANEvZRrXBVtRZ5XALYGIVUgRM7ZMcyYxCpAFrRbbvbaAT77G5fqbs9 iXcCEGMiWdPUjHtIn30XB3zsbOh8KWB2TVmfQX0pLIUYPxBlkwsA0FsLv1K0mVnz1aPvg1By3NeZz 69xPRrLiNbs/TQbGgRMwaxrAUQxvBtdWEuENkpjbZxpy4Dor+fHg/0Fwbf90aD7a38EgBhj9oPGDI wlJZg5t0mxjcHphBhrhFElXoKHrsi5MnyeR/1DqngVz4gtt5eNdCVsGwp0GtJfV/Gy/Sf+49FBuqM 9T9zD+og==; Received: from authenticated user by zero.zsh.org with local id 1lUwXc-00036N-4p; Fri, 09 Apr 2021 19:11:40 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lUwXP-0002rk-2l; Fri, 09 Apr 2021 19:11:27 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.93.0.4) (envelope-from ) id 1lUwXN-000L12-K0 for zsh-workers@zsh.org; Fri, 09 Apr 2021 21:11:25 +0200 In-reply-to: From: Oliver Kiddle References: To: Zsh hackers list Subject: Re: Proposal: Let compinit make standard widgets with _generic instead of _main_complete MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <80786.1617995485.1@hydra> Date: Fri, 09 Apr 2021 21:11:25 +0200 Message-ID: <80787-1617995485.617359@q0GB.FFaP.JPH4> X-Seq: 48442 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: On 4 Apr, Bart Schaefer wrote: > On Mon, Mar 22, 2021 at 12:17 AM Marlon Richert > > > +if [[ "${curcontext:-:::}" == ::: ]] && > > > + zstyle -t ":completion:::::" generic-widgets "$WIDGET" > > > +then > > > + _generic "$@" > > > + return > > > +fi > > > > This feels like a rather roundabout solution. _generic itself already That does indeed seem rather roundabout. And all it achieves is a different way to configure what can already be configured. > > checks whether $curcontext is set and then calls _main_complete. Why > > not just do the straightforward thing, and let the widget call > > _generic directly, which in turn will call _main_complete anyway? > > This is really only the first in a few steps of patch that I didn't > want to spend time on if this were rejected out of hand. > The problem with calling _generic at all (right now) is that it messes > with $curcontext in a way that may break other functions that rely on > _main_complete behavior. If we can invert the call sequence so > _main_complete remains first, then _generic itself can be tweaked so > that it does NOT mung the context in that circumstance, while still > leaving the original semantics of creating a new widget with _generic > unchanged. The only thing _generic really does is shove $WIDGET into the second field of $curcontext where _main_complete left this empty. I wouldn't know why it was empty by default other than perhaps brevity. But it does provide for a notion of a default behaviour for the tab key and widgets like _complete_debug that want to follow that default. Certainly, I have quite a few styles defined with the two consecutive colons hardcoded. I can't see how we can change it in a backward compatible way even if we determine that it would be better. The intended way to do this is to use zle -C to define a custom widget based on an existing one and _generic. And if you really want the existing widget, zstyle -e allows you to check $WIDGET. Or is the aim here actually something else like making it easier for a plugin to base changes on underlying user settings. Oliver