lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I am having fun chaining string functions to process text in Textadept. This is not for the purists as I have been adding to the standard string library e.g.

    function string.pre(text,prefix)
        -- Prefix each line assuming "\n" for end of line
        return prefix..text:gsub("\n","\n"..prefix)
    end

Adding a few global functions to select and insert text (and define undo_action boundaries), I can then type in the command entry line "macros" e.g.

    selection():pre("--  "):gsub("Python ","Lua "):insert()
   
Repeatable and undo-able macros and not quite as unreadable as TECO commands :) 

Q1. Is there a limit to the number of chained string methods Lua 5.3 can process?

Q2. Is there any way to use chained methods for tables - in standard Lua 5.3?  
      This syntax appeals to me: 

    t = {"one","two","three"}
    print(t:insert("four"):sort():concat("\n"))

Kind Regards Gavin