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

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

[elpa] externals-release/activities d9d474c48e 101/103: Add: (activities


From: ELPA Syncer
Subject: [elpa] externals-release/activities d9d474c48e 101/103: Add: (activities-list)
Date: Tue, 30 Jan 2024 03:57:55 -0500 (EST)

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

    Add: (activities-list)
---
 README.org         |  1 +
 activities-list.el | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 activities.info    | 12 ++++---
 3 files changed, 105 insertions(+), 5 deletions(-)

diff --git a/README.org b/README.org
index 20f12e9563..27ffd1787b 100644
--- a/README.org
+++ b/README.org
@@ -119,6 +119,7 @@ When option ~activities-bookmark-store~ is enabled, an 
Emacs bookmark is stored
 ** v0.3-pre
 
 *Additions*
++ Command ~activities-list~ lists activities in a ~vtable~ buffer in which 
they can be managed.
 + Offer current activity name by default when redefining an activity with 
~activities-new~.
 + Record times at which activities' states were updated.
 
diff --git a/activities-list.el b/activities-list.el
new file mode 100644
index 0000000000..13b7c5eac2
--- /dev/null
+++ b/activities-list.el
@@ -0,0 +1,97 @@
+;;; activities-list.el --- List activities           -*- lexical-binding: t; 
-*-
+
+;; Copyright (C) 2024  Free Software Foundation, Inc.
+
+;; Author: Adam Porter <adam@alphapapa.net>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library implements a list view for activities.
+
+;;; Code:
+
+(require 'map)
+(require 'vtable)
+
+(require 'activities)
+
+(defgroup activities-list nil
+  "Activities list buffer."
+  :group 'activities)
+
+(defcustom activities-list-time-format "%c"
+  "Time format for `activities-list' buffer."
+  :type 'string)
+
+(defmacro activities-list-command (command)
+  "Expand to a lambda that applies its args to COMMAND and reverts the list 
buffer."
+  `(lambda (&rest args)
+     (let ((list-buffer (current-buffer)))
+       (apply #',command args)
+       (with-current-buffer list-buffer
+         (vtable-revert)))))
+
+;;;###autoload
+(defun activities-list ()
+  "List activities."
+  (interactive)
+  (with-current-buffer (get-buffer-create "*Activities*")
+    (let ((inhibit-read-only t))
+      (read-only-mode)
+      (erase-buffer)
+      (make-vtable
+       :columns
+       `(( :name "Active" :primary descend
+           :getter (lambda (object _table)
+                     (if (activities-activity-active-p object)
+                         "*" " ")))
+         ( :name "Name"
+           :getter (lambda (object _table)
+                     (activities-activity-name object)))
+         ( :name "Last saved"
+           :getter (lambda (activity _table)
+                     (or (map-elt (activities-activity-state-etc 
(activities-activity-last activity)) 'time)
+                         0))
+           :formatter activities-list--format-time)
+         ( :name "Default saved"
+           :getter (lambda (activity _table)
+                     (or (map-elt (activities-activity-state-etc 
(activities-activity-default activity)) 'time)
+                         0))
+           :formatter activities-list--format-time))
+       :objects-function (lambda ()
+                           (map-values activities-activities))
+       :sort-by '((2 . ascend) (0 . descend))
+       :actions `("q" (lambda (&rest _) (bury-buffer))
+                  "n" (lambda (&rest _) (forward-line 1))
+                  "p" (lambda (&rest _) (forward-line -1))
+                  "RET" ,(activities-list-command activities-resume)
+                  "k" ,(activities-list-command activities-kill)
+                  "s" ,(activities-list-command activities-suspend)
+                  "D" ,(activities-list-command activities-discard)))
+      (pop-to-buffer (current-buffer)))))
+
+;;;###autoload
+(defalias 'list-activities #'activities-list)
+
+(defun activities-list--format-time (time)
+  "Return TIME formatted according to `activities-list-time-format', which 
see.."
+  (format-time-string activities-list-time-format time))
+
+;;;; Footer
+
+(provide 'activities-list)
+
+;;; activities-list.el ends here
diff --git a/activities.info b/activities.info
index 4f57cd21e4..47bc9c0f0a 100644
--- a/activities.info
+++ b/activities.info
@@ -322,6 +322,8 @@ File: README.info,  Node: v03-pre,  Next: v02,  Up: 
Changelog
 ============
 
 *Additions*
+   • Command ‘activities-list’ lists activities in a ‘vtable’ buffer in
+     which they can be managed.
    • Offer current activity name by default when redefining an activity
      with ‘activities-new’.
    • Record times at which activities’ states were updated.
@@ -393,11 +395,11 @@ Node: Bookmarks8301
 Node: FAQ8653
 Node: Changelog11729
 Node: v03-pre11920
-Node: v0212195
-Node: v01312691
-Node: v01212840
-Node: v01113017
-Node: v0113180
+Node: v0212309
+Node: v01312805
+Node: v01212954
+Node: v01113131
+Node: v0113294
 
 End Tag Table
 



reply via email to

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