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