Comment inline.

On Sun, Apr 14, 2013 at 05:01:38PM +0100, Thomas Adam wrote:
> This allows for hooks to run when a bell is sounded by tmux.
> ---
>  server-window.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/server-window.c b/server-window.c
> index 4f5a550..99c25eb 100644
> --- a/server-window.c
> +++ b/server-window.c
> @@ -88,7 +88,7 @@ server_window_check_bell(struct session *s, struct winlink 
> *wl)
>               if (c == NULL || c->session != s || (c->flags & CLIENT_CONTROL))
>                       continue;
>               if (!visual) {
> -                     tty_bell(&c->tty);
> +                     ring_bell(s);
>                       continue;
>               }
>               if (c->session->curw->window == w)
> @@ -238,11 +238,18 @@ void
>  ring_bell(struct session *s)
>  {
>       struct client   *c;
> +     struct hooks    *hooks;
> +     struct hook     *h;
>       u_int            i;
>  
>       for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
>               c = ARRAY_ITEM(&clients, i);
> -             if (c != NULL && c->session == s && !(c->flags & 
> CLIENT_CONTROL))
> +             if (c != NULL && c->session == s && !(c->flags & 
> CLIENT_CONTROL)) {
>                       tty_bell(&c->tty);
> +                     hooks = s != NULL ? &s->hooks : &global_hooks;
> +                     if ((h = hooks_find(hooks, "on-bell")) != NULL)
> +                             hooks_run(h, c->cmdq);

I think you should add a helper to do these few lines because I guess
they will appear in a few places.

Maybe server_session_hook in server-fn.c or session_run_hook in
session.c?

I would make it variadic so we can use formats for the name, eg
something like:

void    server_session_hook(struct session *s, const char *fmt, ...);

But don't forget to add printflike to the declaration in tmux,h.

> +             }
> +
>       }
>  }
> -- 
> 1.7.11.4
> 
> 
> ------------------------------------------------------------------------------
> Precog is a next-generation analytics platform capable of advanced
> analytics on semi-structured data. The platform includes APIs for building
> apps and a phenomenal toolset for data science. Developers can use
> our toolset for easy data analysis & visualization. Get a free account!
> http://www2.precog.com/precogplatform/slashdotnewsletter
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to