guix-external.el 3.0 KB

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