zsh-workers
 help / color / mirror / code / Atom feed
From: Gregory Seidman <gsslist+zshdev@anthropohedron.net>
To: zsh-workers@zsh.org
Subject: PATCH: custom zsh hooks (was Re: Extending zsh hooks)
Date: Wed, 8 Nov 2023 14:16:30 -0500	[thread overview]
Message-ID: <ZUveju0JwMTPa1cM@peterbilt.lan> (raw)
In-Reply-To: <509022a0-b851-4203-bf83-7d6e26660b82@app.fastmail.com>

On Tue, Nov 07, 2023 at 09:35:30PM -0500, Lawrence Velázquez 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., <https://www.zsh.org/mla/workers/2023/>).

Perfect! My one-line-plus-documentation patch is below. The proposal is to
have a way to add custom hook types to be managed with add-zsh-hook.

> -- 
> 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 simple way of adding or
 removing functions from the array.
 
 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 that
+tt(zsh_directory_name) is called in a different way from the other
+functions, but may still be manipulated as a hook.
 
 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=(
   chpwd precmd preexec periodic zshaddhistory zshexit
   zsh_directory_name
+  ${customhooktypes:-}
 )
 local usage="Usage: add-zsh-hook hook function\nValid hooks are:\n  $hooktypes"
 


  reply	other threads:[~2023-11-08 19:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07 23:31 Extending zsh hooks Gregory Seidman
2023-11-08  2:35 ` Lawrence Velázquez
2023-11-08 19:16   ` Gregory Seidman [this message]
2023-11-09  5:13     ` PATCH: custom zsh hooks (was Re: Extending zsh hooks) Bart Schaefer
2023-11-09  4:09   ` Extending zsh hooks Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZUveju0JwMTPa1cM@peterbilt.lan \
    --to=gsslist+zshdev@anthropohedron.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).