[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/20: emacs: Add and use 'guix-concat-strings'.
From: |
Alex Kost |
Subject: |
05/20: emacs: Add and use 'guix-concat-strings'. |
Date: |
Tue, 18 Aug 2015 09:41:09 +0000 |
alezost pushed a commit to branch wip-emacs-popup-ui
in repository guix.
commit 522c86b1538fde7eab042d86794fd4aadf5f1d6c
Author: Alex Kost <address@hidden>
Date: Wed Aug 12 15:44:22 2015 +0300
emacs: Add and use 'guix-concat-strings'.
* emacs/guix-utils.el (guix-concat-strings): New function.
* emacs/guix-pcomplete.el (guix-pcomplete-short-options): Use it.
* emacs/guix-base.el (guix-get-package-strings): Likewise.
---
emacs/guix-base.el | 2 +-
emacs/guix-pcomplete.el | 2 +-
emacs/guix-utils.el | 16 ++++++++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 7ec68ec..2a59a5b 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -947,7 +947,7 @@ ENTRIES is a list of package entries to get info about
packages."
(concat (guix-get-full-name entry)
(when outputs
(concat ":"
- (mapconcat #'identity outputs ",")))
+ (guix-concat-strings outputs ",")))
(when location
(concat "\t(" location ")")))))))
specs)))
diff --git a/emacs/guix-pcomplete.el b/emacs/guix-pcomplete.el
index 99bc29f..fe1b1ef 100644
--- a/emacs/guix-pcomplete.el
+++ b/emacs/guix-pcomplete.el
@@ -146,7 +146,7 @@ subcommands, actions, etc. for this guix COMMAND."
"Return a string with available short options for guix COMMAND."
guix-pcomplete-parse-short-option-regexp
(lambda (list)
- (mapconcat #'identity list "")))
+ (guix-concat-strings list "")))
(guix-memoized-defun guix-pcomplete-all-packages ()
"Return a list of all available Guix packages."
diff --git a/emacs/guix-utils.el b/emacs/guix-utils.el
index 8a0673a..df6636c 100644
--- a/emacs/guix-utils.el
+++ b/emacs/guix-utils.el
@@ -128,6 +128,22 @@ split it into several short lines."
(fill-region (point-min) (point-max)))
(buffer-string)))
+(defun guix-concat-strings (strings separator &optional location)
+ "Return new string by concatenating STRINGS with SEPARATOR.
+If LOCATION is a symbol `head', add another SEPARATOR to the
+beginning of the returned string; if `tail' - add SEPARATOR to
+the end of the string; if nil, do not add SEPARATOR; otherwise
+add both to the end and to the beginning."
+ (let ((str (mapconcat #'identity strings separator)))
+ (cond ((null location)
+ str)
+ ((eq location 'head)
+ (concat separator str))
+ ((eq location 'tail)
+ (concat str separator))
+ (t
+ (concat separator str separator)))))
+
(defun guix-completing-read-multiple (prompt table &optional predicate
require-match initial-input
hist def inherit-input-method)
- branch wip-emacs-popup-ui created (now 2392984), Alex Kost, 2015/08/18
- 01/20: guix lint: Export checkers and <lint-checker> accessors., Alex Kost, 2015/08/18
- 03/20: emacs: Add 'guix-package-names'., Alex Kost, 2015/08/18
- 05/20: emacs: Add and use 'guix-concat-strings'.,
Alex Kost <=
- 04/20: emacs: Add and use 'guix-while-search'., Alex Kost, 2015/08/18
- 06/20: emacs: Add utils to make symbol and string for guix command., Alex Kost, 2015/08/18
- 08/20: emacs: Add 'guix-any'., Alex Kost, 2015/08/18
- 09/20: emacs: Add 'guix-memoized-defalias' macro., Alex Kost, 2015/08/18
- 13/20: ui: Add 'run-guix'., Alex Kost, 2015/08/18
- 02/20: emacs: Add 'guix-lint-checker-names'., Alex Kost, 2015/08/18
- 14/20: emacs: Add code to run guix command in REPL., Alex Kost, 2015/08/18
- 10/20: emacs: Add help variables., Alex Kost, 2015/08/18
- 07/20: emacs: Add utils to copy guix command., Alex Kost, 2015/08/18
- 15/20: emacs: Add code to run guix command in shell., Alex Kost, 2015/08/18