From 655d3222b8e242bcdb96e9458dc311aee1a658e5 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 3 Feb 2008 16:45:32 -0500 Subject: Added textadept.reset() function for resetting the Lua state. The l_init function takes an additional reinit boolean as a result. When resetting, the package.loaded and _G tables are cleared. Since the textadept.buffers, textadept.views, and arg tables were originally in _G, they were moved to the LUA_REGISTRYINDEX table so as not to be lost. They are still available in _G, but as links to the tables in LUA_REGISTRYINDEX. textadept.reset() sets a global RESETTING boolean to true when init.lua is re-run so things like reloading a session or reloading files from the command line do not occur. The boolean is set to nil afterwards. --- init.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 44f7b13f..1a380f55 100644 --- a/init.lua +++ b/init.lua @@ -14,20 +14,22 @@ require 'textadept' require 'ext/key_commands' --- process command line arguments -local textadept = textadept -if #arg == 0 then - textadept.io.load_session() -else - local base_dir = arg[0]:match('^.+/') or '' - local filepath - for _, filename in ipairs(arg) do - if not filename:match('^~?/') then - textadept.io.open(base_dir..filename) - else - textadept.io.open(filename) +if not RESETTING then + -- process command line arguments + local textadept = textadept + if #arg == 0 then + textadept.io.load_session() + else + local base_dir = arg[0]:match('^.+/') or '' + local filepath + for _, filename in ipairs(arg) do + if not filename:match('^~?/') then + textadept.io.open(base_dir..filename) + else + textadept.io.open(filename) + end end + textadept.pm.entry_text = 'buffers' + textadept.pm.activate() end - textadept.pm.entry_text = 'buffers' - textadept.pm.activate() end -- cgit v1.2.3