From 5248783475981cd9eb9d0ba0109e353ca7c5b1f6 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Mon, 4 Jan 2010 16:45:46 -0500 Subject: Added command line switch for not loading/saving sessions. --- init.lua | 10 ++++++++++ modules/textadept/session.lua | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index f00dc278..8e2f4530 100644 --- a/init.lua +++ b/init.lua @@ -56,11 +56,21 @@ if not RESETTING then if #arg == 0 then _m.textadept.session.load() else + -- process command line switches + for i, switch in ipairs(arg) do + if switch == '-ns' or switch == '--no-session' then + _m.textadept.session.SAVE_ON_QUIT = false + table.remove(arg, i) + end + end + + -- open files local base_dir = arg[0]:match('^.+/') or '' for _, filename in ipairs(arg) do if not filename:find('^~?/') then filename = base_dir..filename end textadept.io.open(filename) end + -- read only the Project Manager session settings if not _m.textadept.session.load(nil, true) then textadept.pm.entry_text = 'buffers' diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index 3e7b48aa..61a5a301 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -11,9 +11,13 @@ module('_m.textadept.session', package.seeall) -- ## Settings -- -- * `DEFAULT_SESSION`: The path to the default session file. +-- * `SAVE_ON_QUIT`: Save the session when quitting. Defaults to true and can be +-- disabled by passing the command line switch '-ns' or '--no-session' to +-- Textadept. -- settings DEFAULT_SESSION = _USERHOME..'/session' +SAVE_ON_QUIT = true -- end settings --- @@ -161,4 +165,5 @@ function save(filename) end end -textadept.events.add_handler('quit', save, 1) +textadept.events.add_handler('quit', + function() if SAVE_ON_QUIT then save() end end, 1) -- cgit v1.2.3