-
Notifications
You must be signed in to change notification settings - Fork 44
Workgroups data structures
Let's look at ~/.workgroups file:
[cl-struct-wg-session "0G3A08BU1E35GEA0-18GPMY" ...
([cl-struct-wg-workgroup "0G3A08D8APKR11T4-1C1G10" "Tasks" ...
[cl-struct-wg-wconfig "0GGI0JY4B3HD0WEO-86RSR3" ...
[cl-struct-wg-wtree ...
([cl-struct-wg-win ...
[cl-struct-wg-win ...
The corresponding structures are defined in workgroups-structs.el. So all "workgroups" are in session:
- session
- workgroup 1
- wconfig
- wtree
- win (a buffer)
- win (a buffer)
- wtree
- wconfig
- workgroup 2 ...
- workgroup 1
What's the difference between wconfig and wtree? Well a workgroup can have several wconfigs (buffer layouts). But to keep it simple let's say each workgroup has only 1 wconfig.
wconfig = wtree + additional parameters
Ok, we define a session structure in structs.el, and you can get the value of it with (wg-current-session)
(wg-defstruct wg session
(uid (wg-generate-uid))
(name)
(modified)
(parameters)
(file-name)
(version wg-version)
(workgroup-list)
(buf-list))wg-defstruct creates functions like wg-session-..., wg-make-session (to manipulate structures). So if you have (wg-defstruct wg session ...) - then you have wg-session-file-name and other defined fields.
Look at (wg-defstruct wg session.... To access objects in session use variables like wg-session-<fieldname>. The same rule applies to other defstruct's.
For example:
;; Read
(wg-session-file-name (wg-current-session)) ; Get a filename of current session
(wg-workgroup-parameters (wg-current-workgroup)) ; Get workgroup parameters
;; Write (used just before saving session to file)
(setf (wg-session-file-name (wg-current-session)) filename) ; Set session filename
(setf (wg-session-version (wg-current-session)) wg-version) ; Write workgroups versionChanging main structures may lead to huge problems in compatibility. That's why there are parameters for session, workgroup, wconfig and win objects.
Parameters allow you to save your custom data.
For example to set (key, value) pair for current workgroup:
;; Write (key, value)
(wg-set-workgroup-parameter (wg-current-workgroup t) ; current workgroup
'ecb ; parameter name
(and (boundp 'ecb-minor-mode) ecb-minor-mode)) ; parameter value;; Read a parameter
(wg-workgroup-parameter (wg-current-workgroup t) ; workgroup
'ecb ; parameter name
nil) ; default valueFunctions to work with parameters:
For session: wg-session-parameter, wg-set-session-parameter, wg-remove-session-parameter
For workgroup: wg-workgroup-parameter, wg-set-workgroup-parameter, wg-remove-workgroup-parameter
Writing objects to file is done in... (function stack):
-
wg-write-sexp-to-file-
wg-pickel-all-session-parameters-
wg-pickel-workgroup-parameters-
wg-pickel<-- main function
-
-
-
So the main function to transform Lisp objects to strings is wg-pickel in workgroups-pickel.el.