commit e0bbbe3beb40f4ecd396c12745911bbdb1ee73c9
parent 8a60b03a0119c5ae071952dd5915f2741b3fe4f2
Author: William Casarin <jb55@jb55.com>
Date: Mon, 9 Jul 2018 20:09:19 -0700
cmd macros
Diffstat:
M | cfg.def.h | | | 37 | ++++++++++++++++++++++--------------- |
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/cfg.def.h b/cfg.def.h
@@ -39,23 +39,30 @@ static struct scheme schemes[SchemeLast] = {
},
};
+#define DEFCMD(b, nme, cmd) \
+ { .bind = (b), \
+ .name = (nme), \
+ .command = (cmd), \
+ .nchildren = 0, \
+ .children = NULL, \
+ },
+
+#define DEFPREFIX(b, nme, cs) \
+ { .bind = b, \
+ .name = nme, \
+ .command = 0, \
+ .nchildren = LENGTH(cs), \
+ .children = (cs), \
+ },
+
static struct command browser_commands[] = {
- { .bind = "s", .name = "chrome", .nchildren = 0, .children = NULL },
- { .bind = "c", .name = "chromium", .nchildren = 0, .children = NULL },
- { .bind = "f", .name = "firefox", .nchildren = 0, .children = NULL },
+ DEFCMD("s", "chrome scaled", "chrome")
+ DEFCMD("c", "chromium", "chromium")
+ DEFCMD("f", "firefox", "firefox")
+ DEFCMD("k", "kill chrome", "pkill --oldest chromium")
};
static struct command commands[] = {
- { .bind = "b",
- .name = "browsers",
- .nchildren = LENGTH(browser_commands),
- .children = browser_commands
- },
-
- { .bind = "e",
- .name = "emacs",
- .command = "emacs-dev",
- .children = 0,
- .nchildren = 0
- },
+ DEFPREFIX("b", "browsers", browser_commands)
+ DEFCMD("e", "emacs", "emacs-dev")
};