I don't know if this code is of any use, it's working ok for me. Below is the code I'm calling from buttons. When I rclick on the "session" button, my choices are save, load, clear, refresh, snapshot-save, snapshot-load
get_session: create a node describing the current state After the node is created I give it a descriptive headline load_session: open according to the UNLs opens the files, sets currentPosition clear_session: close all other tabs session_save_snapshot: write to a file session_load_snapshot: read from a file I had hoped to hook snapshots to events - resume with the previous state active, however I couldn't get that to work. Another button: "refresh" calls get_session and updates the current node instead of creating a new one. ------------------------------------------------------ def get_session(): """Return a list of UNLs for open tabs. """ tabs = g.app.windowList UNLs = [] for tab in tabs: current = tab.c.currentPosition() UNLs.append(current.get_UNL()) return UNLs def load_session(c, UNLs): """Open a tab for each item in UNLs. """ for UNL in UNLs: fname, unl = UNL.split("#") ok, frame = g.openWithFileName(fname, c) if ok: this_c = frame.c for pos in this_c.all_positions(): if pos.get_UNL() == unl: this_c.setCurrentPosition(pos) this_c.redraw() break def clear_session(c): """Close other tabs. The other session functions don't require parameters, use leotools.g I don't know how to get this filename from g, hence the ``c`` arg. """ this_fname = c.fileName() tabs = g.app.windowList cmdrs = [tab.c for tab in tabs] for cmdr in cmdrs: if cmdr.fileName() !=this_fname: cmdr.close() def session_save_snapshot(): import json session = get_session() with file('leo.session', 'w') as f: json.dump(session, f) f.close() def session_load_snapshot(): import json with file('leo.session') as f: session = json.loads(f.read()) return session On Thu, Oct 27, 2011 at 12:59 PM, Edward K. Ream <edream...@gmail.com> wrote: > On Thu, Oct 20, 2011 at 3:13 PM, ilkosta > <costantino.giuliod...@gmail.com> wrote: > >>> This is the recommended way to have Leo load multiple files. Why is >>> not good enough? > >> In my workbook.leo I use a button that pickle the session in the >> unknownAttribute of a time-node child of a day-node, where I can put >> some comment of what I'm doing in the body. >> There are also a button to restore the pickled session from the >> current node. >> I use this method from the day of the @session fun post and I found >> this solution very useful, especially because it allows me to jump to >> the precise UNL of each project that I was editing. >> That has also changed my initial habit of keeping everything in one >> big leo file. > > My apologies for the delay in responding. I'm still buried in email. > > Ok. I'm convinced. Support for sessions makes sense. > > Edward > > -- > You received this message because you are subscribed to the Google Groups > "leo-editor" group. > To post to this group, send email to leo-editor@googlegroups.com. > To unsubscribe from this group, send email to > leo-editor+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/leo-editor?hl=en. > > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to leo-editor@googlegroups.com. To unsubscribe from this group, send email to leo-editor+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en.