summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-08-16 13:55:25 +0300
committerAlex Kost <alezost@gmail.com>2015-08-30 18:26:02 +0300
commit7008dffff52b59bb37361e72f4319977a91db2f1 (patch)
treee494a065cfbf07c302720b1095c2ece4199e3a93 /emacs
parent5e53b0c5a9e1c693d46bdaf24e6b5ce498410da6 (diff)
emacs: Add code to run guix command in shell.
* emacs/guix-base.el (guix-run-in-shell, guix-run-in-eshell, guix-run-command-in-shell): New functions. (guix-run-in-shell-function, guix-shell-buffer-name): New variables.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/guix-base.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index d1593e285d..4dff0d6170 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -1087,6 +1087,42 @@ FILE. With a prefix argument, also prompt for PROFILE."
;;; Executing guix commands
+(defcustom guix-run-in-shell-function #'guix-run-in-shell
+ "Function used to run guix command.
+The function is called with a single argument - a command line string."
+ :type '(choice (function-item guix-run-in-shell)
+ (function-item guix-run-in-eshell)
+ (function :tag "Other function"))
+ :group 'guix)
+
+(defcustom guix-shell-buffer-name "*shell*"
+ "Default name of a shell buffer used for running guix commands."
+ :type 'string
+ :group 'guix)
+
+(declare-function comint-send-input "comint" t)
+
+(defun guix-run-in-shell (string)
+ "Run command line STRING in `guix-shell-buffer-name' buffer."
+ (shell guix-shell-buffer-name)
+ (goto-char (point-max))
+ (insert string)
+ (comint-send-input))
+
+(declare-function eshell-send-input "esh-mode" t)
+
+(defun guix-run-in-eshell (string)
+ "Run command line STRING in eshell buffer."
+ (eshell)
+ (goto-char (point-max))
+ (insert string)
+ (eshell-send-input))
+
+(defun guix-run-command-in-shell (args)
+ "Execute 'guix ARGS ...' command in a shell buffer."
+ (funcall guix-run-in-shell-function
+ (guix-command-string args)))
+
(defun guix-run-command-in-repl (args)
"Execute 'guix ARGS ...' command in Guix REPL."
(guix-eval-in-repl