Skip to content

Add support for buffer-local monitors #6

@GuiltyDolphin

Description

@GuiltyDolphin

Sometimes you may want a monitor to only be enabled in a particular buffer, but not others. For this we could use a concept of 'buffer-local' monitors, allowing them to be enabled/disabled on a per-buffer basis.

Things to think about

  • What would 'buffer-local' monitors mean for certain types of monitor such as timers? Should we even allow this?
    • We may want to restrict the types of monitors that can be buffer local.

Syntax

For instances:

(defvar my-monitor-instance
  (monitor 'my-monitor
    ...
    :buffer-local t)

For monitors (defaults instances to buffer-local):

(define-monitor 'my-example-monitor
  "My monitor...."
  ...
  :buffer-local t)

Possible approaches

  1. Tracking buffers

We could potentially track every buffer a monitor (instance) is enabled in by adding information to the variable.

We would have a special monitor (or hook) that would run when switching buffers, look at the enabled monitor instances then disable any that aren't supposed to be enabled in the current buffer.

We would also need to look through any disabled instances to see if any monitors should be enabled.

We would have a mechanism for specifying a monitor may be enabled globally.

Disadvantages: we would effectively need to look through every (non-global?) monitor instance every time we switch buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions