Short function of the week

From: Brian Schott <briancsch....at.gmail.com>
Date: Sun, 17 Jul 2011 22:11:24 -0700

(Just pretend this was posted on Saturday)

This function automatically wraps text as you type it at the edge_column value from your theme file, if it's been set. Useful for just keeping notes in plain text files.

keys[' '] = function()
        if buffer:get_lexer() == "container" then
                local buffer = buffer
                if buffer.column[buffer.current_pos] < buffer.edge_column then return false end
                buffer:begin_undo_action()
                while buffer.column[buffer.current_pos] > buffer.edge_column do buffer:word_left() end
                buffer:new_line()
                buffer:line_end()
                buffer:add_text(" ")
                buffer:end_undo_action()
        else return false end
end
Received on Mon 18 Jul 2011 - 01:11:24 EDT

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