Running SciTE with file parameter won't load last session

638 views
Skip to first unread message

Vlastimil Ovčáčík

unread,
Jan 30, 2012, 12:34:57 PM1/30/12
to scite-interest
Hi,
is there an option to force loading last session on every SciTE launch? It actually loads session, but not always - if you open scite with parametr it won't load last session. Even worse it overwrite the session on next exit. The use case is:

a) normal behaviour
cmd: scite.exe
Last session is loaded, new files can be added to session and session is saved.

b) current (annoying) behaviour
cmd: scite.exe foo.txt
Last session is not loaded, only foo.txt is displayed in edit pane and last session is overwritten with current session.

c) expected behaviour
cmd: scite:exe foo.txt
Last session is loaded, foo.txt is added at the end of the buffer and session is saved on next exit.

It would be great to get scite from b) to c).

Thanks
Vlastimil Ovcacik

zetah

unread,
Feb 1, 2012, 1:38:46 AM2/1/12
to scite-interest
I would also ask for some way of avoiding session overwrite

If for some reason SciTE isn't opened and I accidentally double click
file associated with SciTE, or some application launches SciTE as
default application for some file type, my previous session is lost.
What I do then is load last 10 files from recent file list menu, which
is bad

There is "loadsession:" command line argument, but I can't think how
to use it to solve this problem

Maybe "save.session" property could have one more value - 2, which
would indicate opening single file *not* to override "save.session"
value

Vlastimil Ovčáčík

unread,
Feb 1, 2012, 5:07:39 AM2/1/12
to scite-i...@googlegroups.com
Zetah,
I am using loadsession in batch file to preload the session before opening a file. It's not elegant but it works.

###
@echo off

REM Check if SciTE is already running
tasklist /FI "IMAGENAME eq scite.exe" 2>NUL | find /I /N "scite.exe">NUL
if "%ERRORLEVEL%" NEQ "0" (
  REM If not, load default session and wait 3 seconds
  start /D "%SciTE_HOME%" SciTE.exe -loadsession:SciTE.session
  ping -n 3 localhost
)

REM Pass all parameters to scite.exe
start /D "%SciTE_HOME%" SciTE.exe %*
###

Some built in feature would be much appreciated.



--
You received this message because you are subscribed to the Google Groups "scite-interest" group.
To post to this group, send email to scite-i...@googlegroups.com.
To unsubscribe from this group, send email to scite-interes...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scite-interest?hl=en.


zetah

unread,
Feb 1, 2012, 5:55:25 AM2/1/12
to scite-interest
Thanks Vlastimir,

I'm on Linux and can probably make my file associations with
"preloading" session file, but that doesn't seem like right solution
similarly as overwriting session file doesn't seem to me like great
decision. At least option to cache session file before overwriting and
reload on possible user demand would be more sensitive approach

I'm not sure if Lua start-up script can be used to copy session file
to temp folder in case SciTE overwrites it, or more precisely if
session file is removed prior Lua start-up script initiation

KHMan

unread,
Feb 1, 2012, 6:21:51 AM2/1/12
to scite-i...@googlegroups.com
On 2/1/2012 6:55 PM, zetah wrote:
> I'm on Linux and can probably make my file associations with
> "preloading" session file, but that doesn't seem like right solution
> similarly as overwriting session file doesn't seem to me like great
> decision. At least option to cache session file before overwriting and
> reload on possible user demand would be more sensitive approach
>
> I'm not sure if Lua start-up script can be used to copy session file
> to temp folder in case SciTE overwrites it, or more precisely if
> session file is removed prior Lua start-up script initiation

I separate SciTE processes/windows when used for widely separate
tasks by changing SciTE_HOME using autohotkey, then the one where
I want the session saved is separate from 'normal' SciTE processes.

The ahk file has 2 lines only, for example:
EnvSet,SciTE_HOME,D:\MyApps\wscite\mplab
Run,D:\MyApps\wscite\SciTE.exe

Of course, this needs a separate set of configuration files. I use
it when running with a different asm.properties, but later found
it convenient for saving sessions as well.

The above may or may not be suitable for everyone, but at least it
is another way of approaching a similar issue.

> On Feb 1, 11:07 am, Vlastimil Ovčáčík wrote:
>> Zetah,
>> I am using loadsession in batch file to preload the session before opening
>> a file. It's not elegant but it works.

>>[snip snip]

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia

zetah

unread,
Feb 1, 2012, 3:20:04 PM2/1/12
to scite-interest
It seems it can, but problem still not solved. I have this function in
Lua start-up script:

++++++++++++++++++++++++++++++++++++++++
function store_last_session()
local ses = io.open(props["SciteUserHome"] .. "/stored_session",
"w")

ses:write(io.open(props["SessionPath"], "r"):read("*a"))
ses:flush()
end

function restore_last_session()
scite.MenuCommand(132, props["SciteUserHome"] .. "stored_session")
end
========================================

and I call "store_last_session()" in "OnOpen":

++++++++++++++++++++++++++++++++++++++++
AddEventHandler("OnOpen", function()
store_last_session()
end, 'RunOnce')
========================================

which works just fine, and last session is saved in "stored_session"
in user's home folder.

Problem is how to load it automatically without browsing to it. SciTE
menu command 132 (IDM_LOADSESSION) doesn't seem to accept arguments,
so "restore_last_session()" function is useless, as it just executes
LoadSession menu command.

This is still better then nothing, but I wonder if there is a way to
automate it completely?

zetah

unread,
Feb 1, 2012, 3:29:12 PM2/1/12
to scite-interest
There is a typo in:

> function restore_last_session()
>     scite.MenuCommand(132, props["SciteUserHome"] .. "stored_session")
> end

it should be (notice slash):

scite.MenuCommand(132, props["SciteUserHome"] .. "/stored_session")

but that doesn't change anything.
Worth mentioning is slash character in store_last_session() which is
not so obvious and if user tries this on Windows it wont work unless
replaced with two backslashes

Neil Hodgson

unread,
Feb 4, 2012, 7:02:32 AM2/4/12
to scite-i...@googlegroups.com
zetah:

> Maybe "save.session" property could have one more value - 2, which
> would indicate opening single file *not* to override "save.session"
> value

You can change the "open" action in the registry to turn off
session saving by setting save.session to 0 similar to this:

HKEY_CLASSES_ROOT\Applications\SciTE.exe\shell\open\command="C:\bin\scite\SciTE.exe"
-save.session=0 "%1"

Neil

Reply all
Reply to author
Forward
0 new messages