The branch, hooks has been updated
via 91b245e42e4393193f13566bb09d8bcb31f1005b (commit)
from d38bbd84627bf4735781a809a039e161aaf68d3b (commit)
- Log -----------------------------------------------------------------
commit 91b245e42e4393193f13566bb09d8bcb31f1005b
Author: Nicholas Marriott <[email protected]>
Commit: Nicholas Marriott <[email protected]>
Merge set and show hooks.
---
Makefile.am | 1 -
cmd-set-hook.c | 22 ++++++++++++++++++-
cmd-show-hooks.c | 61 ------------------------------------------------------
3 files changed, 21 insertions(+), 63 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 7739f24..545e6d7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -121,7 +121,6 @@ dist_tmux_SOURCES = \
cmd-set-hook.c \
cmd-set-option.c \
cmd-show-environment.c \
- cmd-show-hooks.c \
cmd-show-messages.c \
cmd-show-options.c \
cmd-source-file.c \
diff --git a/cmd-set-hook.c b/cmd-set-hook.c
index 7f12850..83332cd 100644
--- a/cmd-set-hook.c
+++ b/cmd-set-hook.c
@@ -24,7 +24,7 @@
#include "tmux.h"
/*
- * Set a global or session hook.
+ * Set or show global or session hooks.
*/
enum cmd_retval cmd_set_hook_exec(struct cmd *, struct cmd_q *);
@@ -37,6 +37,14 @@ const struct cmd_entry cmd_set_hook_entry = {
cmd_set_hook_exec
};
+const struct cmd_entry cmd_show_hooks_entry = {
+ "show-hooks", NULL,
+ "gt:", 0, 1,
+ "[-g] " CMD_TARGET_SESSION_USAGE,
+ CMD_PREP_SESSION_T,
+ cmd_set_hook_exec
+};
+
enum cmd_retval
cmd_set_hook_exec(struct cmd *self, struct cmd_q *cmdq)
{
@@ -46,12 +54,24 @@ cmd_set_hook_exec(struct cmd *self, struct cmd_q *cmdq)
struct hook *hook;
char *cause;
const char *name, *cmd;
+ char tmp[BUFSIZ];
+ size_t used;
if (args_has(args, 'g'))
hooks = &global_hooks;
else
hooks = &cmdq->state.tflag.s->hooks;
+ if (self->entry == &cmd_show_hooks_entry) {
+ RB_FOREACH(hook, hooks_tree, &hooks->tree) {
+ used = xsnprintf(tmp, sizeof tmp, "%s -> ", hook->name);
+ cmd_list_print(hook->cmdlist, tmp + used,
+ (sizeof tmp) - used);
+ cmdq_print(cmdq, "%s", tmp);
+ }
+ return (CMD_RETURN_NORMAL);
+ }
+
name = args->argv[0];
if (*name == '\0') {
cmdq_error(cmdq, "invalid hook name");
diff --git a/cmd-show-hooks.c b/cmd-show-hooks.c
deleted file mode 100644
index fa01d5b..0000000
--- a/cmd-show-hooks.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* $OpenBSD$ */
-
-/*
- * Copyright (c) 2012 Thomas Adam <[email protected]>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "tmux.h"
-
-/*
- * Show global or session hooks.
- */
-
-enum cmd_retval cmd_show_hooks_exec(struct cmd *, struct cmd_q *);
-
-const struct cmd_entry cmd_show_hooks_entry = {
- "show-hooks", NULL,
- "gt:", 0, 1,
- "[-g] " CMD_TARGET_SESSION_USAGE,
- CMD_PREP_SESSION_T,
- cmd_show_hooks_exec
-};
-
-enum cmd_retval
-cmd_show_hooks_exec(struct cmd *self, struct cmd_q *cmdq)
-{
- struct args *args = self->args;
- struct hooks *hooks;
- struct hook *hook;
- char tmp[BUFSIZ];
- size_t used;
-
- if (args_has(args, 'g'))
- hooks = &global_hooks;
- else
- hooks = &cmdq->state.tflag.s->hooks;
-
- RB_FOREACH(hook, hooks_tree, &hooks->tree) {
- used = xsnprintf(tmp, sizeof tmp, "%s -> ", hook->name);
- cmd_list_print(hook->cmdlist, tmp + used, (sizeof tmp) - used);
- cmdq_print(cmdq, "%s", tmp);
- }
-
- return (CMD_RETURN_NORMAL);
-}
-----------------------------------------------------------------------
Summary of changes:
Makefile.am | 1 -
cmd-set-hook.c | 22 ++++++++++++++++++-
cmd-show-hooks.c | 61 ------------------------------------------------------
3 files changed, 21 insertions(+), 63 deletions(-)
delete mode 100644 cmd-show-hooks.c
hooks/post-receive
--
tmux
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs