summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-08-16 11:09:39 +0300
committerAlex Kost <alezost@gmail.com>2015-08-30 18:26:01 +0300
commit009d6388e6ba83d903c9e3756daa71251ca1b8e6 (patch)
tree3a620e77f52640168e040775211098914ec28403 /emacs
parent1ce96dd9271445133b920cff81bbb44085a5fe7c (diff)
emacs: Add utils to make symbol and string for guix command.
* emacs/guix-utils.el (guix-shell-quote-argument, guix-command-symbol, guix-command-string): New functions.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/guix-utils.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/emacs/guix-utils.el b/emacs/guix-utils.el
index df6636c139..68cad8878d 100644
--- a/emacs/guix-utils.el
+++ b/emacs/guix-utils.el
@@ -144,6 +144,25 @@ add both to the end and to the beginning."
(t
(concat separator str separator)))))
+(defun guix-shell-quote-argument (argument)
+ "Quote shell command ARGUMENT.
+This function is similar to `shell-quote-argument', but less strict."
+ (if (equal argument "")
+ "''"
+ (replace-regexp-in-string
+ "\n" "'\n'"
+ (replace-regexp-in-string
+ (rx (not (any alnum "-=,./\n"))) "\\\\\\&" argument))))
+
+(defun guix-command-symbol (&optional args)
+ "Return symbol by concatenating 'guix' and ARGS (strings)."
+ (intern (guix-concat-strings (cons "guix" args) "-")))
+
+(defun guix-command-string (&optional args)
+ "Return 'guix ARGS ...' string with quoted shell arguments."
+ (let ((args (mapcar #'guix-shell-quote-argument args)))
+ (guix-concat-strings (cons "guix" args) " ")))
+
(defun guix-completing-read-multiple (prompt table &optional predicate
require-match initial-input
hist def inherit-input-method)