Mercurial > emacs
annotate lisp/pcmpl-rpm.el @ 103666:3337a01621b2
(Help Functions): Fix description of help-buffer and
help-setup-xref to use @defun instead of @deffn.
author | Andreas Schwab <schwab@linux-m68k.org> |
---|---|
date | Wed, 01 Jul 2009 14:52:28 +0000 |
parents | 7af1196e07f8 |
children | 9381dbed5719 |
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 |
74442 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
100908 | 4 ;; 2005, 2006, 2007, 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 (provide 'pcmpl-rpm) | |
28 | |
29 (require 'pcomplete) | |
30 | |
31 (defgroup pcmpl-rpm nil | |
101634
31ebb1cb873f
Klaus Straubinger <KSNetz at UseNet.ArcorNews.DE> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
32 "Functions for dealing with rpm completions." |
29959 | 33 :group 'pcomplete) |
34 | |
35 ;; Functions: | |
36 | |
37 (defsubst pcmpl-rpm-packages () | |
38 (split-string (pcomplete-process-result "rpm" "-q" "-a"))) | |
39 | |
40 (defun pcmpl-rpm-all-query (flag) | |
41 (message "Querying all packages with `%s'..." flag) | |
42 (let ((pkgs (pcmpl-rpm-packages)) | |
43 (provs (list t))) | |
44 (while pkgs | |
45 (nconc provs (split-string | |
46 (pcomplete-process-result | |
47 "rpm" "-q" (car pkgs) flag))) | |
48 (setq pkgs (cdr pkgs))) | |
49 (pcomplete-uniqify-list (cdr provs)))) | |
50 | |
51 (defsubst pcmpl-rpm-files () | |
52 (pcomplete-dirs-or-entries "\\.rpm\\'")) | |
53 | |
54 ;;;###autoload | |
55 (defun pcomplete/rpm () | |
103566 | 56 "Completion for the `rpm' command." |
57 ;; Originally taken from the output of `rpm --help' on a Red Hat 6.1 system. | |
29959 | 58 (let (mode) |
59 (while (<= pcomplete-index pcomplete-last) | |
60 (unless mode | |
61 (if (pcomplete-match "^--\\(.*\\)" 0) | |
62 (pcomplete-here* | |
63 '("--addsign" | |
64 "--checksig" | |
65 "--erase" | |
66 "--help" | |
67 "--initdb" | |
68 "--install" | |
69 "--pipe" | |
70 "--querytags" | |
71 "--rebuild" | |
72 "--rebuilddb" | |
73 "--recompile" | |
74 "--resign" | |
75 "--rmsource" | |
76 "--setperms" | |
77 "--setugids" | |
78 "--upgrade" | |
79 "--verify" | |
80 "--version")) | |
81 (pcomplete-opt "vqVyiUebtK"))) | |
82 ; -b<stage> <spec> | |
83 ; -t<stage> <tarball> - build package, where <stage> is one of: | |
84 ; p - prep (unpack sources and apply patches) | |
85 ; l - list check (do some cursory checks on %files) | |
86 ; c - compile (prep and compile) | |
87 ; i - install (prep, compile, install) | |
88 ; b - binary package (prep, compile, install, package) | |
89 ; a - bin/src package (prep, compile, install, package) | |
90 (cond | |
91 ((or (eq mode 'query) | |
92 (pcomplete-match "-[^-]*q")) | |
93 (setq mode 'query) | |
94 (if (pcomplete-match "^--\\(.*\\)" 0) | |
95 (progn | |
96 (pcomplete-here* | |
97 '("--changelog" | |
98 "--dbpath" | |
99 "--dump" | |
100 "--ftpport" ;nyi for the next four | |
101 "--ftpproxy" | |
102 "--httpport" | |
103 "--httpproxy" | |
104 "--provides" | |
105 "--queryformat" | |
106 "--rcfile" | |
107 "--requires" | |
108 "--root" | |
109 "--scripts" | |
110 "--triggeredby" | |
111 "--whatprovides" | |
112 "--whatrequires")) | |
113 (cond | |
114 ((pcomplete-test "--dbpath") | |
115 (pcomplete-here* (pcomplete-dirs))) | |
116 ((pcomplete-test "--queryformat") | |
117 (pcomplete-here*)) | |
118 ((pcomplete-test "--rcfile") | |
119 (pcomplete-here* (pcomplete-entries))) | |
120 ((pcomplete-test "--root") | |
121 (pcomplete-here* (pcomplete-dirs))) | |
122 ((pcomplete-test "--scripts") | |
123 (if (pcomplete-match "^--\\(.*\\)" 0) | |
124 (pcomplete-here* '("--triggers")))) | |
125 ((pcomplete-test "--triggeredby") | |
126 (pcomplete-here* (pcmpl-rpm-packages))) | |
127 ((pcomplete-test "--whatprovides") | |
128 (pcomplete-here* | |
129 (pcmpl-rpm-all-query "--provides"))) | |
130 ((pcomplete-test "--whatrequires") | |
131 (pcomplete-here* | |
132 (pcmpl-rpm-all-query "--requires"))))) | |
133 (if (pcomplete-match "^-" 0) | |
134 (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
|
135 (if (pcomplete-test "-[^-]*p" 'first 1) |
103566 | 136 (pcomplete-here (pcmpl-rpm-files)) |
99089
d78006bea879
(pcomplete/rpm): Make "rpm -qp" use file completion.
Chong Yidong <cyd@stupidchicken.com>
parents:
99069
diff
changeset
|
137 (pcomplete-here (pcmpl-rpm-packages)))))) |
29959 | 138 ((pcomplete-test "--pipe") |
139 (pcomplete-here* (funcall pcomplete-command-completion-function))) | |
140 ((pcomplete-test "--rmsource") | |
141 (pcomplete-here* (pcomplete-entries)) | |
142 (throw 'pcomplete-completions nil)) | |
143 ((pcomplete-match "\\`--re\\(build\\|compile\\)\\'") | |
144 (pcomplete-here (pcmpl-rpm-files)) | |
145 (throw 'pcomplete-completions nil)) | |
146 ((pcomplete-match "\\`--\\(resign\\|addsign\\)\\'") | |
147 (while (pcomplete-here (pcmpl-rpm-files)))) | |
148 ((or (eq mode 'checksig) | |
149 (pcomplete-test "--checksig")) | |
150 (setq mode 'checksig) | |
151 (if (pcomplete-match "^--\\(.*\\)" 0) | |
152 (progn | |
153 (pcomplete-here* | |
154 '("--nopgp" | |
155 "--nogpg" | |
156 "--nomd5" | |
157 "--rcfile")) | |
158 (cond | |
159 ((pcomplete-test "--rcfile") | |
160 (pcomplete-here* (pcomplete-entries))))) | |
161 (if (pcomplete-match "^-" 0) | |
162 (pcomplete-opt "v") | |
163 (pcomplete-here (pcmpl-rpm-files))))) | |
164 ((or (eq mode 'rebuilddb) | |
165 (pcomplete-test "--rebuilddb")) | |
166 (setq mode 'rebuilddb) | |
167 (if (pcomplete-match "^--\\(.*\\)" 0) | |
168 (progn | |
169 (pcomplete-here* | |
170 '("--dbpath" | |
171 "--root" | |
172 "--rcfile")) | |
173 (cond | |
174 ((pcomplete-test "--dbpath") | |
175 (pcomplete-here* (pcomplete-dirs))) | |
176 ((pcomplete-test "--root") | |
177 (pcomplete-here* (pcomplete-dirs))) | |
178 ((pcomplete-test "--rcfile") | |
179 (pcomplete-here* (pcomplete-entries))))) | |
180 (if (pcomplete-match "^-" 0) | |
181 (pcomplete-opt "v") | |
182 (pcomplete-here)))) | |
183 ((memq mode '(install upgrade)) | |
184 (if (pcomplete-match "^--\\(.*\\)" 0) | |
185 (progn | |
186 (pcomplete-here* | |
187 (append | |
188 '("--allfiles" | |
189 "--badreloc" | |
190 "--dbpath" | |
191 "--excludedocs" | |
192 "--excludepath" | |
193 "--force" | |
194 "--hash" | |
195 "--ignorearch" | |
196 "--ignoreos" | |
197 "--ignoresize" | |
198 "--includedocs" | |
199 "--justdb" | |
200 "--nodeps" | |
201 "--noorder" | |
202 "--noscripts" | |
203 "--notriggers") | |
204 (if (eq mode 'upgrade) | |
205 '("--oldpackage")) | |
206 '("--percent" | |
207 "--prefix" | |
208 "--rcfile" | |
209 "--relocate" | |
210 "--replacefiles" | |
211 "--replacepkgs" | |
212 "--root"))) | |
213 (cond | |
214 ((pcomplete-test "--dbpath") | |
215 (pcomplete-here* (pcomplete-dirs))) | |
216 ((pcomplete-test "--relocate") | |
217 (pcomplete-here*)) | |
218 ((pcomplete-test "--rcfile") | |
219 (pcomplete-here* (pcomplete-entries))) | |
220 ((pcomplete-test "--excludepath") | |
221 (pcomplete-here* (pcomplete-entries))) | |
222 ((pcomplete-test "--root") | |
223 (pcomplete-here* (pcomplete-dirs))) | |
224 ((pcomplete-test "--prefix") | |
225 (pcomplete-here* (pcomplete-dirs))))) | |
226 (if (pcomplete-match "^-" 0) | |
227 (pcomplete-opt "vh") | |
228 (pcomplete-here (pcmpl-rpm-files))))) | |
229 ((or (pcomplete-test "--install") | |
230 (pcomplete-match "-[^-]*i")) | |
231 (setq mode 'install)) | |
232 ((or (pcomplete-test "--upgrade") | |
233 (pcomplete-match "-[^-]*U")) | |
234 (setq mode 'upgrade)) | |
235 ((or (eq mode 'erase) | |
236 (pcomplete-test "--erase") | |
237 (pcomplete-match "-[^-]*e")) | |
238 (setq mode 'erase) | |
239 (if (pcomplete-match "^--\\(.*\\)" 0) | |
240 (progn | |
241 (pcomplete-here* | |
242 '("--allmatches" | |
243 "--dbpath" | |
244 "--justdb" | |
245 "--nodeps" | |
246 "--noorder" | |
247 "--noscripts" | |
248 "--notriggers" | |
249 "--rcfile" | |
250 "--root")) | |
251 (cond | |
252 ((pcomplete-test "--dbpath") | |
253 (pcomplete-here* (pcomplete-dirs))) | |
254 ((pcomplete-test "--rcfile") | |
255 (pcomplete-here* (pcomplete-entries))) | |
256 ((pcomplete-test "--root") | |
257 (pcomplete-here* (pcomplete-dirs))))) | |
258 (if (pcomplete-match "^-" 0) | |
259 (pcomplete-opt "v") | |
260 (pcomplete-here (pcmpl-rpm-packages))))) | |
261 ((or (eq mode 'verify) | |
262 (pcomplete-test "--verify")) | |
263 (setq mode 'verify) | |
264 (if (pcomplete-match "^--\\(.*\\)" 0) | |
265 (progn | |
266 (pcomplete-here* | |
267 '("--dbpath" | |
268 "--nodeps" | |
269 "--nofiles" | |
270 "--nomd5" | |
271 "--rcfile" | |
272 "--root" | |
273 "--triggeredby" | |
274 "--whatprovides" | |
275 "--whatrequires")) | |
276 (cond | |
277 ((pcomplete-test "--dbpath") | |
278 (pcomplete-here* (pcomplete-dirs))) | |
279 ((pcomplete-test "--rcfile") | |
280 (pcomplete-here* (pcomplete-entries))) | |
281 ((pcomplete-test "--root") | |
282 (pcomplete-here* (pcomplete-dirs))) | |
283 ((pcomplete-test "--triggeredby") | |
284 (pcomplete-here* (pcmpl-rpm-packages))) | |
285 ((pcomplete-test "--whatprovides") | |
286 (pcomplete-here* | |
287 (pcmpl-rpm-all-query "--provides"))) | |
288 ((pcomplete-test "--whatrequires") | |
289 (pcomplete-here* | |
290 (pcmpl-rpm-all-query "--requires"))))) | |
291 (if (pcomplete-match "^-" 0) | |
292 (pcomplete-opt "af.p(pcmpl-rpm-files)v") | |
293 (pcomplete-here (pcmpl-rpm-packages))))) | |
294 ((or (memq mode '(build test)) | |
295 (pcomplete-match "\\`-[bt]")) | |
296 (setq mode (if (pcomplete-match "\\`-b") | |
297 'build | |
298 'test)) | |
299 (if (pcomplete-match "^--\\(.*\\)" 0) | |
300 (progn | |
301 (pcomplete-here* | |
302 '("--buildroot" | |
303 "--clean" | |
304 "--nobuild" | |
305 "--rcfile" | |
306 "--rmsource" | |
307 "--short-circuit" | |
308 "--sign" | |
309 "--target" | |
310 "--timecheck")) | |
311 (cond | |
312 ((pcomplete-test "--buildroot") | |
313 (pcomplete-here* (pcomplete-dirs))) | |
314 ((pcomplete-test "--rcfile") | |
315 (pcomplete-here* (pcomplete-entries))) | |
316 ((pcomplete-test "--timecheck") | |
317 (pcomplete-here*)))) | |
318 (if (pcomplete-match "^-" 0) | |
319 (pcomplete-opt "v") | |
320 (pcomplete-here | |
321 (if (eq mode 'test) | |
322 (pcomplete-dirs-or-entries "\\.tar\\'") | |
323 (pcomplete-dirs-or-entries "\\.spec\\'")))))) | |
324 (t | |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
29959
diff
changeset
|
325 (error "You must select a mode: -q, -i, -U, --verify, etc")))))) |
29959 | 326 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
327 ;; arch-tag: 4e64b490-fecf-430e-b2b9-70a8ad64b8c1 |
29959 | 328 ;;; pcmpl-rpm.el ends here |