Mercurial > emacs
annotate lisp/pcmpl-rpm.el @ 110076:c74caa6fbef5
Remove nnultimate.el and related code; Remove nnsoup.el, gnus-soup.el and related code; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Tue, 31 Aug 2010 23:55:50 +0000 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
29959
diff
changeset
|
1 ;;; pcmpl-rpm.el --- functions for dealing with rpm completions |
29959 | 2 |
105810
9381dbed5719
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
103566
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
106815 | 4 ;; 2008, 2009, 2010 Free Software Foundation, Inc. |
29959 | 5 |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
6 ;; Package: pcomplete |
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
7 |
29959 | 8 ;; This file is part of GNU Emacs. |
9 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
29959 | 11 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
29959 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
29959 | 22 |
23 ;;; Commentary: | |
24 | |
103566 | 25 ;; These functions provide completion rules for the `rpm' command. |
29959 | 26 |
27 ;;; Code: | |
28 | |
29 (require 'pcomplete) | |
30 | |
31 ;; Functions: | |
32 | |
33 (defsubst pcmpl-rpm-packages () | |
34 (split-string (pcomplete-process-result "rpm" "-q" "-a"))) | |
35 | |
36 (defun pcmpl-rpm-all-query (flag) | |
37 (message "Querying all packages with `%s'..." flag) | |
38 (let ((pkgs (pcmpl-rpm-packages)) | |
39 (provs (list t))) | |
40 (while pkgs | |
41 (nconc provs (split-string | |
42 (pcomplete-process-result | |
43 "rpm" "-q" (car pkgs) flag))) | |
44 (setq pkgs (cdr pkgs))) | |
45 (pcomplete-uniqify-list (cdr provs)))) | |
46 | |
47 (defsubst pcmpl-rpm-files () | |
48 (pcomplete-dirs-or-entries "\\.rpm\\'")) | |
49 | |
50 ;;;###autoload | |
51 (defun pcomplete/rpm () | |
103566 | 52 "Completion for the `rpm' command." |
53 ;; Originally taken from the output of `rpm --help' on a Red Hat 6.1 system. | |
29959 | 54 (let (mode) |
55 (while (<= pcomplete-index pcomplete-last) | |
56 (unless mode | |
57 (if (pcomplete-match "^--\\(.*\\)" 0) | |
58 (pcomplete-here* | |
59 '("--addsign" | |
60 "--checksig" | |
61 "--erase" | |
62 "--help" | |
63 "--initdb" | |
64 "--install" | |
65 "--pipe" | |
66 "--querytags" | |
67 "--rebuild" | |
68 "--rebuilddb" | |
69 "--recompile" | |
70 "--resign" | |
71 "--rmsource" | |
72 "--setperms" | |
73 "--setugids" | |
74 "--upgrade" | |
75 "--verify" | |
76 "--version")) | |
77 (pcomplete-opt "vqVyiUebtK"))) | |
78 ; -b<stage> <spec> | |
79 ; -t<stage> <tarball> - build package, where <stage> is one of: | |
80 ; p - prep (unpack sources and apply patches) | |
81 ; l - list check (do some cursory checks on %files) | |
82 ; c - compile (prep and compile) | |
83 ; i - install (prep, compile, install) | |
84 ; b - binary package (prep, compile, install, package) | |
85 ; a - bin/src package (prep, compile, install, package) | |
86 (cond | |
87 ((or (eq mode 'query) | |
88 (pcomplete-match "-[^-]*q")) | |
89 (setq mode 'query) | |
90 (if (pcomplete-match "^--\\(.*\\)" 0) | |
91 (progn | |
92 (pcomplete-here* | |
93 '("--changelog" | |
94 "--dbpath" | |
95 "--dump" | |
96 "--ftpport" ;nyi for the next four | |
97 "--ftpproxy" | |
98 "--httpport" | |
99 "--httpproxy" | |
100 "--provides" | |
101 "--queryformat" | |
102 "--rcfile" | |
103 "--requires" | |
104 "--root" | |
105 "--scripts" | |
106 "--triggeredby" | |
107 "--whatprovides" | |
108 "--whatrequires")) | |
109 (cond | |
110 ((pcomplete-test "--dbpath") | |
111 (pcomplete-here* (pcomplete-dirs))) | |
112 ((pcomplete-test "--queryformat") | |
113 (pcomplete-here*)) | |
114 ((pcomplete-test "--rcfile") | |
115 (pcomplete-here* (pcomplete-entries))) | |
116 ((pcomplete-test "--root") | |
117 (pcomplete-here* (pcomplete-dirs))) | |
118 ((pcomplete-test "--scripts") | |
119 (if (pcomplete-match "^--\\(.*\\)" 0) | |
120 (pcomplete-here* '("--triggers")))) | |
121 ((pcomplete-test "--triggeredby") | |
122 (pcomplete-here* (pcmpl-rpm-packages))) | |
123 ((pcomplete-test "--whatprovides") | |
124 (pcomplete-here* | |
125 (pcmpl-rpm-all-query "--provides"))) | |
126 ((pcomplete-test "--whatrequires") | |
127 (pcomplete-here* | |
128 (pcmpl-rpm-all-query "--requires"))))) | |
129 (if (pcomplete-match "^-" 0) | |
130 (pcomplete-opt "af.p(pcmpl-rpm-files)ilsdcvR") | |
99089
d78006bea879
(pcomplete/rpm): Make "rpm -qp" use file completion.
Chong Yidong <cyd@stupidchicken.com>
parents:
99069
diff
changeset
|
131 (if (pcomplete-test "-[^-]*p" 'first 1) |
103566 | 132 (pcomplete-here (pcmpl-rpm-files)) |
99089
d78006bea879
(pcomplete/rpm): Make "rpm -qp" use file completion.
Chong Yidong <cyd@stupidchicken.com>
parents:
99069
diff
changeset
|
133 (pcomplete-here (pcmpl-rpm-packages)))))) |
29959 | 134 ((pcomplete-test "--pipe") |
135 (pcomplete-here* (funcall pcomplete-command-completion-function))) | |
136 ((pcomplete-test "--rmsource") | |
137 (pcomplete-here* (pcomplete-entries)) | |
138 (throw 'pcomplete-completions nil)) | |
139 ((pcomplete-match "\\`--re\\(build\\|compile\\)\\'") | |
140 (pcomplete-here (pcmpl-rpm-files)) | |
141 (throw 'pcomplete-completions nil)) | |
142 ((pcomplete-match "\\`--\\(resign\\|addsign\\)\\'") | |
143 (while (pcomplete-here (pcmpl-rpm-files)))) | |
144 ((or (eq mode 'checksig) | |
145 (pcomplete-test "--checksig")) | |
146 (setq mode 'checksig) | |
147 (if (pcomplete-match "^--\\(.*\\)" 0) | |
148 (progn | |
149 (pcomplete-here* | |
150 '("--nopgp" | |
151 "--nogpg" | |
152 "--nomd5" | |
153 "--rcfile")) | |
154 (cond | |
155 ((pcomplete-test "--rcfile") | |
156 (pcomplete-here* (pcomplete-entries))))) | |
157 (if (pcomplete-match "^-" 0) | |
158 (pcomplete-opt "v") | |
159 (pcomplete-here (pcmpl-rpm-files))))) | |
160 ((or (eq mode 'rebuilddb) | |
161 (pcomplete-test "--rebuilddb")) | |
162 (setq mode 'rebuilddb) | |
163 (if (pcomplete-match "^--\\(.*\\)" 0) | |
164 (progn | |
165 (pcomplete-here* | |
166 '("--dbpath" | |
167 "--root" | |
168 "--rcfile")) | |
169 (cond | |
170 ((pcomplete-test "--dbpath") | |
171 (pcomplete-here* (pcomplete-dirs))) | |
172 ((pcomplete-test "--root") | |
173 (pcomplete-here* (pcomplete-dirs))) | |
174 ((pcomplete-test "--rcfile") | |
175 (pcomplete-here* (pcomplete-entries))))) | |
176 (if (pcomplete-match "^-" 0) | |
177 (pcomplete-opt "v") | |
178 (pcomplete-here)))) | |
179 ((memq mode '(install upgrade)) | |
180 (if (pcomplete-match "^--\\(.*\\)" 0) | |
181 (progn | |
182 (pcomplete-here* | |
183 (append | |
184 '("--allfiles" | |
185 "--badreloc" | |
186 "--dbpath" | |
187 "--excludedocs" | |
188 "--excludepath" | |
189 "--force" | |
190 "--hash" | |
191 "--ignorearch" | |
192 "--ignoreos" | |
193 "--ignoresize" | |
194 "--includedocs" | |
195 "--justdb" | |
196 "--nodeps" | |
197 "--noorder" | |
198 "--noscripts" | |
199 "--notriggers") | |
200 (if (eq mode 'upgrade) | |
201 '("--oldpackage")) | |
202 '("--percent" | |
203 "--prefix" | |
204 "--rcfile" | |
205 "--relocate" | |
206 "--replacefiles" | |
207 "--replacepkgs" | |
208 "--root"))) | |
209 (cond | |
210 ((pcomplete-test "--dbpath") | |
211 (pcomplete-here* (pcomplete-dirs))) | |
212 ((pcomplete-test "--relocate") | |
213 (pcomplete-here*)) | |
214 ((pcomplete-test "--rcfile") | |
215 (pcomplete-here* (pcomplete-entries))) | |
216 ((pcomplete-test "--excludepath") | |
217 (pcomplete-here* (pcomplete-entries))) | |
218 ((pcomplete-test "--root") | |
219 (pcomplete-here* (pcomplete-dirs))) | |
220 ((pcomplete-test "--prefix") | |
221 (pcomplete-here* (pcomplete-dirs))))) | |
222 (if (pcomplete-match "^-" 0) | |
223 (pcomplete-opt "vh") | |
224 (pcomplete-here (pcmpl-rpm-files))))) | |
225 ((or (pcomplete-test "--install") | |
226 (pcomplete-match "-[^-]*i")) | |
227 (setq mode 'install)) | |
228 ((or (pcomplete-test "--upgrade") | |
229 (pcomplete-match "-[^-]*U")) | |
230 (setq mode 'upgrade)) | |
231 ((or (eq mode 'erase) | |
232 (pcomplete-test "--erase") | |
233 (pcomplete-match "-[^-]*e")) | |
234 (setq mode 'erase) | |
235 (if (pcomplete-match "^--\\(.*\\)" 0) | |
236 (progn | |
237 (pcomplete-here* | |
238 '("--allmatches" | |
239 "--dbpath" | |
240 "--justdb" | |
241 "--nodeps" | |
242 "--noorder" | |
243 "--noscripts" | |
244 "--notriggers" | |
245 "--rcfile" | |
246 "--root")) | |
247 (cond | |
248 ((pcomplete-test "--dbpath") | |
249 (pcomplete-here* (pcomplete-dirs))) | |
250 ((pcomplete-test "--rcfile") | |
251 (pcomplete-here* (pcomplete-entries))) | |
252 ((pcomplete-test "--root") | |
253 (pcomplete-here* (pcomplete-dirs))))) | |
254 (if (pcomplete-match "^-" 0) | |
255 (pcomplete-opt "v") | |
256 (pcomplete-here (pcmpl-rpm-packages))))) | |
257 ((or (eq mode 'verify) | |
258 (pcomplete-test "--verify")) | |
259 (setq mode 'verify) | |
260 (if (pcomplete-match "^--\\(.*\\)" 0) | |
261 (progn | |
262 (pcomplete-here* | |
263 '("--dbpath" | |
264 "--nodeps" | |
265 "--nofiles" | |
266 "--nomd5" | |
267 "--rcfile" | |
268 "--root" | |
269 "--triggeredby" | |
270 "--whatprovides" | |
271 "--whatrequires")) | |
272 (cond | |
273 ((pcomplete-test "--dbpath") | |
274 (pcomplete-here* (pcomplete-dirs))) | |
275 ((pcomplete-test "--rcfile") | |
276 (pcomplete-here* (pcomplete-entries))) | |
277 ((pcomplete-test "--root") | |
278 (pcomplete-here* (pcomplete-dirs))) | |
279 ((pcomplete-test "--triggeredby") | |
280 (pcomplete-here* (pcmpl-rpm-packages))) | |
281 ((pcomplete-test "--whatprovides") | |
282 (pcomplete-here* | |
283 (pcmpl-rpm-all-query "--provides"))) | |
284 ((pcomplete-test "--whatrequires") | |
285 (pcomplete-here* | |
286 (pcmpl-rpm-all-query "--requires"))))) | |
287 (if (pcomplete-match "^-" 0) | |
288 (pcomplete-opt "af.p(pcmpl-rpm-files)v") | |
289 (pcomplete-here (pcmpl-rpm-packages))))) | |
290 ((or (memq mode '(build test)) | |
291 (pcomplete-match "\\`-[bt]")) | |
292 (setq mode (if (pcomplete-match "\\`-b") | |
293 'build | |
294 'test)) | |
295 (if (pcomplete-match "^--\\(.*\\)" 0) | |
296 (progn | |
297 (pcomplete-here* | |
298 '("--buildroot" | |
299 "--clean" | |
300 "--nobuild" | |
301 "--rcfile" | |
302 "--rmsource" | |
303 "--short-circuit" | |
304 "--sign" | |
305 "--target" | |
306 "--timecheck")) | |
307 (cond | |
308 ((pcomplete-test "--buildroot") | |
309 (pcomplete-here* (pcomplete-dirs))) | |
310 ((pcomplete-test "--rcfile") | |
311 (pcomplete-here* (pcomplete-entries))) | |
312 ((pcomplete-test "--timecheck") | |
313 (pcomplete-here*)))) | |
314 (if (pcomplete-match "^-" 0) | |
315 (pcomplete-opt "v") | |
316 (pcomplete-here | |
317 (if (eq mode 'test) | |
318 (pcomplete-dirs-or-entries "\\.tar\\'") | |
319 (pcomplete-dirs-or-entries "\\.spec\\'")))))) | |
320 (t | |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
29959
diff
changeset
|
321 (error "You must select a mode: -q, -i, -U, --verify, etc")))))) |
29959 | 322 |
105810
9381dbed5719
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
103566
diff
changeset
|
323 (provide 'pcmpl-rpm) |
9381dbed5719
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
103566
diff
changeset
|
324 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
325 ;; arch-tag: 4e64b490-fecf-430e-b2b9-70a8ad64b8c1 |
29959 | 326 ;;; pcmpl-rpm.el ends here |