gnu: Add BiocGenerics.
[jackhill/guix/guix.git] / emacs / guix-external.el
CommitLineData
70fabd49
AK
1;;; guix-external.el --- External programs -*- lexical-binding: t -*-
2
3;; Copyright © 2015 Alex Kost <alezost@gmail.com>
4
5;; This file is part of GNU Guix.
6
7;; GNU Guix is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Guix is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;; This file provides auxiliary code for running external programs.
23
24;;; Code:
25
51805219
AK
26(require 'guix-config)
27
70fabd49
AK
28(defgroup guix-external nil
29 "Settings for external programs."
30 :group 'guix)
31
38056615
AK
32(defcustom guix-guile-program guix-config-guile-program
33 "Name of the 'guile' executable used for Guix REPL.
34May be either a string (the name of the executable) or a list of
35strings of the form:
36
37 (NAME . ARGS)
38
39Where ARGS is a list of arguments to the guile program."
40 :type 'string
41 :group 'guix-external)
42
51805219
AK
43(defcustom guix-dot-program
44 (if (file-name-absolute-p guix-config-dot-program)
45 guix-config-dot-program
46 (executable-find "dot"))
70fabd49
AK
47 "Name of the 'dot' executable."
48 :type 'string
49 :group 'guix-external)
50
51(defcustom guix-dot-default-arguments
52 '("-Tpng")
53 "Default arguments for 'dot' program."
54 :type '(repeat string)
55 :group 'guix-external)
56
57(defcustom guix-dot-file-name-function #'guix-png-file-name
58 "Function used to define a file name of a temporary 'dot' file.
59The function is called without arguments."
60 :type '(choice (function-item guix-png-file-name)
61 (function :tag "Other function"))
62 :group 'guix-external)
63
64(defun guix-dot-arguments (output-file &rest args)
65 "Return a list of dot arguments for writing a graph into OUTPUT-FILE.
66If ARGS is nil, use `guix-dot-default-arguments'."
67 (or guix-dot-program
68 (error (concat "Couldn't find 'dot'.\n"
69 "Set guix-dot-program to a proper value")))
70 (apply #'list
71 guix-dot-program
72 (concat "-o" output-file)
73 (or args guix-dot-default-arguments)))
74
75(defun guix-dot-file-name ()
76 "Call `guix-dot-file-name-function'."
77 (funcall guix-dot-file-name-function))
78
79(defun guix-png-file-name ()
80 "Return '.png' file name in the `temporary-file-directory'."
81 (concat (make-temp-name
82 (concat (file-name-as-directory temporary-file-directory)
7c0b02f5 83 "guix-emacs-graph-"))
70fabd49
AK
84 ".png"))
85
86(provide 'guix-external)
87
88;;; guix-external.el ends here