[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/rec-mode 0731ca5 11/98: ob-rec.el imported in the repo.
From: |
Stefan Monnier |
Subject: |
[elpa] externals/rec-mode 0731ca5 11/98: ob-rec.el imported in the repo. |
Date: |
Thu, 12 Nov 2020 13:18:30 -0500 (EST) |
branch: externals/rec-mode
commit 0731ca5a851f66b2c6f426ac8d4bc62ecc303e37
Author: Jose E. Marchesi <jemarch@gnu.org>
Commit: Antoine Kalmbach <ane@iki.fi>
ob-rec.el imported in the repo.
---
etc/ob-rec.el | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/etc/ob-rec.el b/etc/ob-rec.el
new file mode 100644
index 0000000..390f64c
--- /dev/null
+++ b/etc/ob-rec.el
@@ -0,0 +1,65 @@
+;;; ob-rec.el --- org-babel functions for recutils evaluation
+
+;; Copyright (C) 2011 Free Software Foundation
+
+;; Author: Jose E. Marchesi
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+;; Version: 7.4
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating recsel queries and substituing the
+;; contained template. See http://www.gnu.org/software/recutils/
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-default-header-args:rec
+ '((:exports . "results")))
+
+(defun org-babel-execute:rec (body params)
+ "Execute a block containing a recsel query.
+This function is called by `org-babel-execute-src-block'."
+ (let* ((in-file ((lambda (el)
+ (or el
+ (error
+ "rec code block requires :data header argument")))
+ (cdr (assoc :data params))))
+ (cmdline (cdr (assoc :cmdline params)))
+ (rec-type (cdr (assoc :type params)))
+ (fields (cdr (assoc :fields params)))
+ (cmd (concat "recsel"
+ (when rec-type (concat " -t " rec-type " "))
+ " " (expand-file-name in-file)
+ (when (> (length (org-babel-trim body)) 0)
+ (concat " -e " "\""
+ (replace-regexp-in-string "\"" "\\\\\"" body)
+ "\""))
+ (when fields (concat " -p " fields " "))
+ " | rec2csv")))
+ (with-temp-buffer
+ (shell-command cmd (current-buffer))
+ (if (or (member "scalar" result-params)
+ (member "html" result-params)
+ (member "code" result-params)
+ (equal (point-min) (point-max)))
+ (buffer-string)
+ (org-table-convert-region (point-min) (point-max) '(4))
+ (org-table-to-lisp)))))
+
+(provide 'ob-rec)
+
+;; ob-rec.el ends here
- [elpa] branch externals/rec-mode created (now d0e8456), Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 1f0916b 02/98: Trailing blanks removed., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 785b4b8 04/98: misc changes to rec-mode.el, Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 969c03a 01/98: experimental/rec-mode.el renamed to etc/rec-mode.el, Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 0731ca5 11/98: ob-rec.el imported in the repo.,
Stefan Monnier <=
- [elpa] externals/rec-mode a1e21e1 14/98: Added %typedef to the list of keywords., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 06ec5c5 17/98: ob-rec: support for :sort and minor fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 2f8aa87 16/98: ob-rec: support for :sort and minor fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode fbd02a9 24/98: rec-mode: field names are no longer lists of parts., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 0b52532 18/98: ob-rec: support for :sort and minor fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 18e9e4a 23/98: rec-mode: editing of individual fields now works., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 424eb72 25/98: rec-mode: fixes in goto-type and show-type., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode f063506 26/98: rec-mode: misc small fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 0f09c3f 33/98: rec-mode: support editing boolean fields as special enum values., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 3e47acf 05/98: rec-mode improvements., Stefan Monnier, 2020/11/12