aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-02-03 16:45:32 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2008-02-03 16:45:32 -0500
commit655d3222b8e242bcdb96e9458dc311aee1a658e5 (patch)
tree9f1d643b137e2ea967ffad5ce16aad7fa8f9f1bb /init.lua
parentbc000dc1ea565efb81a2a3d4b7e6aa41c376c0fb (diff)
downloadtextadept-655d3222b8e242bcdb96e9458dc311aee1a658e5.tar.gz
textadept-655d3222b8e242bcdb96e9458dc311aee1a658e5.zip
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.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua30
1 files changed, 16 insertions, 14 deletions
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