Re: [textadept] Re: buffer list

From: Robert <ro....at.web.de>
Date: Mon, 13 Dec 2010 09:27:37 +0100

Hi Scott,

On Mon, Dec 13, 2010 at 8:58 AM, Scott Weisman <sweis....at.gmail.com> wrote:
> Here's what I have so far:
>
> keys.ck = { function ()
>    local buffer = buffer
>    local events = events
>    local items = {}
>
>    for _, buffer in ipairs(_BUFFERS) do
>        local filename = buffer.filename or buffer._type or 'UNTITLED'
>        local dirty = buffer.dirty and '* ' or ''
>        table.insert(items, 1, dirty .. filename)
> --        items[#items + 1] = dirty .. filename
>        buffer:user_list_show(BUFFER_LIST_TYPE, table.concat(items,
> '|'))
>    end
> end }
>
> When I invoke the above, I get this error:
>
> ...\Documents and Settings\sweisman/.textadept/init.lua:182: bad
> argument #1 to '?' (the indexed Buffer is not the focused one)
>
> Line 182 is the call to buffer:user_list_show.
>

the call to buffer:user_list_show needs to be after the for loop, I think.

keys.ck = { function ()
  local buffer = buffer
  local events = events
  local items = {}
  local BUFFER_LIST_TYPE = 10
  for _, buffer in ipairs(_BUFFERS) do
      local filename = buffer.filename or buffer._type or 'UNTITLED'
      local dirty = buffer.dirty and '* ' or ''
       items[#items + 1] = dirty .. filename
  end
  local sep = buffer.auto_c_separator
  buffer.auto_c_separator = ('|'):byte()
  buffer:user_list_show(BUFFER_LIST_TYPE, table.concat(items, '|'))
  buffer.auto_c_separator = sep
end }

Robert
Received on Mon 13 Dec 2010 - 03:27:37 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:56:03 EST