[2768] in BarnOwl Developers
Re: [PATCH] Allow adding text to the command history
daemon@ATHENA.MIT.EDU (Alex Dehnert)
Thu Nov 11 23:12:26 2010
Date: Thu, 11 Nov 2010 23:12:23 -0500
From: Alex Dehnert <adehnert@MIT.EDU>
To: barnowl-dev@mit.edu
In-Reply-To: <1289534697-28606-1-git-send-email-adehnert@mit.edu>
Oh, hey, apparently I sent this in on 12/24/2009, when it apparently
failed to get a reply. Anyway...
On 11/11/2010 11:04 PM, adehnert@MIT.EDU wrote:
> From: Alex Dehnert<adehnert@mit.edu>
>
> Adds the cmd-history-add command, which permits
> appending text to the command history.
>
> Adds the with-history command, which permits
> saving a command to history and executing it.
> This is primarily intended for use with bindkey.
>
> See also http://barnowl.mit.edu/ticket/96.
> ---
> I wrote this a while ago. I'm not sure if I ever actually sent it in,
> but I know I at least mentioned it somewhere.
>
> commands.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 50 insertions(+), 0 deletions(-)
>
> diff --git a/commands.c b/commands.c
> index 5cbe262..e7e0c4b 100644
> --- a/commands.c
> +++ b/commands.c
> @@ -768,6 +768,16 @@ const owl_cmd commands_to_init[]
> "message<message>",
> ""),
>
> + OWLCMD_ARGS("add-cmd-history", owl_command_add_cmd_history, OWL_CTX_ANY,
> + "Add a command to the history",
> + "add-cmd-history<cmd>",
> + ""),
> +
> + OWLCMD_ARGS("with-history", owl_command_with_history, OWL_CTX_ANY,
> + "Run a command and store it into the history",
> + "with-history<cmd>",
> + ""),
> +
> OWLCMD_VOID("yes", owl_command_yes, OWL_CTX_RECV,
> "Answer yes to a question",
> "yes",
> @@ -2632,6 +2642,46 @@ char *owl_command_message(int argc, const char *const *argv, const char *buff)
> return NULL;
> }
>
> +char *owl_command_add_cmd_history(int argc, const char *const *argv, const char *buff)
> +{
> + owl_history *hist;
> + const char *ptr;
> +
> + if (argc< 2) {
> + owl_function_makemsg("usage: %s<commands> ...", argv[0]);
> + return NULL;
> + }
> +
> + ptr = skiptokens(buff, 1);
> + hist = owl_global_get_cmd_history(&g);
> + owl_history_store(hist, ptr);
> + owl_history_reset(hist);
> + /* owl_function_makemsg("History '%s' stored successfully", ptr+1); */
> + return NULL;
> +}
> +
> +char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
> +{
> + owl_history *hist;
> + const char *ptr;
> +
> + if (argc< 2) {
> + owl_function_makemsg("usage: %s<commands> ...", argv[2]);
> + return NULL;
> + }
> +
> + ptr = skiptokens(buff, 1);
> + if (!ptr) {
> + owl_function_makemsg("Parse error finding command");
> + return NULL;
> + }
> +
> + hist = owl_global_get_cmd_history(&g);
> + owl_history_store(hist, ptr);
> + owl_history_reset(hist);
> + return owl_function_command(ptr);
> +}
> +
> void owl_command_yes(void)
> {
> owl_message *m;