buffer ordering
commit8cc96654f166c625c5b4224e7cea365604fbb8d7
authorJohn Foerch <jjfoerch@earthlink.net>
Sat, 14 May 2011 04:18:28 +0000 (14 00:18 -0400)
committerJohn Foerch <jjfoerch@earthlink.net>
Sun, 29 Jan 2012 19:00:34 +0000 (29 14:00 -0500)
treeb5e3b25db5f2b506a4825789d08657d81f4ce211
parent3cc23207d6e3942eaf6c91fd9e6d062b39c7f353
buffer ordering

This patch introduces a design for spatial ordering (one-dimensional) of
buffers, a canonical order independent of (but not in conflict with) the
temporal ordering (based on last-access time) that was there before.
Spatial ordering of buffers lends itself especially well to a tabs-based
UI or other on-screen visualization of the buffer-list.

Central to this is the introduction of the idea of "buffer position" as
regards the place where new buffers are inserted or buffers are buried.
If buffers have a spatial order, we must be able to say where in that
ordering a new buffer is initially inserted, recognizing that we may like
to configure this based on circumstances such as whether the new buffer
has an opener in the same window, or the type of the new buffer.

Position is represented either as a simple index number or in a
generalized way, as a function that, given a buffer list, a buffer to
insert, and the index of another buffer appropriate to the type of action
doing the insertion, returns the index at which to insert the new buffer.

Several position functions are provided:

 * buffer_position_before

   Before the other buffer.

 * buffer_position_after

   After the other buffer.

 * buffer_position_end

   At the end of the list.

 * buffer_position_end_by_type

   After the last buffer of the same type in the list.

Several variables have positions as their value, to configure the behavior
of various ways in which buffers are inserted into a buffer list:

 * new_buffer_position, new_buffer_with_opener_position

   These two user variables both have a position as their value, and
   determine the basic behavior of where new buffers get inserted when
   there is or is not an opener.

 * buffer $position keyword

   The keyword '$position', given to the buffer constructor, overrides
   new_buffer_position or new_buffer_with_opener_position.

 * buffer.default_position

   The property of a buffer, 'default_position' also overrides
   new_buffer_position and new_buffer_with_opener_position, but is itself
   overridden by the keyword '$position'.  This property provides a way to
   configure position based on buffer type.  For instance, to make all
   special buffers be inserted at the end of the buffer list:

       special_buffer.prototype.default_position = buffer_position_end;

 * bury_buffer_position

   This variable controls the default position for buried buffers.

Manual buffer moving is also provided, by the following commands:

 * buffer-move-forward (M-N)
 * buffer-move-backward (M-P)

Other technical details follow:

move_buffer_hook: new hook, called when a buffer is moved.

buffer_container.buffer_list is now a list of the canonical ordering of
buffers.  last-accessed order is now tracked in buffer_container.buffer_history.

buffer_container.insert: new method of buffer_container that manages
inserting a new buffer in a given position.

tab-bar.js, new-tabs.js, buffer_count_widget, session_load,
session-auto-save updated.

This patch is partly based on the work of Ben Spencer and Peter Lunicks.
modules/bindings/default/global.js
modules/buffer.js
modules/mode-line.js
modules/new-tabs.js
modules/session.js
modules/tab-bar.js