From 53fd2b35343d6ba66ee97be3adb136f266270c07 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 6 Dec 2015 02:12:20 +0000 Subject: [PATCH] Read ~/.config/profanity/inputrc --- src/config/preferences.c | 22 ++++++++++++++++++++-- src/config/preferences.h | 2 ++ src/ui/inputwin.c | 7 +++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/config/preferences.c b/src/config/preferences.c index 30b07598..088fb527 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -85,8 +85,7 @@ prefs_load(void) } prefs = g_key_file_new(); - g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, - NULL); + g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, NULL); err = NULL; log_maxsize = g_key_file_get_integer(prefs, PREF_GROUP_LOGGING, "maxsize", &err); @@ -920,6 +919,25 @@ prefs_get_aliases(void) } } +gchar* +prefs_get_inputrc(void) +{ + gchar *xdg_config = xdg_get_config_home(); + GString *inputrc_file = g_string_new(xdg_config); + g_free(xdg_config); + + g_string_append(inputrc_file, "/profanity/inputrc"); + + if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) { + gchar *result = strdup(inputrc_file->str); + g_string_free(inputrc_file, TRUE); + + return result; + } + + return NULL; +} + void _free_alias(ProfAlias *alias) { diff --git a/src/config/preferences.h b/src/config/preferences.h index b2411906..910245c1 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -222,4 +222,6 @@ gboolean prefs_get_room_notify(const char *const roomjid); gboolean prefs_get_room_notify_mention(const char *const roomjid); gboolean prefs_get_room_notify_trigger(const char *const roomjid); +gchar* prefs_get_inputrc(void); + #endif diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index c840baac..a6711bab 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -421,6 +421,13 @@ _inp_rl_startup_hook(void) // disable readline completion rl_variable_bind("disable-completion", "on"); + // check for and load ~/.config/profanity/inputrc + char *inputrc = prefs_get_inputrc(); + if (inputrc) { + rl_read_init_file(inputrc); + free(inputrc); + } + return 0; }