Function: projection-multi-embark--set-command-wrapper

projection-multi-embark--set-command-wrapper is a macro defined in projection-multi-embark.el.

Signature

(projection-multi-embark--set-command-wrapper TYPE)

Documentation

Define embark commands for setting project commands for TYPE.

Source Code

;; Defined in /nix/store/cgdc0fkc4kbckjkfirzz40zlqs56d2gg-emacs-packages-deps/share/emacs/site-lisp/elpa/projection-multi-embark-20241107.2107/projection-multi-embark.el
(defmacro projection-multi-embark--set-command-wrapper (type)
  "Define embark commands for setting project commands for TYPE."
  (let ((func-name (intern (concat "projection-multi-embark-set-" (symbol-name type) "-command-dwim")))
        (raw-func-name (intern (concat "projection-multi-embark-set-" (symbol-name type) "-command")))
        (default-func-name (intern (concat "projection-commands-set-" (symbol-name type) "-command")))
        (projection-multi-embark--custom-property 'projection-set-command-callback))
    `(progn
       (defun ,func-name (command &optional set-raw)
         ,(format "Set %s command for the current project to COMMAND intelligently.
Command should be a shell command string. As a special case COMMAND if
having a property `%s'
will have that property called with key-args of :type, :command and :project.
For convenience all other text-properties of COMMAND will be passed as keyword
arguments to the special property.

Pass SET-RAW to always set `%s' command to COMMAND directly."
                  type projection-multi-embark--custom-property type)
         (let ((project (projection--current-project)))
           (if-let* ((should-not-set-raw (not set-raw))
                     (command-is-string (stringp command))
                     (set-command-property
                      (get-text-property 0 ',projection-multi-embark--custom-property command)))
               (apply set-command-property
                      (append
                       (list :type ',type
                             :command command
                             :project project)
                       (cl-loop for prop being the elements of (text-properties-at 0 command)
                                using (index i)
                                when (eq (% i 2) 0)
                                collect (intern (concat ":" (symbol-name prop)))
                                else
                                collect prop)))
             (funcall #',default-func-name command project))))

       (defun ,raw-func-name (command)
         ,(format "Set %s command for the current project to COMMAND."
                  type)
         (,func-name command 'set-raw)))))