[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals-release/activities 970ec6c377 042/103: Add: Bookmark su
From: |
ELPA Syncer |
Subject: |
[elpa] externals-release/activities 970ec6c377 042/103: Add: Bookmark support |
Date: |
Tue, 30 Jan 2024 03:57:49 -0500 (EST) |
branch: externals-release/activities
commit 970ec6c37756f36e33f859683e9de91e7c1cfc4f
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Add: Bookmark support
---
README.org | 4 ++++
activity.el | 42 ++++++++++++++++++++++++++++++++----------
2 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/README.org b/README.org
index 6b2c7368f5..21a2502fa3 100644
--- a/README.org
+++ b/README.org
@@ -68,6 +68,10 @@ If you choose to install it otherwise, you'll need to load
both the ~activity~ a
6. Return to the original activity state with ~activity-revert~ (~C-x C-a g~).
7. Suspend the activity with ~activity-suspend~ (~C-x C-a s~) (which saves its
last state and closes its frame/tab).
+** Bookmarks
+
+When option ~activity-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).
+
* FAQ
+ How is this different from
[[https://github.com/alphapapa/burly.el][Burly.el]] or
[[https://github.com/alphapapa/bufler.el/][Bufler.el]]? :: Burly is a
well-polished tool for restoring window and frame configurations, which could
be considered an incubator for some of the ideas furthered here. Bufler's
~bufler-workspace~ library uses Burly to provide some similar functionality,
which is at an exploratory stage. ~activity~ hopes to provide a longer-term
solution more suitable for inte [...]
diff --git a/activity.el b/activity.el
index e264fab880..6ed4425f65 100644
--- a/activity.el
+++ b/activity.el
@@ -208,6 +208,22 @@ persisted."
"Prefix applied to activity names in frames/tabs."
:type 'string)
+(defcustom activity-bookmark-store t
+ "Store a bookmark when making a new activity.
+This is merely for convenience, offering a way to help unify the
+`bookmark' and `activity' interfaces (i.e. allowing
+`bookmark-jump' to open an activity rather than requiring the use
+of `activity-resume').
+
+Such bookmarks merely point to an activity name; they do not
+contain the actual activity metadata, so if an activity is
+discarded, such a bookmark could become stale."
+ :type 'boolean)
+
+(defcustom activity-bookmark-name-prefix "Activity: "
+ "Prefix for activity bookmark names."
+ :type 'string)
+
(defcustom activity-window-persistent-parameters
(list (cons 'header-line-format 'writable)
(cons 'mode-line-format 'writable)
@@ -253,6 +269,8 @@ Called with one argument, the activity."
(let ((activity (make-activity :name name)))
(activity--set activity)
(activity-save activity :defaultp t :lastp t)
+ (when activity-bookmark-store
+ (activity-bookmark-store activity))
(activity--switch activity)
activity))
@@ -308,6 +326,7 @@ In order to be safe for `kill-emacs-hook', this demotes
errors."
(defun activity-discard (activity)
"Discard ACTIVITY and its state.
It will not be recoverable."
+ ;; TODO: Discard relevant bookmarks when `activity-bookmark-store' is
enabled.
(interactive (list (activity-completing-read :prompt "Discard activity: ")))
(ignore-errors
;; FIXME: After fixing all the bugs, remove ignore-errors.
@@ -602,22 +621,25 @@ PROMPT is passed to `completing-read', which see."
(or (map-elt activity-activities name)
(make-activity :name name))))
-;; (defun activity--bookmarks ()
-;; "Return list of activity bookmarks."
-;; (bookmark-maybe-load-default-file)
-;; (mapcar (lambda (bookmark)
-;; (bookmark-prop-get bookmark 'activity))
-;; (cl-remove-if-not (pcase-lambda (`(,_name . ,(map handler)))
-;; (equal #'activity-bookmark-handler handler))
-;; bookmark-alist)))
-
(cl-defun activity-names (&optional (activities activity-activities))
"Return list of names of ACTIVITIES."
(map-keys activities))
+;;;; Bookmark support
+
+(require 'bookmark)
+
+(defun activity-bookmark-store (activity)
+ "Store a `bookmark' record for ACTIVITY."
+ (bookmark-maybe-load-default-file)
+ (let* ((activity-name (activity-name activity))
+ (bookmark-name (concat activity-bookmark-name-prefix activity-name))
+ (props `((activity-name . ,activity-name))))
+ (bookmark-store bookmark-name props nil)))
+
(defun activity-bookmark-handler (bookmark)
"Switch to BOOKMARK's activity."
- (activity--switch (map-elt activity-activities (car bookmark))))
+ (activity-resume (map-elt activity-activities (bookmark-prop-get bookmark
'activity-name))))
(defun activity--buffer-local-variables (variables)
"Return alist of buffer-local VARIABLES for current buffer.
- [elpa] externals-release/activities e0bdd210bd 027/103: Fix, (continued)
- [elpa] externals-release/activities e0bdd210bd 027/103: Fix, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 42f9e302be 031/103: Tidy, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 68dc0e0d55 033/103: Fix: Don't redisplay, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 31d563422f 030/103: Fix, tidy, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities d3d1c9f6dd 036/103: Docs: Update readme, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 0a5bdc6f1a 044/103: Add: (activity-new) Use prefix to redefine, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 2f4ce2441c 046/103: Docs: Update, add Info manual, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 99ae983d0b 048/103: Tidy, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 2e18f9cb36 047/103: Rename to "activities", ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities d5e0ad5884 049/103: Merge: Rename to "activities", ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 970ec6c377 042/103: Add: Bookmark support,
ELPA Syncer <=
- [elpa] externals-release/activities 7ee86c2841 043/103: Notes: Update, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 095231ef6a 052/103: Tidy: Indentation, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 8e004b83f1 058/103: Change: (activities--name-buffer) Error for missing buffers, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 5f044d448b 060/103: Change: (activities-resume) Don't reload already active activities, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 379058b3cf 061/103: Tidy, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities a4d0cf85a5 062/103: Docs: Update, list commands, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities e160659a91 065/103: Release: v0.1, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 1d8492adcf 068/103: Meta: v0.2-pre, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 6590d88558 069/103: Docs: Update, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 0a567ae61e 063/103: Docs: Update, ELPA Syncer, 2024/01/30