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.
This commit is contained in:
parent
89949e8f54
commit
f2638f0b37
|
@ -54,9 +54,10 @@ guix subcommand, system action, importer, etc.")
|
||||||
"-" (group (not (any "- "))))
|
"-" (group (not (any "- "))))
|
||||||
"Regexp used to find short options.")
|
"Regexp used to find short options.")
|
||||||
|
|
||||||
(defvar guix-pcomplete-parse-linter-regexp
|
(defvar guix-pcomplete-parse-list-regexp
|
||||||
(rx bol "- " (group (one-or-more (or wordchar "-"))))
|
(rx bol (zero-or-more blank) "- "
|
||||||
"Regexp used to find 'lint' checkers.")
|
(group (one-or-more (or wordchar "-"))))
|
||||||
|
"Regexp used to find various lists (lint checkers, graph types).")
|
||||||
|
|
||||||
(defvar guix-pcomplete-parse-regexp-group 1
|
(defvar guix-pcomplete-parse-regexp-group 1
|
||||||
"Parenthesized expression of regexps used to find commands and
|
"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 ()
|
(guix-memoized-defun guix-pcomplete-lint-checkers ()
|
||||||
"Return a list of all available lint checkers."
|
"Return a list of all available lint checkers."
|
||||||
(guix-pcomplete-run-guix-and-search
|
(guix-pcomplete-run-guix-and-search
|
||||||
guix-pcomplete-parse-linter-regexp
|
guix-pcomplete-parse-list-regexp
|
||||||
guix-pcomplete-parse-regexp-group
|
guix-pcomplete-parse-regexp-group
|
||||||
"lint" "--list-checkers"))
|
"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
|
;;; Completing
|
||||||
|
|
||||||
|
@ -254,8 +262,8 @@ group - the argument.")
|
||||||
"Complete argument for guix COMMAND."
|
"Complete argument for guix COMMAND."
|
||||||
(cond
|
(cond
|
||||||
((member command
|
((member command
|
||||||
'("archive" "build" "edit" "environment" "lint" "refresh"
|
'("archive" "build" "graph" "edit" "environment"
|
||||||
"size"))
|
"lint" "refresh" "size"))
|
||||||
(while t
|
(while t
|
||||||
(pcomplete-here (guix-pcomplete-all-packages))))
|
(pcomplete-here (guix-pcomplete-all-packages))))
|
||||||
(t (pcomplete-here* (pcomplete-entries)))))
|
(t (pcomplete-here* (pcomplete-entries)))))
|
||||||
|
@ -311,6 +319,10 @@ INPUT is the current partially completed string."
|
||||||
(option? "-r" "--root"))
|
(option? "-r" "--root"))
|
||||||
(complete* (pcomplete-entries)))
|
(complete* (pcomplete-entries)))
|
||||||
|
|
||||||
|
((and (command? "graph")
|
||||||
|
(option? "-t" "--type"))
|
||||||
|
(complete* (guix-pcomplete-graph-types)))
|
||||||
|
|
||||||
((and (command? "environment")
|
((and (command? "environment")
|
||||||
(option? "-l" "--load"))
|
(option? "-l" "--load"))
|
||||||
(complete* (pcomplete-entries)))
|
(complete* (pcomplete-entries)))
|
||||||
|
|
Loading…
Reference in New Issue