|
From: Daniel J S. <dan...@ie...> - 2007-06-06 09:39:09
|
Petr Mikulik wrote:
>>I've programmed the condensed version during display rather than tossing out
>>redundant commands and that was *so* much easier. The only difference is that
>>the up-arrow that you mention, Petr, will still have to go through the full
>>list. (I could probably reprogram that as well to skip redundancy.)
>>
>>I think it is easy enough to enable both with an option (full history stack,
>>default). In fact, I'd propose to deprecate
>
>
> So it seems everybody likes a different history: I like a "set" of commands,
> some other "ordered list" with/out duplicates, ... Dan, please make options
> to satisfy everybody -- it you think all this is worth to change.
OK, I think you will like this new patch (#1729825). Type
help history
help set history
"set history" will set a few options that can be over-ridden locally. E.g.,
set history condensed
will generally display the history stack in condensed format; however,
history full
will override that.
Here is something really neat, and nothing kludge-like about it from the
perspective of readline. When "set history condensed" is active, the up/down
arrows will now also scan through only unique history entries, like you want
Petr. Here is the elegant way to do it. Simply write a routine like
static int gp_get_condensed_next_history(int count, int key) {
/* Look for the previous unique command */
HIST_ENTRY **the_list = history_list();
int i_hist = where_history() + 1;
for (; i_hist < history_length; i_hist++) {
if (the_list[i_hist]->data == NULL)
break;
}
/* Advance to found unique entry */
if (i_hist < history_length)
return rl_get_next_history(i_hist - where_history(), key);
else
return 0;
}
and then bind that function to the downarrow key sequence. When not in
condensed mode, bind the keys back to the original rl_get_next_history().
There is some flexibility with what we could do (e.g., bind the condensed
up/down to other keys) but we'll see what feedback we get.
I've also made the non GNU-readline version behave similarly.
Could people please review this to see if everyone is happy, or at least mildly
content? I think it is close to ready. I've tried most everything and see no
bugs. (I've updated to readline-5.2, as readline-4.3 seemed buggy.)
...
Juergen, now that I'm familiar with all this GNU readline bindings stuff, I
think C-o may not be difficult. But again, you'll have to explain what it does.
E.g., give an example command-line stack and the before and after of a C-o.
Dan
|