Re: select all text behavior

From: Scott Weisman <sweis....at.gmail.com>
Date: Sun, 12 Dec 2010 01:38:58 -0800 (PST)

I found a problem in my solution. Sometimes I forget about the ctrl-a
and just keep going about my business. When I hit escape later, if I
am in a different buffer, I get an error:

...\Documents and Settings\sweisman/.textadept/init.lua:117: bad
argument #1 to '?' (the indexed Buffer is not the focused one)

So, I would like to changed the hook to something like this:

keys.ca = { function ()
    local buffer = buffer
-- saved_buffer = ???
    local KEYSYMS = _m.textadept.keys.KEYSYMS
    local pos = buffer.current_pos
    buffer:select_all()
    local restore = events.connect('keypress', function(code)
        if KEYSYMS[code] == 'esc' then
-- current_buffer = ???
-- if current_buffer ~= saved_buffer
-- goto saved_buffer
-- end
            buffer:goto_pos(pos)
-- if current_buffer ~= saved_buffer
-- goto current_buffer
-- end
            events.disconnect('keypress', restore)
        end
    end)
end }

Do you know what I have to fill in there to make it work?

Alternatively, just check if the current buffer is not the saved
buffer, and skip the goto_pos in that case, and just disconnect
without doing anything.

Scott

On Dec 9, 11:20 am, Scott Weisman <sweis....at.gmail.com> wrote:
> > How about simply having short cuts for
> > copy everything to clipboard,
> > delete everything and mabye
> > cut everything?
>
> I'm leaning towards this solution myself. I also looked into coding,
Received on Sun 12 Dec 2010 - 04:38:58 EST

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