9.1 What are contexts
Let’s see what’s contained in a context. Most of it is optional.
mu4e-context is Lisp object with the following members:
- name: the name of the context, e.g. work or private
- vars: an association-list (alist) of variable settings for this account.
- enter-func: an (optional) function that takes no parameter and is invoked when
entering the context. You can use this for extra setup etc.
- leave-func: an (optional) function that takes no parameter and is invoked when
leaving the context. You can use this for clearing things up.
match-func: an (optional) function that takes an MSG message plist as
argument, and returns non-nil if this context matches the situation. mu4e
uses the first context that matches, in a couple of situations:
- when starting mu4e to determine the starting context; in this case,
MSG is nil. You can use e.g. the host you’re running or the time of day to
determine which context matches.
- before replying to or forwarding a message with the given message plist as parameter,
or nil when composing a brand new message. The function should return t
when this context is the right one for this message, or nil otherwise.
- when determining the target folders for deleting, refiling etc; see Contexts and special
mu4e uses a variable
mu4e-contexts, which is a list of such objects.