emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals-release/activities 9f566e9523 020/103: WIP (Stuff is br


From: ELPA Syncer
Subject: [elpa] externals-release/activities 9f566e9523 020/103: WIP (Stuff is broken, don't use yet)
Date: Tue, 30 Jan 2024 03:57:47 -0500 (EST)

branch: externals-release/activities
commit 9f566e9523f875815457df887dc6f308ee781e5e
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    WIP (Stuff is broken, don't use yet)
---
 README.org  |  2 ++
 activity.el | 37 ++++++++++++++++++++-----------------
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/README.org b/README.org
index 9cd2bb02be..d7b1888f5c 100644
--- a/README.org
+++ b/README.org
@@ -1,5 +1,7 @@
 #+TITLE: activity.el
 
+*NOTE:* This is currently broken.  Don't use it yet.  (It's only a day old.)
+
 Inspired by Genera's and KDE's concepts of "activities", this library allows 
the user to select an "activity", the loading of which restores a window 
configuration and/or frameset, along with the buffers shown in each window.  
Saving an activity saves the state for later restoration.  Switching away from 
an activity saves the last-used state for later switching back to, while still 
allowing the activity's initial or default state to be restored on demand.  
Restoring an activity loads the [...]
 
 The implementation uses the bookmark system to save 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 usually trivial.
diff --git a/activity.el b/activity.el
index 778ae14c67..abe1f87e7d 100644
--- a/activity.el
+++ b/activity.el
@@ -224,15 +224,15 @@ Called with one argument, the activity."
 ;;;; Commands
 
 (defun activity-new (name)
-  "Switch to a new, empty activity named NAME."
+  "Save current state as a new activity with NAME."
   ;; Not sure if this is needed, but let's experiment.
   (interactive (list (read-string "New activity name: ")))
   (when (member name (activity-names))
     (user-error "Activity named %S already exists" name))
-  (scratch-buffer)
-  (delete-other-windows)
   (let ((activity (make-activity :name name)))
-    (run-hook-with-args 'activity-after-resume-functions activity)))
+    (activity--set activity)
+    (activity-save name :defaultp t :lastp t)
+    activity))
 
 (cl-defun activity-resume (activity &key resetp)
   "Resume ACTIVITY.
@@ -250,22 +250,21 @@ closed."
   (activity-save activity :lastp t)
   (activity-close activity))
 
-(cl-defun activity-save (activity &key defaultp lastp)
-  "Save ACTIVITY's states.
+(cl-defun activity-save (name &key defaultp lastp)
+  "Save states of activity having NAME.
 If DEFAULTP, save its default state; if LASTP, its last."
-  (interactive (list (activity-completing-read :prompt "Save activity as: ")
-                     :defaultp t :lastp t))
   (unless (or defaultp lastp)
     (user-error "Neither DEFAULTP nor LASTP specified"))
-  (activity-with activity
-    (pcase-let* (((cl-struct activity name default last) activity)
-                 (default (if defaultp (activity-state) default))
-                 (last (if lastp (activity-state) last))
-                 (props `((handler . activity-bookmark-handler)
-                          (activity . ,(prog1 activity
-                                         (setf (activity-default activity) 
default
-                                               (activity-last activity) 
last))))))
-      (bookmark-store name props nil))))
+  (let ((activity (or (activity-named name) (activity-new name))))
+    (activity-with activity
+      (pcase-let* (((cl-struct activity name default last) activity)
+                   (default (if defaultp (activity-state) default))
+                   (last (if lastp (activity-state) last))
+                   (props `((handler . activity-bookmark-handler)
+                            (activity . ,(prog1 activity
+                                           (setf (activity-default activity) 
default
+                                                 (activity-last activity) 
last))))))
+        (bookmark-store name props nil)))))
 
 (defun activity-save-all ()
   "Save all active activities' last states.
@@ -350,6 +349,10 @@ closed."
       ;; Not only frame: delete it.
       (delete-frame frame))))
 
+(defun activity-named (name)
+  "Return activity having NAME."
+  (cl-find name (activity-activities) :key #'activity-name :test #'equal))
+
 (defun activity-switch (activity)
   "Switch to ACTIVITY.
 Its STATE is loaded into the current frame.  Does not modify its



reply via email to

[Prev in Thread] Current Thread [Next in Thread]