Re: [textadept] Re: Problem with Windows io.popen

From: steve donovan <steve.j.dono....at.gmail.com>
Date: Fri, 6 May 2011 13:59:43 +0200

On Fri, May 6, 2011 at 1:49 PM, Robert <ro....at.web.de> wrote:
> The code from find.lua could be reused which works as you describe.

Right, yes, that's exactly right. It is easy enough to patch, but
better to reuse code.

My fix went like this: replace the call to io.open_file(utf8_filename)
in goto_error with this function:

local function find_view_or_buffer(utf8_filename)
  local file_buffer
  for i, b in ipairs(_BUFFERS) do
    if utf8_filename == b.filename then
      file_buffer = b
      break
    end
  end
  if file_buffer then
    for j, vw in ipairs(_VIEWS) do
      if vw.doc_pointer == file_buffer.doc_pointer then
        gui.goto_view(j,true)
        return
      end
    end
  end
  -- otherwise, ask TA to open the buffer
  io.open_file(utf8_filename)
end

These search-in-buffer and search-in-views patterns are certainly
common enough to be factored out, say as gui.find_buffer(filename) and
gui.find_view(buffer)

steve d.
Received on Fri 06 May 2011 - 07:59:43 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:06:32 EST