Home / Emacs / Org Babel / Patches
TODO Org Babel: Contribute an execute function for (GNU/BSD) Make
(with-eval-after-load 'org
(defun org-babel-execute:makefile-gmake (body params)
"Execute BODY with GNU Makefile code using Org Babel.
PARAMS is a plist of src block parameters.
This function is called by `org-babel-execute-src-block'."
(let ((input-file (let ((file (org-babel-temp-file "make-input")))
(with-temp-file file (insert body))
file)))
(when-let* ((results
(with-temp-buffer
;; TODO use process-lines
(call-process "gmake"
nil
(current-buffer)
nil
"-f"
input-file)
(buffer-substring-no-properties (point-min)
(point-max)))))
(let ((clean-results (string-replace input-file "Makefile" results)))
(org-babel-reassemble-table
(org-babel-result-cond (cdr (assq :result-params params))
clean-results
(org-babel-import-elisp-from-file
(let ((output-file (org-babel-temp-file "make-output-")))
(with-temp-file output-file (insert clean-results))
output-file)))
(org-babel-pick-name (cdr (assq :colname-names params))
(cdr (assq :colnames params)))
(org-babel-pick-name (cdr (assq :rowname-names params))
(cdr (assq :rownames params)))))))))
(add-to-list 'org-babel-load-languages '(makefile-gmake t))