Chet Ramey wrote: > Henning Bekel wrote: >> Hello, >> If I try to change READLINE_LINE and READLINE_POINT from a >> function bound via bind -x, then setting READLINE_POINT is not >> applied every second time I invoke the function. Instead, the >> cursor is placed at the end of the line. >> >> Simple test case: >> >> test_rl () { >> READLINE_LINE="$READLINE_LINE#edited" >> READLINE_POINT=3 >> } >> >> bind -x '"\ew": test_rl' >> >> And keep hitting \ew... every first time the cursor is placed >> at position 3, every second time it ends up at the end of the >> line. >> >> Is this the intended behavior or is it a bug? > > It's a bug. A fix will appear as a patch to bash-4.0.
Thanks! >> Also, is it intended that the modified line is drawn on a new >> line? For example, if I wrote a function that increments the >> word at READLINE_POINT if it contains only digits, and i wanted >> to increase a value by hitting a keyseq five times, I'd end up >> with five lines being printed in my terminal. I'd love to see >> this work like readline's own editing functions (e.g. >> upcase-word) or macros that edit the line without printing it >> again on a new line. But maybe I just misinterpreted the >> purpose of this new feature. If so, could you explain it's >> intended purpose? > > It's intended. Since the command executed as a result of `bind > -x' is an arbitrary one that can do anything it wants to the > display, it's better to completely redraw the line. I already assumed this, just thought I'd make sure, thanks. > I wonder if we could specify whether or not to completely redraw > the line with a return status. As far as I see it there hasn't been a reason to return a specific value from a function bound via -x in the past, has there? Still, maybe some users have done so out of principle (as in "I just always return 0 on success for any function"), and thus giving meaning to the return value might result in unexpected behaviour for existing code... not sure about this. Alternatively, couldn't another option like '-X' be introduced for bind to explicitly request not to redraw the line completely? Or would you consider this feature creep? Best Regards, Henning