* lisp/ob-fortran.el: Add support for :prologue/:epilogue parameters

(org-babel-expand-body:fortran):
This commit is contained in:
Ihor Radchenko 2023-10-19 11:58:39 +03:00
parent 936290fe18
commit 67bd4b0a36
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 11 additions and 2 deletions

View File

@ -85,6 +85,8 @@ This function is called by `org-babel-execute-src-block'."
(defun org-babel-expand-body:fortran (body params)
"Expand a fortran BODY according to its header arguments defined in PARAMS."
(let ((vars (org-babel--get-vars params))
(prologue (cdr (assq :prologue params)))
(epilogue (cdr (assq :epilogue params)))
(main-p (not (string= (cdr (assq :main params)) "no")))
(includes (or (cdr (assq :includes params))
(org-babel-read (org-entry-get nil "includes" t))))
@ -107,9 +109,16 @@ This function is called by `org-babel-execute-src-block'."
(concat
;; variables
(mapconcat 'org-babel-fortran-var-to-fortran vars "\n")
body)
(and prologue (concat prologue "\n"))
body
(and prologue (concat prologue "\n")))
params)
body) "\n") "\n")))
(concat
(and prologue (concat prologue "\n"))
body
(and epilogue (concat "\n" epilogue "\n"))))
"\n")
"\n")))
(defun org-babel-fortran-ensure-main-wrap (body params)
"Wrap BODY in a \"program ... end program\" block if none exists.