summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-08-27 17:50:01 +0300
committerAlex Kost <alezost@gmail.com>2015-08-27 17:50:01 +0300
commitf2638f0b379c69737ed3ff84a73d8eb16a5a6134 (patch)
tree31643e91433006d87343ead519fd52900bc25563 /emacs
parent89949e8f54ecd76ce08e1d56dc65ab906c1b2d36 (diff)
downloadguix-f2638f0b379c69737ed3ff84a73d8eb16a5a6134.tar.gz
emacs: Add completions for 'guix graph'.
* emacs/guix-pcomplete.el (guix-pcomplete-parse-linter-regexp): Improve
  and rename to ...
  (guix-pcomplete-parse-list-regexp): ...this.  New variable.
  (guix-pcomplete-lint-checkers): Use it.
  (guix-pcomplete-graph-types): New function.
  (guix-pcomplete-complete-command-arg): Complete package names for
  'guix graph' command.
  (guix-pcomplete-complete-option-arg): Complete '-t/--type' option.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/guix-pcomplete.el24
1 files changed, 18 insertions, 6 deletions
diff --git a/emacs/guix-pcomplete.el b/emacs/guix-pcomplete.el
index cad19662dd..9ec563cf52 100644
--- a/emacs/guix-pcomplete.el
+++ b/emacs/guix-pcomplete.el
@@ -54,9 +54,10 @@ guix subcommand, system action, importer, etc.")
       "-" (group (not (any "- "))))
   "Regexp used to find short options.")
 
-(defvar guix-pcomplete-parse-linter-regexp
-  (rx bol "- " (group (one-or-more (or wordchar "-"))))
-  "Regexp used to find 'lint' checkers.")
+(defvar guix-pcomplete-parse-list-regexp
+  (rx bol (zero-or-more blank) "- "
+      (group (one-or-more (or wordchar "-"))))
+  "Regexp used to find various lists (lint checkers, graph types).")
 
 (defvar guix-pcomplete-parse-regexp-group 1
   "Parenthesized expression of regexps used to find commands and
@@ -169,10 +170,17 @@ subcommands, actions, etc. for this guix COMMAND."
 (guix-memoized-defun guix-pcomplete-lint-checkers ()
   "Return a list of all available lint checkers."
   (guix-pcomplete-run-guix-and-search
-   guix-pcomplete-parse-linter-regexp
+   guix-pcomplete-parse-list-regexp
    guix-pcomplete-parse-regexp-group
    "lint" "--list-checkers"))
 
+(guix-memoized-defun guix-pcomplete-graph-types ()
+  "Return a list of all available graph types."
+  (guix-pcomplete-run-guix-and-search
+   guix-pcomplete-parse-list-regexp
+   guix-pcomplete-parse-regexp-group
+   "graph" "--list-types"))
+
 
 ;;; Completing
 
@@ -254,8 +262,8 @@ group - the argument.")
   "Complete argument for guix COMMAND."
   (cond
    ((member command
-            '("archive" "build" "edit" "environment" "lint" "refresh"
-              "size"))
+            '("archive" "build" "graph" "edit" "environment"
+              "lint" "refresh" "size"))
     (while t
       (pcomplete-here (guix-pcomplete-all-packages))))
    (t (pcomplete-here* (pcomplete-entries)))))
@@ -311,6 +319,10 @@ INPUT is the current partially completed string."
            (option? "-r" "--root"))
       (complete* (pcomplete-entries)))
 
+     ((and (command? "graph")
+           (option? "-t" "--type"))
+      (complete* (guix-pcomplete-graph-types)))
+
      ((and (command? "environment")
            (option? "-l" "--load"))
       (complete* (pcomplete-entries)))