[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals-release/activities 9de2334d94 011/103: Tabs WIP
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals-release/activities 9de2334d94 011/103: Tabs WIP |
|
Date: |
Tue, 30 Jan 2024 03:57:46 -0500 (EST) |
branch: externals-release/activities
commit 9de2334d948a72f9484cd577a2d6bc418cdba7ec
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Tabs WIP
---
activity-tabs.el | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
activity.el | 55 ++++++++++-----------------------------
2 files changed, 92 insertions(+), 42 deletions(-)
diff --git a/activity-tabs.el b/activity-tabs.el
new file mode 100644
index 0000000000..5492ee97bc
--- /dev/null
+++ b/activity-tabs.el
@@ -0,0 +1,79 @@
+;;; activity-tabs.el --- Integrate activities with tabs -*- lexical-binding:
t; -*-
+
+;; Copyright (C) 2024 Free Software Foundation, Inc.
+
+;; Author: Adam Porter <adam@alphapapa.net>
+;; Keywords: convenience
+;; Version: 0.1-pre
+;; Package-Requires: ((emacs "29.1"))
+
+;; 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 integrates activities with `tab-bar-mode' tabs.
+
+;;; Code:
+
+;;;; Requirements
+
+(require 'activity)
+
+;;;; Customization
+
+(defgroup activity-tabs nil
+ "Integrates activities and tabs."
+ :group 'activity)
+
+(defcustom activity-tabs-before-resume-functions
+ '(activity-tabs-switch-to-tab)
+ "Functions called before resuming an activity.
+Each is called with one argument, the activity."
+ :type 'hook)
+
+(defcustom activity-tabs-prefix "α:"
+ "Prepended to activity names in tabs."
+ :type 'string)
+
+;;;; Mode
+
+;;;###autoload
+(define-minor-mode activity-tabs-mode
+ "Integrate Activity with `tab-bar-mode'.
+When active, activities are opened in new tabs and named
+accordingly."
+ :global t
+ :group 'activity
+ (if activity-tabs-mode
+ (progn
+ (advice-add #'activity-resume :before #'activity-tabs-before-resume))
+ (advice-remove #'activity-resume #'activity-tabs-before-resume)))
+
+;;;; Functions
+
+(defun activity-tabs-before-resume (activity)
+ "Called before resuming ACTIVITY."
+ (run-hook-with-args activity-tabs-before-resume-functions activity))
+
+(defun activity-tabs-switch-to-tab (activity)
+ "Switch to a tab for ACTIVITY."
+ (pcase-let* (((cl-struct activity name) activity)
+ (tab-name (concat activity-tabs-prefix name)))
+ (tab-bar-switch-to-tab tab-name)))
+
+;;;; Footer
+
+(provide 'activity-tabs)
+
+;;; activity-tabs.el ends here
diff --git a/activity.el b/activity.el
index 27a2bb9718..371c3f7491 100644
--- a/activity.el
+++ b/activity.el
@@ -181,6 +181,16 @@ See Info node `(elisp)Window Parameters'. See also option
:value-type (choice (const :tag "Not saved" nil)
(const :tag "Saved" writable))))
+(defcustom activity-after-resume-functions nil
+ "Functions called after resuming an activity.
+Called with one argument, the activity."
+ :type 'hook)
+
+(defcustom activity-before-resume-functions nil
+ "Functions called before resuming an activity.
+Called with one argument, the activity."
+ :type 'hook)
+
(cl-defstruct activity
"FIXME: Docstring."
name default last etc)
@@ -197,7 +207,9 @@ If RESETP (interactively, with universal prefix), reset to
ACTIVITY's default state; otherwise, resume its last state, if
available."
(interactive (list (activity-completing-read) :resetp current-prefix-arg))
- (activity-open activity :state (if resetp 'default 'last)))
+ (run-hook-with-args 'activity-before-resume-functions activity)
+ (activity-open activity :state (if resetp 'default 'last))
+ (run-hook-with-args 'activity-after-resume-functions activity))
(defun activity-suspend (activity)
"Suspend ACTIVITY.
@@ -474,47 +486,6 @@ ignored."
when (buffer-local-boundp variable (current-buffer))
collect (cons variable (buffer-local-value variable
(current-buffer)))))
-;;;; Tabs mode
-
-;; When this mode is active, activities are loaded into `tab-bar-mode'
-;; tabs.
-
-;;;###autoload
-(define-minor-mode activity-tabs-mode
- "Integrate Activity with `tab-bar-mode'.
-When active, activities are opened in new tabs and named
-accordingly."
- :global t
- :group 'activity)
-
-(cl-defmethod activity-open (activity &context (activity-tabs-mode (eql t))
- &key (state 'last))
- "Open ACTIVITY.
-Its STATE is loaded into the current frame. Used when
-ACTIVITY-TABS-MODE is active."
- ;; TODO: Use a hook to optionally open a new frame.
- ;; TODO: Deduplicate this with the method for when the mode is inactive.
- (pcase-let (((cl-struct activity name default last) activity))
- (pcase state
- ('default (activity--windows-set (activity-state-window-state default)))
- ('last (if last
- (activity--windows-set (activity-state-window-state last))
- (activity--windows-set (activity-state-window-state default))
- (message "Activity %S has no last state. Resuming default."
name))))))
-
-(cl-defmethod activity-close (activity &context (activity-tabs-mode (eql t)))
- "Close ACTIVITY.
-Its state is not saved, and its frames, windows, and tabs are
-closed. Used when ACTIVITY-TABS-MODE is active."
- (pcase-let* (((cl-struct activity name) activity)
- (tab (cl-find-if
- (lambda (tab)
- (equal name (activity-name (alist-get 'activity tab))))
- (funcall tab-bar-tabs-function)))
- (tab-name (alist-get 'name tab)))
- ;; TODO: Set tab parameter when resuming.
- (tab-bar-close-tab-by-name tab-name)))
-
;;;; Footer
(provide 'activity)
- [elpa] externals-release/activities 72039e1c5e 081/103: Change: (activities-tabs-face) Use font-lock-function-name-face, (continued)
- [elpa] externals-release/activities 72039e1c5e 081/103: Change: (activities-tabs-face) Use font-lock-function-name-face, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities dc2bf71050 085/103: Merge: (activities-default-name-fn), ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 44df8af7de 089/103: Change: (-discard) Offer current activity as default completion, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 0ea9b84880 088/103: Change: (-switch) Offer current activity as default completion, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 6938717945 090/103: Docs: Update changelog, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 70f75f1d2a 086/103: Fix: (activities-mode) Fix parent group, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities ee788599ba 103/103: Release: v0.3, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 6d2aa1a381 003/103: WIP, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 388f31f686 007/103: WIP, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 2027ede904 001/103: Initial commit, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 9de2334d94 011/103: Tabs WIP,
ELPA Syncer <=
- [elpa] externals-release/activities 10c1a7f629 010/103: WIP, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities a337656530 014/103: WIP, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 003df257af 002/103: WIP, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 3738d539e9 018/103: Add FAQ, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities bf181fa512 019/103: Update FAQ, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities bf84de5214 022/103: WIP (multisession doesn't seem to work with alists, trying persist next), ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities f55b63a1cf 023/103: Seems to work, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 43c4524b47 025/103: Fix: (activity-switch) Set frame name, call make-frame correctly, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities 4bc5b0f757 026/103: Fixes and additions, ELPA Syncer, 2024/01/30
- [elpa] externals-release/activities e0bdd210bd 027/103: Fix, ELPA Syncer, 2024/01/30