On Sat, Aug 07, 2010 at 10:23:30PM +0200, Vitaly S. wrote:
> "John J. Foerch" <[email protected]> writes:
> >
> > 2) We don't store access times for buffers, but the 'buffers' property of
> > each window is a list of buffers, stored in access order, so yes, the
> > information is available.
>
> Sorry, I have only a very vague idea of how conkeror works and almost not JS
> experience. I found that window.buffers.bufer_list is indeed a list of buffers
> stored in decreasing access time order.
>
> So, the idea would be to modify switch-to-buffer such that the displayed
> buffers
> are in that exact order.I tried to modify "switch-to-buffer" by
> supplying the $completer argument with explicit $completions, an array
> window.buffers.buffer_list as bellow:
>
> interactive("switch-to-buffer-ordered",
> "Switch to the most recent buffer.",
> function (I) {
> switch_to_buffer(
> I.window,
> (yield I.minibuffer.read_buffer(
> $prompt = "Switch to buffer:",
> $default = (I.window.buffers.count > 1 ?
> I.window.buffers.buffer_list[1] :
> I.buffer),
> $completer = all_word_completer(
> //<-this added
> $completions = I.window.buffers.buffer_list,
> //<-this is supposed to give the ordered buffers??
> $get_string = function (x) x.description,
> $get_description = function (x) x.title)))
> );
> });
>
> I definitely do not understand how "all_word_completer" and other completers
> work
> and would appreciate any help.
>
> I fill like being very close to what I actually need, am I?
>
> Many thanks,
> Vitaly.
You need a new reader, since buffer order is hard-coded into read_buffer.
So try this...
minibuffer.prototype.read_recent_buffer = function () {
var window = this.window;
var buffer = this.window.buffers.current;
keywords(arguments, $prompt = "Buffer:",
$default = buffer,
$history = "buffer");
var buffers = window.buffers.buffer_list.slice(0);
buffers.push(buffers.shift());
var completer = all_word_completer(
$completions = buffers,
$get_string = function (x) x.description,
$get_description = function (x) x.title);
var result = yield this.read(
$keymap = read_buffer_keymap,
$prompt = arguments.$prompt,
$history = arguments.$history,
$completer = completer,
$match_required = true,
$auto_complete = "buffer",
$auto_complete_initial = true,
$auto_complete_delay = 0,
$default_completion = arguments.$default);
yield co_return(result);
};
interactive("switch-to-recent-buffer",
"Switch to a buffer specified in the minibuffer. List of buffers "+
"will be ordered by recency.",
function (I) {
switch_to_buffer(
I.window,
(yield I.minibuffer.read_recent_buffer(
$prompt = "Switch to buffer:",
$default = (I.window.buffers.count > 1 ?
I.window.buffers.buffer_list[1] :
I.buffer))));
});
define_key(default_global_keymap, "C-x B", "switch-to-recent-buffer");
--
John Foerch
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror