From 791fc92dc7bf15efff444004128b90b8b53ca14f Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Mon, 19 Jan 2009 23:25:01 -0500 Subject: Command line parameters can now be used in Windows. --- init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 87782215..aee97e87 100644 --- a/init.lua +++ b/init.lua @@ -33,6 +33,17 @@ require 'ext/menu' -- provides the menu bar require 'ext/key_commands' -- key commands for Mitchell (Nano-Emacs hybrid) if not RESETTING then + -- for Windows, create arg table from single command line string (arg[0]) + if WIN32 and #arg[0] > 0 then + local lpeg = require 'lpeg' + local P, S, C, Ct = lpeg.P, lpeg.S, lpeg.C, lpeg.Ct + space = P(' ') + param = P('"') * C((1 - P('"'))^0) * '"' + C((1 - space)^1) + cmdline = Ct(param * (space * param)^0) + args = lpeg.match(cmdline, arg[0]) + for _, a in ipairs(args) do arg[#arg + 1] = a end + end + -- process command line arguments if MAC and arg[1] and arg[1]:match('^%-psn_0') then table.remove(arg, 1) -- cgit v1.2.3