[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] add operate-and-get next (C-o) from Bash

From: Tom Tromey
Subject: Re: [PATCH] add operate-and-get next (C-o) from Bash
Date: Sun, 17 Jan 2021 14:26:19 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

>> This isn't a bug, but it's a feature I'd love to have: the
>> operate-and-get-next function (C-o) of Bash, which I'd find extremely
>> handy to use in some other Readline-equipped programs, too.

Chet> I applied this patch, with a minor change or two, and it will be in the
Chet> next bash and readline devel branch pushes.

gdb implemented its own version of this binding back in ancient times.
I tried importing readline 8.1 (initial testing looks good, thank you)
and then tried removing gdb's variant.

This didn't work, because gdb uses the callback API.

I came up with the appended.  It fixes a K&R-ism in
rl_operate_and_get_next, and it removes a call to _rl_init_line_state
from rl_callback_read_char.

What was happening before this patch is that operate-and-get-next would
update rl_line_buffer -- but then this call to _rl_init_line_state would
truncate it again.  The "target" command would still be displayed by
readline, but confusingly would not be invoked on RET.

I am not totally sure if this patch is correct.  What do you think?


diff --git a/readline/readline/callback.c b/readline/readline/callback.c
index a466cf9b6ef..aad53903f81 100644
--- a/readline/readline/callback.c
+++ b/readline/readline/callback.c
@@ -280,10 +280,6 @@ rl_callback_read_char (void)
          in_handler = 0;
          (*rl_linefunc) (line);
-         /* If the user did not clear out the line, do it for him. */
-         if (rl_line_buffer[0])
-           _rl_init_line_state ();
          /* Redisplay the prompt if readline_handler_{install,remove}
             not called. */
          if (in_handler == 0 && rl_linefunc)
diff --git a/readline/readline/misc.c b/readline/readline/misc.c
index 3d9a674ca59..a6329bf1216 100644
--- a/readline/readline/misc.c
+++ b/readline/readline/misc.c
@@ -664,8 +664,7 @@ set_saved_history ()
-rl_operate_and_get_next (count, c)
-     int count, c;
+rl_operate_and_get_next (int count, int c)
   /* Accept the current line. */
   rl_newline (1, c);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]