From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id c3c0a60b for ; Thu, 23 Jan 2020 03:13:44 +0000 (UTC) Received: (qmail 3417 invoked by alias); 23 Jan 2020 03:13:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45339 Received: (qmail 8932 invoked by uid 1010); 23 Jan 2020 03:13:34 -0000 X-Qmail-Scanner-Diagnostics: from out3-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25699. spamassassin: 3.4.2. Clear:RC:0(66.111.4.27):SA:0(-2.6/5.0):. Processed in 4.68663 secs); 23 Jan 2020 03:13:34 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrvddugdehvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkjghfofggtgfgsehtqhdttdertdejnecuhfhrohhmpeffrghnihgv lhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenuc fkphepjeelrddukedtrdehjedrudduleenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Date: Thu, 23 Jan 2020 03:12:49 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Cc: "Andrew Reyes" Subject: Re: Unset =?UTF-8?B?4oCcemxlX2JyYWNrZXRlZF9wYXN0ZeKAnQ==?= .zshrc Message-ID: <20200123031249.034c7e1a@tarpaulin.shahaf.local2> In-Reply-To: References: <0723EF0A-BD62-4C2C-AAA1-735AD3D64768@icloud.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable [tl;dr: See the antepenultimate paragraph.] Daniel Shahaf wrote on Sat, 18 Jan 2020 19:40:42 +0000: > Andrew Reyes wrote on Fri, 17 Jan 2020 23:20 +00:00: > > The problem is:=20 > > 1) zsh/zle's setup_() assigns the parameter, overwriting existing values > >=20 > > 2) not possible to 'unset' the parameter before zsh/zle is loaded. >=20 > @Andrew thanks for the report. Let me spell out the symptoms for the lis= t: >=20 > In zshrc, =C2=ABtypeset -a zle_bracketed_paste=3D('' '')=C2=BB and =C2=AB= unset > zle_bracketed_paste=C2=BB have no effect if done before zsh/zle has been > loaded, because of zsh/zle's setup_() unconditionally assigns to the > parameter, even if it already exists and has a non-null value. >=20 > I looked into this yesterday, and guarding the assignaparam() call with > a paramtab->getnode() !=3D NULL fixes the case that the variable is > already set by the time zsh/zle is loaded (e.g., if it's set in zshrc). > However, I haven't been able to make =C2=ABunset zle_bracketed_paste=C2= =BB have > any lasting effect if done before zsh/zle is loaded. Is that achievable? I think it is achievable. We already have a facility for knowing which parameters will be provided by not-yet-loaded modules: $ zsh -fc 'zmodload -ap; zmodload' | tail patchars (zsh/parameter) reswords (zsh/parameter) saliases (zsh/parameter) termcap (zsh/termcap) terminfo (zsh/terminfo) userdirs (zsh/parameter) usergroups (zsh/parameter) widgets (zsh/zleparameter) zsh_scheduled_events (zsh/sched) zsh/main $=20 (For those following along at home: the 'autofeatures' array in the *.mdd file is compiled into a call to the autofeatures() function, which is done from init_bltinmods() during shell initialization.) Currently, unsetting a marked-for-autoloading parameter removes all traces of it: $ zsh -fc 'unset aliases; zmodload -ap | grep -w aliases; zmodload' zsh/main =E2=80=A6 but it's silently recreated when the module is actually loaded: $ zsh -fc 'unset aliases; zmodload zsh/parameter; echo ${(t)aliases}'=20 association-hide-hideval-special Because we know which parameters will be provided by modules _before_ those modules are loaded, we can change the behaviour so loading a module would not create parameters that had been marked autoloadable and subsequently unset; that is, we can make it so after =C2=ABunset aliase= s; zmodload zsh/parameter=C2=BB the parameter $aliases would remain unset. Would this be the Right way to proceed? Or would it be better to keep the current behaviour and document that modul= es must be loaded before parameters provided by them are =C2=ABunset=C2=BB? (= In this case, we could still check whether $zle_bracketed_paste exists before silently overwriting its zshrc-set value.) I haven't tried to implement this yet, but what I have in mind is (1)=C2=A0Make unsetparam_pm() add the PM_UNSET bit if the PM_AUTOLOAD bit is present; (2)=C2=A0Make module loading, before creating a parameter, check if there's a Param with PM_UNSET and PM_AUTOLOAD both set; if there is, rather than create the "real" parameter, delete the tombstone parameter. (But if there isn't a Param at all, the module _should_ create its special Param anyway, to allow modules to be unloaded and reloaded in the same shell session.) Thanks, Daniel