branch: externals/el-job
commit 5c28a27d993c295527e9fa6c0b5d833a9bdcc1f7
Author: Martin Edström <[email protected]>
Commit: Martin Edström <[email protected]>
Some new function names
---
README.org | 7 -------
el-job.el | 39 +++++++++++++++++++++++++--------------
2 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/README.org b/README.org
index 216b45185a..886805f23e 100644
--- a/README.org
+++ b/README.org
@@ -7,13 +7,6 @@ This library is a tool to split up the inputs and run the
function in many subpr
For real-world usage, search for =el-job-launch= in the source of
[[https://github.com/meedstrom/org-node/blob/main/org-node.el][org-node.el]].
-** News
-
-Still in a development honeymoon, API unstable.
-
-- [2024-11-14 Thu 18:14]
- - Version 0.3.0: Everything changed, so read the docstring again :-)
-
** Limitations
1. Will *drop support for Emacs 28/29* sometime in mid-2025 (when Debian
trixie is released). For a backwards-compatible library, try
[[https://github.com/jwiegley/emacs-async][async.el]].
diff --git a/el-job.el b/el-job.el
index 2a4d189759..eeb38e272f 100644
--- a/el-job.el
+++ b/el-job.el
@@ -765,7 +765,23 @@ Prevent its sentinel and filter from reacting."
(kill-buffer buf)))
-;;; Tools; maybe bless some as public API?
+;;; Tools
+
+(defun el-job--all-processes (job)
+ "Return all processes for JOB, busy and ready."
+ (append (el-job:busy job) (el-job:ready job)))
+
+(defun el-job-show ()
+ "Prompt for a job and show its metadata in a new buffer."
+ (interactive)
+ (let* ((id (intern (completing-read "Get info on job: " el-jobs)))
+ (job (gethash id el-jobs)))
+ (when job
+ (switch-to-buffer (get-buffer-create "*el-job*" t))
+ (erase-buffer)
+ (cl-prin1 job (current-buffer))
+ ;; Never print the above into echo area
+ t)))
(defun el-job-kill-all ()
"Kill all el-jobs and forget metadata."
@@ -775,21 +791,13 @@ Prevent its sentinel and filter from reacting."
(remhash id el-jobs))
el-jobs))
-(defun el-job--all-processes (job)
- "Return all processes for JOB, busy and ready."
- (append (el-job:busy job) (el-job:ready job)))
+(defun el-job-await (id timeout &optional message)
+ "Block until all processes for job ID finished, then return t.
-(defun el-job--show ()
- "Prompt for a job and show its metadata in a new buffer."
- (interactive)
- (let ((id (intern (completing-read "Get info on job: " el-jobs))))
- (with-current-buffer (get-buffer-create "*el-job*" t)
- (erase-buffer)
- (switch-to-buffer (current-buffer))
- (cl-prin1 (gethash id el-jobs) (current-buffer)))
- t))
+If the job has still not finished after TIMEOUT seconds, stop
+blocking and return nil.
-(defun el-job--await (id timeout &optional message)
+Meanwhile, ensure string MESSAGE is visible in the minibuffer."
(let ((deadline (time-add (current-time) timeout)))
(catch 'timeout
(while (el-job-is-busy id)
@@ -806,6 +814,9 @@ Safely return nil otherwise, whether or not ID is known."
(when-let ((job (gethash id el-jobs)))
(el-job:busy job)))
+(define-obsolete-function-alias 'el-job--await 'el-job-await "2024-12-29")
+(define-obsolete-function-alias 'el-job--show 'el-job-show "2024-12-29")
+
(provide 'el-job)
;;; el-job.el ends here