summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actions.c69
-rw-r--r--src/actions.h1
2 files changed, 59 insertions, 11 deletions
diff --git a/src/actions.c b/src/actions.c
index ec44cda..3f23ddf 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -82,6 +82,7 @@ static user_command user_commands[] =
{"startup_message", cmd_startup_message, arg_STRING},
{"link", cmd_link, arg_STRING},
{"alias", cmd_alias, arg_STRING},
+ {"unalias", cmd_unalias, arg_STRING},
{"prevscreen", cmd_prevscreen, arg_VOID},
{"nextscreen", cmd_nextscreen, arg_VOID},
/*@end (tag required for genrpbindings) */
@@ -875,17 +876,7 @@ command (int interactive, char *data)
PRINT_DEBUG ("cmd==%s rest==%s\n", cmd, (char*)rest);
- /* find the command */
- for (uc = user_commands; uc->name; uc++)
- {
- if (!strcmp (cmd, uc->name))
- {
- result = uc->func (interactive, rest);
- goto done;
- }
- }
-
- /* Look for it in the aliases. */
+ /* Look for it in the aliases, first. */
for (i=0; i<alias_list_last; i++)
{
if (!strcmp (cmd, alias_list[i].name))
@@ -910,6 +901,16 @@ command (int interactive, char *data)
}
}
+ /* If it wasn't an alias, maybe its a command. */
+ for (uc = user_commands; uc->name; uc++)
+ {
+ if (!strcmp (cmd, uc->name))
+ {
+ result = uc->func (interactive, rest);
+ goto done;
+ }
+ }
+
marked_message_printf (0, 0, MESSAGE_UNKNOWN_COMMAND, cmd);
done:
@@ -2434,6 +2435,52 @@ cmd_alias (int interactive, void *data)
}
char *
+cmd_unalias (int interactive, void *data)
+{
+ char *name;
+ int index;
+
+ if (data == NULL)
+ {
+ message (" unalias: One argument required ");
+ return NULL;
+ }
+
+ /* Parse out the arguments. */
+ name = (char *)data;
+
+ /* Are we updating an existing alias, or creating a new one? */
+ index = find_alias_index (name);
+ if (index >= 0)
+ {
+ char *tmp;
+
+ alias_list_last--;
+
+ /* Free the alias and put the last alias in the the space to
+ keep alias_list from becoming sparse. This code must jump
+ through some hoops to correctly handle the case when
+ alias_list_last == index. */
+ tmp = alias_list[index].alias;
+ alias_list[index].alias = xstrdup (alias_list[alias_list_last].alias);
+ free (tmp);
+ free (alias_list[alias_list_last].alias);
+
+ /* Do the same for the name element. */
+ tmp = alias_list[index].name;
+ alias_list[index].name = xstrdup (alias_list[alias_list_last].name);
+ free (tmp);
+ free (alias_list[alias_list_last].name);
+ }
+ else
+ {
+ message (" unalias: alias not found ");
+ }
+
+ return NULL;
+}
+
+char *
cmd_nextscreen (int interactive, void *data)
{
int new_screen;
diff --git a/src/actions.h b/src/actions.h
index cbedd60..0503484 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -110,6 +110,7 @@ char * cmd_alias (int interactive, void *data);
char *cmd_defbarborder (int interactive, void *data);
char *cmd_prevscreen (int interactive, void *data);
char *cmd_nextscreen (int interactive, void *data);
+char *cmd_unalias (int interactive, void *data);
void initialize_default_keybindings (void);
rp_action* find_keybinding (KeySym keysym, int state);