From c839649551dd47edfebdfbfdf7be0923bf1ea8d1 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Fri, 10 Jul 2015 00:54:54 +0200
Subject: degesch: add some default aliases
---
degesch.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/degesch.c b/degesch.c
index ed49617..7e50ad9 100644
--- a/degesch.c
+++ b/degesch.c
@@ -8598,6 +8598,34 @@ show_first_time_help (struct app_context *ctx)
log_global_indent (ctx, "#m", g_first_time_help[i]);
}
+const char *g_default_aliases[][2] =
+{
+ { "c", "/buffer clear" }, { "close", "/buffer close" },
+ { "j", "/join $*" }, { "p", "/part $*" },
+ { "k", "/kick $*" }, { "kb", "/kickban $*" },
+ { "m", "/msg $*" }, { "q", "/query $*" },
+ { "n", "/names $*" }, { "t", "/topic $*" },
+ { "w", "/who $*" }, { "wi", "/whois $*" },
+ { "ww", "/whowas $*" },
+};
+
+static void
+load_default_aliases (struct app_context *ctx)
+{
+ struct str_map *aliases =
+ &config_item_get (ctx->config.root, "aliases", NULL)->value.object;
+ for (size_t i = 0; i < N_ELEMENTS (g_default_aliases); i++)
+ {
+ const char **pair = g_default_aliases[i];
+
+ struct str tmp;
+ str_init (&tmp);
+ str_append (&tmp, pair[1]);
+ str_map_set (aliases, pair[0], config_item_string (&tmp));
+ str_free (&tmp);
+ }
+}
+
static void
load_configuration (struct app_context *ctx)
{
@@ -8627,6 +8655,7 @@ load_configuration (struct app_context *ctx)
else
{
show_first_time_help (ctx);
+ load_default_aliases (ctx);
}
}
--
cgit v1.2.3-70-g09d2