Switching between contexts. Heavily inspired by the contextual package.
A context contains a list of profiles, where only a single profile might be active per context. When changing a profile, a user-defined function for deactivating the currently active profile is called before a user-defined function for activating the new profile.
M-x sijo-ctx-switch-profile to switch a profile in the
sijo-ctx-default-context context.
C-u M-x sijo-ctx-switch-profile to select a context before switching profile.
The callback functions can be lambdas ((lambda () )), functions (#'function)
or symbols ('function). 'function is preferred as you can recompile the
function without having to register the profile again.
(sijo-ctx-add-profile 'some-profile
(lambda () (message "on activating"))
(lambda () (message "on deactivating"))
'some-context)Switch between different clients
(sijo-ctx-add-profile 'apple
(lambda () (message "Working for apple"))
(lambda () (message "Unloading apple"))
'client)
(sijo-ctx-add-profile 'fsf
(lambda () (message "Working for fsf"))
nil
'client)
(sijo-ctx--activate-profile 'apple 'client)
(sijo-ctx--activate-profile 'fsf 'client)Different roles in a company
(sijo-ctx-add-profile 'developer
(lambda () (message "developer mode"))
nil
'awesome-company)
(sijo-ctx-add-profile 'tech-lead
(lambda () (message "tech-lead mode"))
nil
'awesome-company)Different settings based on location
(sijo-ctx-add-profile '@home
(lambda () (message "Home sweet home"))
(lambda () (message "No longer home"))
'location)
(sijo-ctx-add-profile '@commute
(lambda () (message "Train goes choo choo"))
(lambda () (message "Elisp off rails"))
'location)
(sijo-ctx-add-profile '@office
(lambda () (message "At the office"))
(lambda () (message "Bye bye office"))
'location)Switching between multiple email accounts
(sijo-ctx-add-profile 'gmail
(lambda () (message "Setup for gmail"))
nil
'email)
(sijo-ctx-add-profile 'fastmail
(lambda () (message "Setup for fastmail"))
nil
'email)