alphapapa / activities.el

Activities for Emacs (suspend and resume activities, i.e. frames/tabs and their windows, buffers)
GNU General Public License v3.0
157 stars 10 forks source link
emacs

+TITLE: activities.el

NOTE: It would be preferable to put these at the bottom of the file under the export options heading, but it seems that "TEXINFO_DIR_CATEGORY" only works at the top of the file.

+EXPORT_FILE_NAME: activities.texi

+TEXINFO_DIR_CATEGORY: Emacs

+TEXINFO_DIR_TITLE: Activities: (activities)

+TEXINFO_DIR_DESC: Suspend/resume activities (sets of windows, frames, and buffers)

ELPA badge image.

[[https://elpa.gnu.org/packages/activities.html][file:https://elpa.gnu.org/packages/activities.svg]]

Inspired by Genera's and KDE's concepts of "activities", this Emacs library allows the user to manage frames/tabs, windows, and buffers according to their purpose. An "activity" comprises a frame or tab, its window configuration, and the buffers displayed in them--its "state"; this state would be related to a certain task the user performs at various times, such as developing a certain software project, reading and writing email, working with one's Org mode system, etc.

"Suspending" an activity saves the activity's state and closes its frame/tab; the user would do this when finished with the activity's task for the time being. "Resuming" the activity restores its buffers and windows to its frame/tab; the user would do this when ready to resume the task at a later time. This saves the user from having to manually arrange the same windows and buffers each time the task is to be done.

Each activity saves two states: the default state, set when the activity is defined by the user, and the last-used state, which was how the user left it when the activity was suspended (or when Emacs exited, etc). This allows the user to resume the activity where the task was left off, while also allowing it to be reverted to the default state, providing a consistent entry point into the activity.

Internally, the Emacs ~bookmark~ library is used to save and restore buffers' states--that is, any major mode that supports the bookmark system is compatible. A buffer whose major mode does not support the bookmark system (or does not support it well enough to restore useful state) is not compatible and can't be fully restored, or perhaps not at all; but solving that is as simple as implementing bookmark support for the mode, which is often trivial.

Various hooks are (or will be--feedback is welcome) provided, both globally and per-activity, so that the user can define functions to be called when an activity is saved, restored, or switched from/to. For example, this could be used to limit the set of buffers offered for switching to within an activity, or to track the time spent in an activity.

** GNU ELPA

~activities~ may be installed into Emacs versions 29.1 or later from [[https://elpa.gnu.org/packages/activities.html][GNU ELPA]] by using the command ~M-x package-install RET activities RET~. This will install the latest stable release, which is recommended.

** Quelpa

To install directly from git (e.g. to test a pre-release version), it's recommended to use [[https://framagit.org/steckerhalter/quelpa][Quelpa]]:

  1. Install [[https://framagit.org/steckerhalter/quelpa-use-package#installation][quelpa-use-package]] (which can be installed directly from MELPA).
  2. Add this form to your init file (see [[Configuration][Configuration]] for more details):

+BEGIN_SRC elisp

(use-package activities :quelpa (activities :fetcher github :repo "alphapapa/activities.el"))

+END_SRC

If you choose to install it otherwise, please note that the author can't offer help with manual installation problems.

This is the recommended configuration, in terms of a ~use-package~ form to be placed in the user's init file:

+BEGIN_SRC elisp

(use-package activities :init (activities-mode) (activities-tabs-mode) ;; Prevent `edebug' default bindings from interfering. (setq edebug-inhibit-emacs-lisp-mode-bindings t)

:bind
(("C-x C-a C-n" . activities-new)
 ("C-x C-a C-d" . activities-define)
 ("C-x C-a C-a" . activities-resume)
 ("C-x C-a C-s" . activities-suspend)
 ("C-x C-a C-k" . activities-kill)
 ("C-x C-a RET" . activities-switch)
 ("C-x C-a b" . activities-switch-buffer)
 ("C-x C-a g" . activities-revert)
 ("C-x C-a l" . activities-list)))

+END_SRC

** Activities

For the purposes of this library, an "activity" is a window configuration and its associated buffers. When an activity is "resumed," its buffers are recreated and loaded into the window configuration, which is loaded into a frame or tab.

From the user's perspective, an "activity" should be thought of as something like, "reading my email," "working on my Emacs library," "writing my book," "working for this client," etc. The user arranges a set of windows and buffers according to what's needed, then saves it as a new activity. Later, when the user wants to return to doing that activity, the activity is "resumed," which restores the activity's last-seen state, allowing the user to pick up where the activity was left off; but the user may also revert the activity to its default state, which may be used as a kind of entry point to doing the activity in general.

** Compatibility

This library is designed to not interfere with other workflows and tools; it is intended to coexist and allow integration with them. For example, when ~activities-tabs-mode~ is enabled, non-activity-related tabs are not affected by it; and the user may close any tab using existing tab commands, regardless of whether it is associated with an activity.

** Modes

** Workflow

An example of a workflow using activities:

  1. Arrange windows in a tab according to an activity you're performing.
  2. Call ~activities-define~ (~C-x C-a C-d~) to save the activity under a name.
  3. Perform the activity for a while.
  4. Change window configuration, change tab, close the tab, or even restart Emacs.
  5. Call ~activities-resume~ (~C-x C-a C-a~) to resume the activity where you left off.
  6. Return to the original activity state with ~activities-revert~ (~C-x C-a g~).
  7. Rearrange windows and buffers.
  8. Call ~activities-define~ with a universal prefix argument (~C-u C-x C-a C-d~) to redefine an activity's default state.
  9. Suspend the activity with ~activities-suspend~ (~C-x C-a s~) (which saves its last state and closes its frame/tab).

** Bindings

Key bindings are, as always, ultimately up to the user. However, in [[Configuration][Configuration]], we suggest a set of bindings with a simple philosophy behind them:

** Commands

/With the recommended bindings:/

** Bookmarks

When option ~activities-bookmark-store~ is enabled, an Emacs bookmark is stored when a new activity is made. This allows the command ~bookmark-jump~ (~C-x r b~) to be used to resume an activity (helping to universalize the bookmark system).

** v0.8-pre

Fixes

** v0.7

Additions

Changes

Fixes

** v0.6

Additions

Changes

** v0.5.1

Fixes

** v0.5

Additions

Changes

Fixes

** v0.4

Additions

Fixes

** v0.3.3

Fixes

** v0.3.2

Updated documentation, etc.

** v0.3.1

Fixes

** v0.3

Additions

** v0.2

Additions

Fixes

** v0.1.3

Fixes

** v0.1.2

Fixes

** v0.1.1

Fixes

** v0.1

Initial release.

~activities~ is developed on [[https://github.com/alphapapa/activities.el][GitHub]]. Suggestions, bug reports, and patches are welcome.

** Copyright assignment

This package is part of [[https://www.gnu.org/software/emacs/][GNU Emacs]], being distributed in [[https://elpa.gnu.org/][GNU ELPA]]. Contributions to this project must follow GNU guidelines, which means that, as with other parts of Emacs, patches of more than a few lines must be accompanied by having assigned copyright for the contribution to the FSF. Contributors who wish to do so may contact [[mailto:emacs-devel@gnu.org][emacs-devel@gnu.org]] to request the assignment form.

Copied from org-super-agenda's readme, in which much was borrowed from Org's =org-manual.org=.

+OPTIONS: broken-links:t *:t num:1 toc:1

** Info export options

NOTE: See note at top of file.

** File-local variables

NOTE: Setting org-comment-string buffer-locally is a nasty hack to work around GitHub's org-ruby's HTML rendering, which does not respect noexport tags. The only way to hide this tree from its output is to use the COMMENT keyword, but that prevents Org from processing the export options declared in it. So since these file-local variables don't affect org-ruby, wet set org-comment-string to an unused keyword, which prevents Org from deleting this tree from the export buffer, which allows it to find the export options in it. And since org-export does respect the noexport tag, the tree is excluded from the info page.

Local Variables:

before-save-hook: org-make-toc

org-export-initial-scope: buffer

org-comment-string: "NOTCOMMENT"

End: