diff options
-rw-r--r-- | pcmpl-emerge.el | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/pcmpl-emerge.el b/pcmpl-emerge.el index 00cb79f..ae28191 100644 --- a/pcmpl-emerge.el +++ b/pcmpl-emerge.el @@ -30,6 +30,7 @@ (require 'cl-lib) (require 'pcomplete) +(require 'subr-x) (defvar pcmpl-emerge-package-completions '() "Cache for emerge package completions.") @@ -44,7 +45,8 @@ "--autounmask-unrestricted-atoms" "--autounmask-keep-keywords" "--autounmask-keep-masks" "--autounmask-license" "--autounmask-use" "--autounmask-write" "--binpkg-changed-deps" "--binpkg-respect-use" - "--buildpkg" "-b" "--buildpkg-exclude" "--buildpkgonly" "-B")) + "--buildpkg" "-b" "--buildpkg-exclude" "--buildpkgonly" "-B") + "Emerge options.") (defun pcmpl-emerge-list-packages-in-repo (repo) @@ -61,22 +63,23 @@ (defun pcmpl-emerge-update-completions () "Update the completions cache." (let ((top-dir "/var/db/repos/") - paths) + paths) (cl-loop for repo in (seq-filter (lambda (f) (not (string-match-p "\\.git$" f))) (directory-files top-dir t directory-files-no-dot-files-regexp)) - do (setf paths (append paths (seq-filter - (lambda (str) + do (setf paths (append paths (seq-filter + (lambda (str) (not (string-match-p "/\\.git/" str))) (pcmpl-emerge-list-packages-in-repo repo))))) (setf pcmpl-emerge-package-completions (seq-uniq paths)))) ;;;###autoload (defun pcomplete/emerge () - "Completion rules for the 'emerge' command." + "Completion rules for the `emerge' command." (unless pcmpl-emerge-package-completions (pcmpl-emerge-update-completions)) - (pcomplete-here* pcmpl-emerge-options) - (pcomplete-here* pcmpl-emerge-package-completions)) + (while (pcomplete-arg) + (if (string-prefix-p "-" (pcomplete-arg)) + (pcomplete-here* pcmpl-emerge-options) + (pcomplete-here* pcmpl-emerge-package-completions)))) (provide 'pcmpl-emerge) - |