Re: textadept 2.0 ideas/suggestions

From: Vyacheslav Egorov <v.e.ego....at.gmail.com>
Date: Wed, 8 Jul 2009 01:09:50 +0700

Thanks for the snippet. But IMHO it should not work at all. You should
not be able to so simply manipulate textadept (i.e. use buffer
methods) from the forked process, because child process will have a
totally separate address space. You need some kind of IPC with
marshalling and all other fancy things.

--
e.v.e
On Wed, Jul 8, 2009 at 12:58 AM, M Rawash<mraw....at.gmail.com> wrote:
>
> sorry, i didn't have an internet access at home for the past few days..
>
> On Tue, 2009-06-30 at 20:22 +0700, Vyacheslav Egorov wrote:
>> > this is probably one of the more trivial tasks yet, i've come up
>> with a
>> > way to fork run.execute in the background and then back, using
>> > lua-posix, but it keeps crashing ta (so it only works in theory),
>> would
>> > you be interested in debugging it?
>>
>> Could you please share it with us?
>>
>
> as i said, i hadn't had a chance to test it thoroughly, you can,
> however, modify it for use outside of ta as a proof of concept:
>
> require 'posix'
> function execute(command)
>  local filepath = textadept.iconv(buffer.filename, _CHARSET, 'UTF-8')
>  local filedir, filename = filepath:match('^(.+[/\\])([^/\\]+)$')
>  local filename_noext = filename:match('^(.+)%.')
>  command = command:gsub('%%%b()', {
>    ['%(filepath)'] = filepath, _CHARSET, 'UTF-8',
>    ['%(filedir)'] = filedir,
>    ['%(filename)'] = filename,
>    ['%(filename_noext)'] = filename_noext,
>  })
>  local current_dir = lfs.currentdir()
>  lfs.chdir(filedir)
>  local pfork = assert(posix.fork())
>  if ( pfork==0 )then
>    local p = io.popen(command..' 2>&1')
>    local out = p:read('*all')
>    p:close()
>    lfs.chdir(current_dir)
>    textadept.print(textadept.iconv('..done!', 'UTF-8', _CHARSET))
>    buffer:clear_all()
>    textadept.print(textadept.iconv('> '..command..'\n'..out, 'UTF-8', _CHARSET))
>    buffer:goto_pos(buffer.length)
>  else
>    textadept.print(textadept.iconv('waiting for \''..command..'\' to finish..', 'UTF-8', _CHARSET))
>  end
> end
>
>
>
>
>
> >
>
Received on Tue 07 Jul 2009 - 14:09:50 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:38:19 EST