diff options
author | Michael Vetter <jubalh@iodoru.org> | 2021-04-16 23:18:19 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2021-04-16 23:18:19 +0200 |
commit | 19c5925c378edc12e383278561e1a2f5e2d1f597 (patch) | |
tree | 3e02393fdbf2dc8579901ff5d28c855054ee47b5 /src/command | |
parent | 1f4f912e78d54821ff2ebaf736afa1cd54d51cd0 (diff) | |
download | profani-tty-19c5925c378edc12e383278561e1a2f5e2d1f597.tar.gz |
editor: make editor configurable via /executable
`/executable set editor /full/path/to/edit`. Regards https://github.com/profanity-im/profanity/issues/1521
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 1 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 9 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 15 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 1 |
4 files changed, 23 insertions, 3 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index f74ca847..26c9d948 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -1044,6 +1044,7 @@ cmd_ac_init(void) autocomplete_add(executable_ac, "avatar"); autocomplete_add(executable_ac, "urlopen"); autocomplete_add(executable_ac, "urlsave"); + autocomplete_add(executable_ac, "editor"); } void diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index e85f1a56..239467a1 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2508,7 +2508,8 @@ static struct cmd_t command_defs[] = { CMD_SUBFUNCS( { "avatar", cmd_executable_avatar }, { "urlopen", cmd_executable_urlopen }, - { "urlsave", cmd_executable_urlsave }) + { "urlsave", cmd_executable_urlsave }, + { "editor", cmd_executable_editor }) CMD_NOMAINFUNC CMD_TAGS( CMD_TAG_DISCOVERY) @@ -2525,7 +2526,8 @@ static struct cmd_t command_defs[] = { { "urlopen set", "Set executable that is run by /url open. Takes a command template that replaces %u and %p with the URL and path respectively." }, { "urlopen default", "Restore to default settings." }, { "urlsave set", "Set executable that is run by /url save. Takes a command template that replaces %u and %p with the URL and path respectively." }, - { "urlsave default", "Use the built-in download method for saving." }) + { "urlsave default", "Use the built-in download method for saving." }, + { "editor set", "Set editor to be used with /editor. Needs full file path." }) CMD_EXAMPLES( "/executable avatar xdg-open", "/executable urlopen set \"xdg-open %u\"", @@ -2533,7 +2535,8 @@ static struct cmd_t command_defs[] = { "/executable urlopen default", "/executable urlsave set \"wget %u -O %p\"", "/executable urlsave set \"curl %u -o %p\"", - "/executable urlsave default") + "/executable urlsave default", + "/executable editor set /usr/bin/vim") }, { "/url", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 8c9377f8..9d8fec50 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -9277,6 +9277,21 @@ cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args) } gboolean +cmd_executable_editor(ProfWin* window, const char* const command, gchar** args) +{ + guint num_args = g_strv_length(args); + + if (g_strcmp0(args[1], "set") == 0 && num_args >= 3) { + prefs_set_string(PREF_COMPOSE_EDITOR, args[2]); + cons_show("`editor` command set to invoke '%s'", args[2]); + } else { + cons_bad_cmd_usage(command); + } + + return TRUE; +} + +gboolean cmd_mam(ProfWin* window, const char* const command, gchar** args) { _cmd_set_boolean_preference(args[0], command, "Message Archive Management", PREF_MAM); diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index f4ca72ed..a2c5f8f3 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -241,6 +241,7 @@ gboolean cmd_url_save(ProfWin* window, const char* const command, gchar** args); gboolean cmd_executable_avatar(ProfWin* window, const char* const command, gchar** args); gboolean cmd_executable_urlopen(ProfWin* window, const char* const command, gchar** args); gboolean cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_executable_editor(ProfWin* window, const char* const command, gchar** args); gboolean cmd_mam(ProfWin* window, const char* const command, gchar** args); gboolean cmd_editor(ProfWin* window, const char* const command, gchar** args); |