Re: Ctrl-Tab to go back to the most-recently-used buffer

From: mitchell <mforal.n....at.gmail.com>
Date: Wed, 13 May 2009 21:16:48 -0700 (PDT)

Andy,

> Problem is: _G.previous_buffer_idx always has the current buffer index, not
> the previous one's.

'buffer_switch' is activated after the switch occurs, so 'buffer'
always referrers to the current buffer naturally. One solution would
be to use an intermediate variable.

textadept.events.add_handler('buffer_switch',
  function()
    for idx, buf in ipairs(textadept.buffers) do
      if buf == buffer then
        _G.previous_buffer_idx = _G.current_buffer_idx or idx
        _G.current_buffer_idx = idx
      end
    end
  end)

There may be more elegant solutions, but this is the midnight one ;)
Received on Thu 14 May 2009 - 00:16:48 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:37:53 EST