I am completely new to this mailing list, and in fact to elisp. I am
an user of org-babel, and in particular use a lot of fortran code
One annoyance is that these blocks were not supporting the :libs
header: I had to tangle the code and compile it by hand.
After asking for a solution in emacs-reddit
I was suggested to try to contribute with a patch.
Here it is. Since it is the first time that I do something like this,
please let me know if something is wrong or not done correctly.
Thanks to all for the awesome org-mode!
>From 5c42f43bc2c1e95a54e0bee0f7f97e4d673238e9 Mon Sep 17 00:00:00 2001
From: Alberto Ramos
Date: Fri, 27 Sep 2019 23:11:02 +0100
Subject: [PATCH] ob-fortran.el: Add support for :libs header
lisp/ob-fortran.el: Add support for :libs header in fortran code
lisp/ob-fortran.el | 16 ++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/lisp/ob-fortran.el b/lisp/ob-fortran.el
index f1285f6ab..6e3421a75 100644
@@ -40,6 +40,10 @@
(defvar org-babel-default-header-args:fortran '())
+(defconst org-babel-header-args:fortran '((libs. :any))
+ "Fortran-specific header arguments.")
(defvar org-babel-fortran-compiler "gfortran"
"fortran command used to compile a fortran source code file into an
@@ -50,15 +54,23 @@
(tmp-bin-file (org-babel-temp-file "fortran-bin-" org-babel-exeext))
(cmdline (cdr (assq :cmdline params)))
(flags (cdr (assq :flags params)))
+ (libs (org-babel-read
+ (or (cdr (assq :libs params))
+ (org-entry-get nil "libs" t))
+ (libs (mapconcat #'identity
+ (if (listp libs) libs (list libs))
+ " "))
(full-body (org-babel-expand-body:fortran body params)))
(with-temp-file tmp-src-file (insert full-body))
- (format "%s -o %s %s %s"
+ (format "%s -o %s %s %s %s"
(if (listp flags) flags (list flags)) " ")
- (org-babel-process-file-name tmp-src-file)) "")
+ (org-babel-process-file-name tmp-src-file)
+ libs) "")