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

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

[elpa] externals-release/activities 8afee346ab 084/103: Add: (activities


From: ELPA Syncer
Subject: [elpa] externals-release/activities 8afee346ab 084/103: Add: (activities-default-name-fn) And use as default activity name
Date: Tue, 30 Jan 2024 03:57:54 -0500 (EST)

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

    Add: (activities-default-name-fn) And use as default activity name
---
 README.org      |  3 ++-
 activities.el   | 23 +++++++++++++++++++----
 activities.info | 12 +++++++-----
 3 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/README.org b/README.org
index 5621688e1f..7c0bf6f176 100644
--- a/README.org
+++ b/README.org
@@ -118,7 +118,8 @@ When option ~activities-bookmark-store~ is enabled, an 
Emacs bookmark is stored
 
 ** v0.2-pre
 
-Nothing new yet.
+*Additions*
++ Offer current ~project~ name by default for new activities.  (Thanks to 
[[https://github.com/josephmturner][Joseph Turner]].)
 
 ** v0.1.3
 
diff --git a/activities.el b/activities.el
index a72524cad2..97d93e5ab0 100644
--- a/activities.el
+++ b/activities.el
@@ -260,17 +260,23 @@ Called with one argument, the activity."
 Called with one argument, the activity."
   :type 'hook)
 
+(defcustom activities-default-name-fn 'activities--project-name
+  "Function that returns the default name for a new activity.
+The string should not be prefixed by, e.g. \"Activity\" because
+prefixes will be added automatically."
+  :type '(choice (const :tag "No default name" (lambda (&rest _) nil))
+                 (const :tag "Current project's name" activities--project-name)
+                 (function-item :tag "Other function")))
+
 ;;;; Commands
 
 ;;;###autoload
 (cl-defun activities-new (name &key forcep)
   "Save current state as a new activity with NAME.
 If FORCEP (interactively, with prefix), overwrite existing
-activity.  Interactively, NAME defaults to the current
-`project.el' project's name, if any."
+activity."
   (interactive
-   (let ((default (when-let ((proj (project-current)))
-                    (project-name proj))))
+   (let ((default (funcall activities-default-name-fn)))
      (list (read-string (format-prompt "New activity name" default) nil nil 
default)
            :forcep current-prefix-arg)))
   (when (and (not forcep) (member name (activities-names)))
@@ -644,6 +650,15 @@ PROMPT is passed to `completing-read', which see."
 Adds `activities-name-prefix'."
   (concat activities-name-prefix (activities-activity-name activity)))
 
+;;;; Project support
+
+(declare-function project-name "project")
+(defun activities--project-name ()
+  "Return the name of the current project, if any."
+  (require 'project)
+  (when-let ((project (project-current)))
+    (project-name project)))
+
 ;;;; Bookmark support
 
 (defun activities-bookmark-store (activity)
diff --git a/activities.info b/activities.info
index 17f3b3fd12..3bf7cf6e54 100644
--- a/activities.info
+++ b/activities.info
@@ -319,7 +319,9 @@ File: README.info,  Node: v02-pre,  Next: v013,  Up: 
Changelog
 4.1 v0.2-pre
 ============
 
-Nothing new yet.
+*Additions*
+   • Offer current ‘project’ name by default for new activities.
+     (Thanks to Joseph Turner (https://github.com/josephmturner).)
 
 
 File: README.info,  Node: v013,  Next: v012,  Prev: v02-pre,  Up: Changelog
@@ -372,10 +374,10 @@ Node: Bookmarks8288
 Node: FAQ8640
 Node: Changelog11716
 Node: v02-pre11894
-Node: v01312005
-Node: v01212158
-Node: v01112335
-Node: v0112498
+Node: v01312138
+Node: v01212291
+Node: v01112468
+Node: v0112631
 
 End Tag Table
 



reply via email to

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