Author Topic: save / restore session; save / restore bookmarks  (Read 9399 times)

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
save / restore session; save / restore bookmarks
« on: June 26, 2013, 11:58:37 AM »
Just found some macros I wrote a couple of years ago.  I haven't been using them so I'm unsure of how reliable they are but they appear to work in Slickedit V18 and probably at least versions 17 and 16 as well.

Save/ restore sessions saves a subset of the information that vrestore.slk has in it but to any file of your choosing.  I don't have a complete list of what gets saved but it includes open buffers, windows (including the new troublesome floating windows :) ) and bookmarks.  The file has an "ini_section" type heading of [State] added to it at the start to help make it recognizable as a valid session file (I think that's why I did it!).

<<<<<< update 19 Oct 2014 >>>>>>>
I've uploaded a new version with the save session functions "deactivated" with #if 0 because I'm not sure they're reliable.
To save a set of files you can instead use the official (undocumented) functions
save_named_state
load_named_state
<<<<<<<<<<   >>>>>>>>>>>>

_command void xsave_session(_str filename = '')
Allows you to pass the filename to save the session into, otherwise defaults to
1. %configuratrion-folder%/SlickEdit Sessions/default.ses
or if a workspace is active
2. %workspace-folder%/SlickEdit Sessions/default.ses
but you get to confirm or re-select the file to save to.

_command void xrestore_session(_str filename = '')
Restores from a file of your choosing with defaults as for save-session.

_command void xsave_bookmarks()
Saves current bookmarks to %configuration-folder%/Bookmarks\bookmarks-file1.bmk  - or whatever file you choose.
You are given the choice of deleting all bookmarks after they have been saved.

_command void xrestore_bookmarks()
Restores bookmarks from %configuration-folder%/Bookmarks\bookmarks-file1.bmk   - or whatever file you choose.  Current bookmarks are cleared before restoring.

_command void xsave_session_plus_toolbars(_str filename = '')
Same as xsave_session but includes toolbars.
« Last Edit: October 19, 2014, 10:20:41 AM by Graeme »

sdavidhicks0

  • Community Member
  • Posts: 15
  • Hero Points: 0
Re: save / restore session; save / restore bookmarks
« Reply #1 on: July 15, 2013, 08:32:03 PM »
Thanks very much for the advice and macros, Graeme. Works like a charm! Wonderful.

« Last Edit: July 15, 2013, 08:40:38 PM by sdavidhicks0 »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: save / restore session; save / restore bookmarks
« Reply #2 on: July 24, 2013, 11:03:44 AM »
Updated xsave_restore.e to include xsave_session_plus_toolbars().

Haven't figured out a decent way to save / restore just toolbars but a crude way is to write a macro that first saves the current session, then loads a session file that includes toolbars, then restore the original session.
e.g. (I haven't actually tried this) 
xsave_session_plus_toolbars("file1.ses");  // save toolbars

// a few days later
xsave_session("file2.ses");
xrestore_session("file1.ses");  // get toolbars
xrestore_session("file2.ses");


Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: save / restore session; save / restore bookmarks
« Reply #3 on: October 19, 2014, 10:20:16 AM »
Uploaded a new version with a couple of fixes and the session functions deactivated with #if 0 because I'm not sure they're reliable.
To save a set of files you can instead use the official (undocumented) functions
save_named_state
load_named_state