Function: compile-multi--fill-tasks

compile-multi--fill-tasks is a natively compiled function defined in compile-multi.el.

Signature

(compile-multi--fill-tasks TASKS)

Documentation

Convert TASKS values into shell commands.

Returns a cons cell of the completion target and a plist of task properties. The plist will contain a command and an optional annotation property for task.

Source Code

;; Defined in /nix/store/ax1p6npch7lvclxg5n7cjd3i0dh74vcc-emacs-packages-deps/share/emacs/site-lisp/elpa/compile-multi-20250831.1542/compile-multi.el
(defun compile-multi--fill-tasks (tasks)
  "Convert TASKS values into shell commands.
Returns a cons cell of the completion target and a plist of task properties.
The plist will contain a command and an optional annotation property for task."
  (let (res)
    (dolist (task tasks)
      (cond
       ;; Generate one-or more tasks to replace this task.
       ((functionp task)
        (setq res (append (nreverse
                           (compile-multi--fill-tasks (funcall task)))
                          res)))
       ;; A full command to be called as a standalone task.
       ((stringp (cdr task))
        (push `(,(car task)
                :command ,(cdr task)
                ,@(when compile-multi-annotate-string-cmds
                    (list :annotation (cdr task))))
              res))
       ;; Defer to a lisp-command to compile, not a shell command.
       ;; KLUDGE: I'm not sure about this, it might be a little too hacky.
       ((functionp (cdr task))
        (push `(,(car task)
                :command ,(cdr task)
                :annotation ,(if (eq (car-safe (cdr task)) 'lambda)
                                 "lambda"
                               (format "%s" (cdr task))))
              res))
       ;; Command is a pre-formatted plist, nothing to be done.
       ((and (listp (cdr task))
             (keywordp (cadr task)))
        ;; (cl-assert (plist-get (cdr task) :command) nil
        ;;            "Task %S has a missing command value" task)
        (when-let ((annotation (plist-get (cdr task) :annotation)))
          (plist-put (cdr task) :annotation
                     (when compile-multi-annotate-cmds
                       annotation)))
        (push `(,(car task) ,@(cdr task)) res))
       ;; It's a list that we need to format into a shell-command to run.
       ((listp (cdr task))
        (let ((cmd
               (mapconcat (lambda (it)
                            (or
                             (and (symbolp it)
                                  (let* ((val (or (alist-get it compile-multi-forms)
                                                  it))
                                         (evaluated-value (eval val)))
                                    (unless (stringp evaluated-value)
                                      (error "Failed to stringify task argument %s" val))
                                    evaluated-value))
                             (let ((evaluated-value (eval it)))
                               (unless (stringp evaluated-value)
                                 (error "Failed to stringify task argument %s" it))
                               evaluated-value)))
                          (cdr task) " ")))
          (push `(,(car task)
                  :command ,cmd
                  ,@(when compile-multi-annotate-string-cmds
                      (list :annotation cmd)))
                res)))
       (t (error "Unknown task type: %s" task))))
    (nreverse res)))