I like the new flexible positioning when opening new buffers.  The
default setting of new_buffer_with_opener_position as
buffer_position_after results in a hierarchical ordering of buffers,
with descendants following their parent in right-to-left order.
Contrariwise, the value buffer_position_end results in a right-to-left
order, but buffers may be separated from their parents.

The function given below results in buffers ordered hierarchically in
left-to-right order, which feels more natural to me.  An example of a
similar ordering is in Firefox, where middle-clicked links are placed in
sequence to the right of the current tab, but only until another tab is
selected, when a new sequence is begun.

A left-to-right ordering cannot be strictly maintained; any of the
buffers may be re-used for any purpose; a link may be followed or an
unrelated URL opened.  The approximation used here is to place the new
buffer to the right of all other descendants of the current buffer (or
immediately to the right of the current buffer if it has no other
descendants).

Furthermore, no attempt is made to strictly maintain the parent/child
relationship; the referrer URL (with any #reference component trimmed
off) is used as an approximation for the parent of a buffer.

Despite these drawbacks, I think this ordering works rather well in
practise.  I intend to either submit this as a patch or perhaps to place
it as a tip on the wiki.  Comments welcome.


function url_ref_trim (uri) {
    try {
        uri = uri.clone().QueryInterface(Ci.nsIURL);
    } catch (e) {
        return uri.spec;
    }
    uri.ref = "";
    return uri.spec;
}

function buffer_position_after_descendants (container, b, i) {
    var refs = [url_ref_trim(container.get_buffer(i).current_uri)];
    var count = container.count;
    var p = i + 1;
    for (i++; i < count; i++) {
        b = container.get_buffer(i);
        if (b.web_navigation &&
            b.web_navigation.referringURI &&
            refs.indexOf(url_ref_trim(b.web_navigation.referringURI)) != -1)
        {
            refs.push(url_ref_trim(b.current_uri));
            p = i + 1;
        }
    }
    return p;
}

new_buffer_with_opener_position = buffer_position_after_descendants;

Regards, David
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to