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=DKIM_SIGNED,DKIM_VALID, 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 ca296e4f for ; Mon, 15 Jul 2019 21:43:20 +0000 (UTC) Received: (qmail 24513 invoked by alias); 15 Jul 2019 21:43:15 -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: 44537 Received: (qmail 1992 invoked by uid 1010); 15 Jul 2019 21:43:15 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f172.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25510. spamassassin: 3.4.2. Clear:RC:0(209.85.208.172):SA:0(-1.9/5.0):. Processed in 0.938606 secs); 15 Jul 2019 21:43:15 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.208.172 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=JvjUA+yRUWndXO6orK1ACKMLfBZn/1XCeoobv+oJuw8=; b=LgFnDpIH0Vuz7d4cOvvJHmIKVxc86yJ6v2HNCAGm0ifRfYnWA9rth+KQ4Y7wIzSG+b g/t799Hb+XZWTdBDvkKcMhk1QxpwPUZwW/Sw+PMatFlQgvGza6lfsz8MBXPk1p63Db+k gCMWscMfSn2qIdGAOh4+VdYpytgkY07Hm48rMqauYtGBl+H9Jmq97y5iK9fxvOQPwkRr QRZakfZf6jAX/5L0BV5JxLkcBWo4TSfubjUaS1KsMBzNpZaPy4o/Udw8K4Ej0XDHGn73 63rQqfSWgiQFx5qGPE8ZcpKMxkkU7v1DU4Wcd7PbBRTkNnvinOebVzB0jCRmd1aoSugx RopA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=JvjUA+yRUWndXO6orK1ACKMLfBZn/1XCeoobv+oJuw8=; b=Z75qXvlJZaMsk5eKdTomOoe8kGxVI7nOfsxQuP9I6lZsBAqLpoFnhqtZAJMkyoK6Um B3LtRe64Y4H++3BIlE22J6Mzm5+dwSxmEXX0vGimM6VEhy4ShsG7GrMMmLzJgPWr3MDR wbgwArd4W/Yz02jBUdrpS+zltpgHuPHN2HxI2eQHIt4c2zcw63zmUOA840ujPm5Edki+ WrFwVqjzR39s9w7gAypRBbVzLMKW10ZufG1vMYHhzaVMmRGXaMrpq9cN8bzNMVnqe4Og GKBEXaXNJGKlYudPftYQWjy86l7kL7ShtF7OY5AHcMiu5uUb8+J2W629LDhiHaVr+uBs l5Ow== X-Gm-Message-State: APjAAAUW0DB1p5gXLFM4LKHUFDHUSHLaqfetmVpw1LHrOiWlY/2nwaxl fIoC8S6gbr+FP6k8/rMlhdTirNGzW9y7Lx5MyB8j7g== X-Google-Smtp-Source: APXvYqw7az1UJtGWR7hA7oPq/kNBy4YiRaj1wd+N/PAblotQ+dpotgvwzGUjTlmJO7cQDiWBhZ7VUh1cICnmMJ5TA6U= X-Received: by 2002:a2e:b0e6:: with SMTP id h6mr14782959ljl.18.1563226960343; Mon, 15 Jul 2019 14:42:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Mon, 15 Jul 2019 14:42:28 -0700 Message-ID: Subject: Re: PATCH: function copy To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" On Mon, Jul 15, 2019 at 1:00 PM Peter Stephenson wrote: > > I've had this lying around for a while, wondering if there's more to it, > but I can't think of it. > > The point is that it's very easy internally to provide an interface to > tweak standard functions to add arbitrary code before and after --- we > have most of the support for this internally, and just lack the means to > add a different name for a function, which this adds. Emacs calls this "advice" and allows before/around/after variations which can be added without having to redefine the existing function. I have a half-finished (that may be optimistic) module to provide this for ZLE widgets. Handling the before/after is not too bad, but for "around" you need a way to say "call the original function HERE" which you can then embed in another function that becomes the "around" (and which is called in place of the original everywhere except HERE). The other thing that would be really helpful in order to do it "your way" would be local functions, so that when the calling context exits, _std_fn reverts to its old definition and _my_fn disappears. Hacking this by making the entire $functions array local is error-prone.