branch: externals/el-job
commit 94ce2730e0e7d90fc6c5849e91ead580c50e9c9e
Author: Martin Edström <[email protected]>
Commit: Martin Edström <[email protected]>
Add 3 new API functions
---
el-job-ng.el | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/el-job-ng.el b/el-job-ng.el
index 349a3bd203..1296c0cc42 100644
--- a/el-job-ng.el
+++ b/el-job-ng.el
@@ -400,6 +400,19 @@ A typical TEST would check if something in the environment
has changed."
MAX-SECS and MESSAGE as in `el-job-ng-sit-until'."
(el-job-ng-sit-until (el-job-ng-ready-p id) max-secs message))
+(defun el-job-ng-await-or-die (id max-secs &optional message)
+ "Like `el-job-ng-await', but kill the job on timeout or any signal.
+Otherwise, a keyboard quit would let it continue in the background."
+ (condition-case signal
+ (if (el-job-ng-await id max-secs message)
+ t
+ (el-job-ng-kill-keep-bufs id)
+ nil)
+ (t
+ (el-job-ng-kill id)
+ (apply #'signal signal)
+ nil)))
+
(defun el-job-ng-ready-p (id)
"Return t if job ID is not currently active."
(not (el-job-ng-busy-p id)))
@@ -494,6 +507,25 @@ EVAL, INPUTS, FUNCALL-PER-INPUT, CALLBACK)."
(when callback
(funcall callback .outputs))))))
+(define-obsolete-function-alias 'el-job-ng-job 'el-job-ng-get-job "2026-01-22")
+(defun el-job-ng-get-job (id-or-process)
+ (if (processp id-or-process)
+ (cl-loop for job being each hash-value of el-job-ng--jobs
+ when (memq id-or-process (el-job-ng--processes job))
+ return job)
+ (gethash id-or-process el-job-ng--jobs)))
+
+(defun el-job-ng-vars (mixed-list &optional scope)
+ "Replace each symbol in MIXED-LIST with a cons cell \(SYMBOL . VALUE\).
+If SYMBOL is nil or not bound, it is dropped.
+Uses `symbol-value' to get VALUE.
+If an element of MIXED-LIST is already a cons cell, it is kept as-is."
+ (cl-loop for var in mixed-list
+ if (and var (symbolp var) (boundp var))
+ ;; REVIEW: Not sure about the scope thing
+ collect (cons var (if scope (eval var t) (symbol-value var)))
+ else collect var))
+
(provide 'el-job-ng)
;;; el-job-ng.el ends here