This example highlights the power of a modal client. Remember that with lumail you're always in one of three modes:
- maildir-mode - Which shows you maildirs.
- index-mode - Which shows you indexes from the set of maildirs which are "selected".
- message-mode - Which shows you a single message.
The following function has the net result of showing all unread mail, in a list, regardless of which folder it is contained within:
-- -- Open all folders that contain unread messages, and view them all. -- function global_unread() -- set the mode appropriately. maildir_limit( "new" ); global_mode( "maildir" ); -- ensure we have no selected folders. clear_selected_folders(); offset = 0; -- Now for each one we'll add it to the selected set. while( offset <= (count_maildirs() - 1) ) do -- jump to folder. jump_maildir_to( offset ) -- Added the folder to the selected set. add_selected_folder() -- move to the next. offset = offset + 1; end -- -- Now we've added all maildirs with new mail to the list -- of selected maildirs. -- -- Jump to the global index-mode, and view only new mails. -- -- global_mode( "index" ); index_limit( "new" ); end
The key to this is to remember that more than one folder may be selected at the same time, and that the index-view will show a union of all selected folders.