[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 001704750d 249/500: Improve pcomplete
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 001704750d 249/500: Improve pcomplete |
Date: |
Sat, 29 Jan 2022 08:27:11 -0500 (EST) |
branch: elpa/nix-mode
commit 001704750d49422a92f2514bf941db75668921c3
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Improve pcomplete
add more flags
---
nix.el | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 128 insertions(+), 7 deletions(-)
diff --git a/nix.el b/nix.el
index 5b633ecb6f..f6861da609 100644
--- a/nix.el
+++ b/nix.el
@@ -142,16 +142,137 @@
"trusted-subtituters"
"trusted-users"))
+(defun nix--pcomplete-flags (options)
+ "Complete flags to the Nix command."
+ (while (pcomplete-match "^-" 0)
+ (pcomplete-here options)
+ (let ((last-arg (nth (1- pcomplete-index) pcomplete-args)))
+ (cond
+ ((string= "--option" last-arg)
+ (pcomplete-here nix-config-options)
+ (pcomplete-here))
+ ((or (string= "-f" last-arg) (string= "--file" last-arg))
+ (pcomplete-here (pcomplete-entries nil 'file-exists-p)))
+ ((or (string= "--arg" last-arg) (string= "--argstr" last-arg))
+ (pcomplete-here)
+ (pcomplete-here))
+ ((or (string= "-I" last-arg) (string= "--include" last-arg))
+ (pcomplete-here (pcomplete-entries nil 'file-exists-p)))
+ ((or (string= "-k" last-arg) (string= "--keep" last-arg))
+ (pcomplete-here))
+ ((or (string= "-u" last-arg) (string= "--unset" last-arg))
+ (pcomplete-here))
+ ((or (string= "-s" last-arg) (string= "--substituter" last-arg))
+ (pcomplete-here))))))
+
;;;###autoload
(defun pcomplete/nix ()
"Completion for the nix command."
- (while (pcomplete-match "^-" 0)
- (pcomplete-here nix-toplevel-options)
- (when (string= "--option"
- (nth (1- pcomplete-index) pcomplete-args))
- (pcomplete-here nix-config-options)
- (pcomplete-here)))
- (pcomplete-here nix-commands))
+ (nix--pcomplete-flags nix-toplevel-options)
+ (pcomplete-here nix-commands)
+ (pcase (nth (1- pcomplete-index) pcomplete-args)
+ ("run"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr" "-c" "--command"
+ "-f" "--file" "-i" "-I" "--include"
+ "-k" "--keep" "-u" "--unset"))))
+ ("build"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr" "--dry-run"
+ "-f" "--file" "-I" "--include"
+ "--no-link" "-o" "--out-link"))))
+ ("add-to-store"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--dry-run" "-n" "--name"))))
+ ("copy"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "--from"
+ "-I" "--include" "--no-check-sigs"
+ "--no-recursive" "-s" "--substitute"
+ "--to"))))
+ ("copy-sigs"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "-r" "--recursive" "-s"
"--substituter"))))
+ ("dump-path"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ ("edit"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ ("eval"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--json" "--raw"))))
+ ("hash-file"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--base16" "--base32"
+ "--base64" "--type"))))
+ ("hash-path"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--base16" "--base32"
+ "--base64" "--type"))))
+ ("log"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--json" "--raw"))))
+ ("ls-nar"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-d" "--directory"
+ "--json" "-l" "--long"
+ "-R" "--recursive"))))
+ ("ls-store"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-d" "--directory"
+ "--json" "-l" "--long"
+ "-R" "--recursive"))))
+ ("repl"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-I" "--include"))))
+ ("search"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file"
+ "-I" "--include"
+ "--json" "--no-cache"
+ "-u" "--update-cache"))))
+ ("show-config"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--json"))))
+ ("show-derivation"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file"
+ "-I" "--include"
+ "-r" "--recursive"))))
+ ("sign-paths"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "-k" "--key-file" "-r" "--recursive"))))
+ ("upgrade-nix"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-p" "--profile"))))
+ ("verify"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--no-contents" "--no-trust"
+ "-r" "--recursive" "-n" "--sigs-needed"
+ "-s" "--substuter"))))
+ ("why-depends"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-a" "--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ (_ (nix--pcomplete-flags nix-toplevel-options)))
+ (pcomplete-here (pcomplete-entries)))
(provide 'nix)
;;; nix.el ends here
- [nongnu] elpa/nix-mode 1b85a1986d 479/500: nix-flake: Use = key consistently to switch the flake, (continued)
- [nongnu] elpa/nix-mode 1b85a1986d 479/500: nix-flake: Use = key consistently to switch the flake, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7929f9623d 483/500: chore: Add transient to the dependencies, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 33b2edf8ac 005/500: set spacing to defaults, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 24e8281149 013/500: Refactor keywords, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3c7afb9478 026/500: Add nix-visit-file function., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4edccb66e5 071/500: Small nitpicks, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode bd019fe5e5 111/500: Automatically makunbound 'nix-mode-syntax-table, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a521468c5b 129/500: Fixup string indenting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e40377b36b 194/500: Make the correctly-prefixed prettify global mode name canonical, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 293f9a5e06 203/500: Oops, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 001704750d 249/500: Improve pcomplete,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 94e1a57c31 242/500: Add missing file to Cask, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode fbcbc446f8 254/500: Add attr to nix-search, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b0829d67c5 256/500: Fix missing parens and standardize regexp style, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ccb320ab31 344/500: Make sure update .elc is available when running tests, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 004c81e51d 362/500: Merge branch 'master' into fix-94, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e20afb51a4 370/500: Release 1.4.2, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e7fa834b80 383/500: Update nix-shell.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 21d3ba0b80 382/500: Update yaml again, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7487346812 378/500: Add flake, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 015bf9639a 386/500: Remove filenames handling, ELPA Syncer, 2022/01/29