blob: 8c614a11bcac0a3bd14d0d720e2fb121ef3bc52f (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
(defvar pcmpl-emerge-package-completions '()
"Cache for emerge package completions.")
(defvar pcmpl-emerge-options '("--sync" "--info" "--help" "-h" "--depclean" "-c"
"--check-news" "--clean" "-av" "-avuDN"
"--config" "--deselect" "-W" "--prune" "-P" "--regen"
"--resume" "-r" "--searchdesc" "-S" "--unmerge" "-C"
"--version" "-V" "--accept-properties=" "--accept-restrict="
"--alert" "-A" "--alphabetical" "--ask" "-a" "--autounmask-backtrack"
"--autounmask" "--autounmask-only" "--autounmask-continue"
"--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"))
(defun pcmpl-emerge-list-packages-in-repo (repo)
"Return a list of package paths in REPO."
(let (result)
(setf result (split-string (shell-command-to-string
(format "find %s -mindepth 2 -maxdepth 2 -type d -not -path '*/\.*'" repo))
"\n" t))
(setf result (mapcar
(lambda (str) (string-remove-prefix (concat "/var/db/repos/" (file-name-nondirectory repo) "/") str))
result))
result))
(defun pcmpl-emerge-update-completions ()
"Update the completions cache."
(let ((top-dir "/var/db/repos/")
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)
(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."
(unless pcmpl-emerge-package-completions
(pcmpl-emerge-update-completions))
(pcomplete-here* pcmpl-emerge-options)
(pcomplete-here* pcmpl-emerge-package-completions))
(provide 'pcmpl-emerge)
|