emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alberto Ramos <alberto.ramos@maths.tcd.ie>
To: emacs-orgmode@gnu.org
Subject: :libs header in fortran code blocks
Date: Fri, 27 Sep 2019 23:29:27 +0100	[thread overview]
Message-ID: <86lfu9jrug.fsf@maths.tcd.ie> (raw)

[-- Attachment #1: Type: text/plain, Size: 665 bytes --]


  Hi all,

  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
  blocks. 

  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
  (https://www.reddit.com/r/emacs/comments/d8krp0/org_mode_code_blocks_and_libraries/),
  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!

  A.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-fortran.el-Add-support-for-libs-header.patch --]
[-- Type: text/x-patch, Size: 1810 bytes --]

From 5c42f43bc2c1e95a54e0bee0f7f97e4d673238e9 Mon Sep 17 00:00:00 2001
From: Alberto Ramos <alberto.ramos@desy.de>
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
blocks.

TINYCHANGE
---
 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
--- a/lisp/ob-fortran.el
+++ b/lisp/ob-fortran.el
@@ -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
   executable.")
@@ -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))
+		nil))
+	 (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))
     (org-babel-eval
-     (format "%s -o %s %s %s"
+     (format "%s -o %s %s %s %s"
 	     org-babel-fortran-compiler
 	     (org-babel-process-file-name tmp-bin-file)
 	     (mapconcat 'identity
 			(if (listp flags) flags (list flags)) " ")
-	     (org-babel-process-file-name tmp-src-file)) "")
+	     (org-babel-process-file-name tmp-src-file)
+	     libs) "")
     (let ((results
            (org-trim
             (org-remove-indentation
-- 
2.22.0


                 reply	other threads:[~2019-09-27 22:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86lfu9jrug.fsf@maths.tcd.ie \
    --to=alberto.ramos@maths.tcd.ie \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).