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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 875 invoked from network); 8 Nov 2023 19:17:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Nov 2023 19:17:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1699471065; b=MXJqg6amW+6z5k7gttOPYaKcEut770+G0VOjPgOScKDyO/xsrn/c6zumTUU0lWYi3vS+m2rniP 9dFgGHifjYTOZWpQT8lzSWAj3XdrhT4Sgkc60gjol9q3aQczeSL03lDgUZ4HGvUJkYQF3Vu6Gf NNxXT31zbBvwUVQujRrcbHrRSQlozCW8NZZNKEUkvJ8vgyPeySoPQtTCNhRH/xpruPTWKdSjj2 zAmzM8WVCM0br1LdeW9R0Gtmh19OD9LcP37erU5BGLhMRSCR/A5LlQPyjrOVUi2zMd+DGd9mqV K8ucjup3nrj/oOVvGblytkIv/7Z5UYBFz3UbFS9e12wUgA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mailin02.mxof.com) smtp.remote-ip=72.20.134.35; dmarc=none header.from=anthropohedron.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1699471065; bh=I/nQnCr4xBKi+O/cekqbugAYJwWCt+hBnYZ2Sjr7FYg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:In-Reply-To:Content-Type: MIME-Version:References:Reply-To:Message-ID:Subject:To:From:Date: DKIM-Signature; b=BQznK2ri5/5Soj9+qd1KhYEiJaQBc4ouD+AfojKzr17TkZZlpIaizL9qcVnG4w+EIGID6RDwvn hndK4pEMpxcyFYu8nuCvpsQ7cOIVVH9NCrpOmLcS5sqUj+7oXJt2uSmjJQoSvuWmX5xuhy6423 Gz8HTT23mIFmLqlDSdTXRofwDrF6mg50pACKHtZndkF5Mf0zG/ZQqUlmpBkmi6abBT4a1Lr9Tm XMBjQ4VikB8IbliGRvkYZ3tLlHBloENzRQT5aJDZaqjGPrIZ/A9zz3mDUEJjUxbrWbbBzJOL8B oiQ4u2XMC59k216dmapwMbMAJVlNzq7Sc5jq96SFbfyv+w==; 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:Content-Transfer-Encoding:In-Reply-To :Content-Type:MIME-Version:References:Reply-To:Message-ID:Subject:To:From: Date:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=jJuO6m+XPHen0XkVwN3qdKN0ledLOe6LwhaICFGw1U8=; b=Wo+sTJz+44OIVX55GM2S/AxNWe oE/KA7Vdzs6E+WgNhRzzEXp8TjwhvYXlSFf/P1Ed5PLg0ws6qEg5m3YISMobgWu3Jjc16NtludVUK a83jEj7hxsQybP1du6gZdo2QtEJZaQ0IuqUn9wIZFNXwLrZ1wW1yiOHTRRURLGvyp17EZHGyNHbQ6 d92qFUbTEt3GcbZp4IpccPRA/dtiTwMi9OlSmYArPP9WNuRKxlg3ddOxjWarg59dgED5N8Jx5ya57 uUN+qRuG8zMRR8A8omeb4BA551w2sIkC7W9AFIG2NcpmU2D8a9qrol8mB4JeyiNCW439NRaVDXdtG L26qsMGw==; Received: by zero.zsh.org with local id 1r0o3c-0007sU-3U; Wed, 08 Nov 2023 19:17:44 +0000 Authentication-Results: zsh.org; iprev=pass (mailin02.mxof.com) smtp.remote-ip=72.20.134.35; dmarc=none header.from=anthropohedron.net; arc=none Received: from mailin02.mxof.com ([72.20.134.35]:49073) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1r0o33-0007a2-VZ; Wed, 08 Nov 2023 19:17:10 +0000 Received: from mta02.mxof.net (mta02.prxy.com [3.17.98.36]) by mailin02.mxof.com (8.15.2/8.15.2/Debian-8) with ESMTPS id 3A8JGVfi009892 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 8 Nov 2023 19:16:53 GMT Received: from mta02.mxof.net (localhost.localdomain [127.0.0.1]) by mta02.mxof.net (Postfix) with ESMTPS id 838DE2B6FED for ; Wed, 8 Nov 2023 19:16:31 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by mta02.mxof.net (Postfix) with ESMTP id 6C72D2B6FF7 for ; Wed, 8 Nov 2023 19:16:31 +0000 (UTC) X-Virus-Scanned: amavis at mta02.mxof.net Received: from mta02.mxof.net ([127.0.0.1]) by localhost (mta02.mxof.net [127.0.0.1]) (amavis, port 10026) with ESMTP id 7gRaQKHRhmUG for ; Wed, 8 Nov 2023 19:16:31 +0000 (UTC) Received: from peterbilt.lan (pool-68-134-14-115.bltmmd.fios.verizon.net [68.134.14.115]) (Authenticated sender: jollygood@usermail.com) by mta02.mxof.net (Postfix) with ESMTPSA id 5BBA72B6FED for ; Wed, 8 Nov 2023 19:16:31 +0000 (UTC) Received: from gss by peterbilt.lan with local (Exim 4.96) (envelope-from ) id 1r0o2Q-00Ewv5-2f for zsh-workers@zsh.org; Wed, 08 Nov 2023 14:16:30 -0500 Date: Wed, 8 Nov 2023 14:16:30 -0500 From: Gregory Seidman To: zsh-workers@zsh.org Subject: PATCH: custom zsh hooks (was Re: Extending zsh hooks) Message-ID: Reply-To: gsslist+zshdev@anthropohedron.net Mail-Followup-To: zsh-workers@zsh.org References: <509022a0-b851-4203-bf83-7d6e26660b82@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <509022a0-b851-4203-bf83-7d6e26660b82@app.fastmail.com> Content-Transfer-Encoding: quoted-printable X-Bayes-Prob: 0.0001 (Score 0, tokens from: outgoing:default, base:default, @@RPTN) X-CanIt-Geo: ip=3.17.98.36; country=US; region=Ohio; city=Columbus; latitude=39.9653; longitude=-83.0235; http://maps.google.com/maps?q=39.9653,-83.0235&z=6 X-CanItPRO-Stream: outgoing:default (inherits from base:default) X-Canit-Stats-ID: 02b7Tgvfm - 2da5943dc665 - 20231108 X-Antispam-Training-Forget: https://spamblock.prxy.com/b.php?c=f&i=02b7Tgvfm&m=2da5943dc665&rlm=outgoing&t=20231108 X-Antispam-Training-Nonspam: https://spamblock.prxy.com/b.php?c=n&i=02b7Tgvfm&m=2da5943dc665&rlm=outgoing&t=20231108 X-Antispam-Training-Phish: https://spamblock.prxy.com/b.php?c=p&i=02b7Tgvfm&m=2da5943dc665&rlm=outgoing&t=20231108 X-Antispam-Training-Spam: https://spamblock.prxy.com/b.php?c=s&i=02b7Tgvfm&m=2da5943dc665&rlm=outgoing&t=20231108 X-Scanned-By: CanIt (www . roaringpenguin . com) on 10.1.0.12 X-Seq: 52283 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 Tue, Nov 07, 2023 at 09:35:30PM -0500, Lawrence Vel=E1zquez wrote: [...] > The usual process is to propose changes on this list and include > any patches inline or as an attachment. You can find many examples > in the archive (e.g., ). Perfect! My one-line-plus-documentation patch is below. The proposal is t= o have a way to add custom hook types to be managed with add-zsh-hook. > --=20 > vq --Gregory diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index f43ac2257..004a244b6 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -303,10 +303,11 @@ The shell function tt(add-zsh-hook) provides a simp= le way of adding or removing functions from the array. =20 var(hook) is one of tt(chpwd), tt(periodic), tt(precmd), tt(preexec), -tt(zshaddhistory), tt(zshexit), or tt(zsh_directory_name), -the special functions in question. Note that tt(zsh_directory_name) -is called in a different way from the other functions, but may -still be manipulated as a hook. +tt(zshaddhistory), tt(zshexit), or tt(zsh_directory_name), the special +functions in question. Additional custom hooks may be manipulated with +add-zsh-hook by setting the var(customhooktypes) shell variable. Note t= hat +tt(zsh_directory_name) is called in a different way from the other +functions, but may still be manipulated as a hook. =20 var(function) is name of an ordinary shell function. If no options are given this will be added to the array of functions to be executed diff --git a/Functions/Misc/add-zsh-hook b/Functions/Misc/add-zsh-hook index 3bc952e2f..33090f201 100644 --- a/Functions/Misc/add-zsh-hook +++ b/Functions/Misc/add-zsh-hook @@ -18,6 +18,7 @@ local -a hooktypes hooktypes=3D( chpwd precmd preexec periodic zshaddhistory zshexit zsh_directory_name + ${customhooktypes:-} ) local usage=3D"Usage: add-zsh-hook hook function\nValid hooks are:\n $h= ooktypes" =20