aboutsummaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-08-12 14:40:47 +0300
committerAlex Kost <alezost@gmail.com>2015-08-30 18:26:02 +0300
commit25a2839c9dfb72fc4eddf0621b80023f87fc2e2e (patch)
treea64f28cbfc674a4106a1ffad629d0842121e8f05 /emacs
parent43b40c4b152a5d7113e3ee591f9f91a342c8fbac (diff)
downloadpatches-25a2839c9dfb72fc4eddf0621b80023f87fc2e2e.tar
patches-25a2839c9dfb72fc4eddf0621b80023f87fc2e2e.tar.gz
emacs: Add 'guix-package-names'.
* emacs/guix-main.scm (package-names, package-names-lists): New procedures. * emacs/guix-base.el (guix-package-names): New function.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/guix-base.el14
-rw-r--r--emacs/guix-main.scm11
2 files changed, 25 insertions, 0 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 1f4a00ce59..9cec510406 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -191,6 +191,20 @@ If PATH is relative, it is considered to be relative to
"Return a list of names of available lint checkers."
(guix-eval-read (guix-make-guile-expression 'lint-checker-names)))
+(guix-memoized-defun guix-package-names ()
+ "Return a list of names of available packages."
+ (sort
+ ;; Work around <https://github.com/jaor/geiser/issues/64>:
+ ;; list of strings is parsed much slower than list of lists,
+ ;; so we use 'package-names-lists' instead of 'package-names'.
+
+ ;; (guix-eval-read (guix-make-guile-expression 'package-names))
+
+ (mapcar #'car
+ (guix-eval-read (guix-make-guile-expression
+ 'package-names-lists)))
+ #'string<))
+
;;; Buffers and auto updating.
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 191aa8d5cf..341657d931 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -942,3 +942,14 @@ GENERATIONS is a list of generation numbers."
(map (lambda (checker)
(symbol->string (lint-checker-name checker)))
%checkers))
+
+(define (package-names)
+ "Return a list of names of available packages."
+ (delete-duplicates
+ (fold-packages (lambda (pkg res)
+ (cons (package-name pkg) res))
+ '())))
+
+;; See the comment to 'guix-package-names' function in "guix-popup.el".
+(define (package-names-lists)
+ (map list (package-names)))