summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-10-14 12:54:22 +0300
committerThanos Apollo <[email protected]>2024-10-14 12:54:22 +0300
commit857ec337ca68b3d8a1dbae6e830ebf2629f17c14 (patch)
treee4933b6aa6976996a078caf59189dc23d5da3921
parent1cd12dea274e25074e4d24fbe62cf2a426d29de9 (diff)
RefactorHEADmaster
-rw-r--r--pcmpl-emerge.el19
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)
-