1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

editor: make editor configurable via /executable

`/executable set editor /full/path/to/edit`.

Regards https://github.com/profanity-im/profanity/issues/1521
This commit is contained in:
Michael Vetter 2021-04-16 23:18:19 +02:00
parent 1f4f912e78
commit 19c5925c37
4 changed files with 23 additions and 3 deletions

View File

@ -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

View File

@ -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",

View File

@ -9276,6 +9276,21 @@ cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}
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)
{

View File

@ -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);