diff options
-rw-r--r-- | core/args.lua | 11 | ||||
-rw-r--r-- | core/init.lua | 5 | ||||
-rw-r--r-- | modules/textadept/session.lua | 2 |
3 files changed, 10 insertions, 8 deletions
diff --git a/core/args.lua b/core/args.lua index bbf4a074..d5712a42 100644 --- a/core/args.lua +++ b/core/args.lua @@ -8,10 +8,12 @@ local M = {} -- -- ## Arg Events -- --- + `'arg_none'` +-- @field _G.events.ARG_NONE (string) -- Emitted when no command line arguments are passed to Textadept on startup. module('args')]] +events.ARG_NONE = 'arg_none' + -- Contains registered command line switches. -- @class table -- @name switches @@ -38,7 +40,7 @@ end -- Processes command line argument table *arg*, handling switches previously -- defined using `args.register()` and treating unrecognized arguments as -- filenames to open. --- Emits an `'arg_none'` event when no arguments are present. +-- Emits an `ARG_NONE` event when no arguments are present. -- @param arg Argument table. -- @see register -- @see events @@ -65,7 +67,7 @@ function M.process(arg) end i = i + 1 end - if no_args then events.emit('arg_none') end + if no_args then events.emit(events.ARG_NONE) end end -- Shows all registered command line switches on the command line. @@ -103,4 +105,7 @@ _G._USERHOME = userhome M.register('-u', '--userhome', 1, function() end, 'Sets alternate _USERHOME') M.register('-f', '--force', 0, function() end, 'Forces unique instance') +events.connect(events.INITIALIZED, + function() if arg then M.process(arg) end end) + return M diff --git a/core/init.lua b/core/init.lua index d272281e..47e2677f 100644 --- a/core/init.lua +++ b/core/init.lua @@ -5,9 +5,9 @@ _RELEASE = "Textadept 7.0 beta 3" package.path = _HOME..'/core/?.lua;'..package.path _SCINTILLA = require('iface') -args = require('args') _L = require('locale') events = require('events') +args = require('args') require('file_io') require('lfs_ext') require('ui') @@ -17,9 +17,6 @@ _M = {} -- language modules table -- LuaJIT compatibility. if jit then module, package.searchers, bit32 = nil, package.loaders, bit end -events.connect(events.INITIALIZED, - function() if arg then args.process(arg) end end) - --[[ This comment is for LuaDoc. --- -- Extends Lua's _G table to provide extra functions and fields for Textadept. diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index b44a777c..81023328 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -114,7 +114,7 @@ function M.load(filename) return true end -- Load session when no args are present. -events.connect('arg_none', function() +events.connect(events.ARG_NONE, function() if M.SAVE_ON_QUIT then M.load(M.DEFAULT_SESSION) end end) |