Mercurial > emacs
annotate lisp/pcmpl-rpm.el @ 101999:efada72951fb
* minibuffer.el (internal-complete-buffer-except): Doc fix. (Bug#2315)
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Fri, 13 Feb 2009 10:35:40 +0000 |
parents | 31ebb1cb873f |
children | 7af1196e07f8 |
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 | |
23 ;; These functions provide completion rules for RedHat's `rpm' tool. | |
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 () | |
56 "Completion for RedHat's `rpm' command. | |
57 These rules were taken from the output of `rpm --help' on a RedHat 6.1 | |
58 system. They follow my interpretation of what followed, but since I'm | |
59 not a major rpm user/builder, please send me any corrections you find. | |
99069 | 60 You can use \\[report-emacs-bug] to do so." |
29959 | 61 (let (mode) |
62 (while (<= pcomplete-index pcomplete-last) | |
63 (unless mode | |
64 (if (pcomplete-match "^--\\(.*\\)" 0) | |
65 (pcomplete-here* | |
66 '("--addsign" | |
67 "--checksig" | |
68 "--erase" | |
69 "--help" | |
70 "--initdb" | |
71 "--install" | |
72 "--pipe" | |
73 "--querytags" | |
74 "--rebuild" | |
75 "--rebuilddb" | |
76 "--recompile" | |
77 "--resign" | |
78 "--rmsource" | |
79 "--setperms" | |
80 "--setugids" | |
81 "--upgrade" | |
82 "--verify" | |
83 "--version")) | |
84 (pcomplete-opt "vqVyiUebtK"))) | |
85 ; -b<stage> <spec> | |
86 ; -t<stage> <tarball> - build package, where <stage> is one of: | |
87 ; p - prep (unpack sources and apply patches) | |
88 ; l - list check (do some cursory checks on %files) | |
89 ; c - compile (prep and compile) | |
90 ; i - install (prep, compile, install) | |
91 ; b - binary package (prep, compile, install, package) | |
92 ; a - bin/src package (prep, compile, install, package) | |
93 (cond | |
94 ((or (eq mode 'query) | |
95 (pcomplete-match "-[^-]*q")) | |
96 (setq mode 'query) | |
97 (if (pcomplete-match "^--\\(.*\\)" 0) | |
98 (progn | |
99 (pcomplete-here* | |
100 '("--changelog" | |
101 "--dbpath" | |
102 "--dump" | |
103 "--ftpport" ;nyi for the next four | |
104 "--ftpproxy" | |
105 "--httpport" | |
106 "--httpproxy" | |
107 "--provides" | |
108 "--queryformat" | |
109 "--rcfile" | |
110 "--requires" | |
111 "--root" | |
112 "--scripts" | |
113 "--triggeredby" | |
114 "--whatprovides" | |
115 "--whatrequires")) | |
116 (cond | |
117 ((pcomplete-test "--dbpath") | |
118 (pcomplete-here* (pcomplete-dirs))) | |
119 ((pcomplete-test "--queryformat") | |
120 (pcomplete-here*)) | |
121 ((pcomplete-test "--rcfile") | |
122 (pcomplete-here* (pcomplete-entries))) | |
123 ((pcomplete-test "--root") | |
124 (pcomplete-here* (pcomplete-dirs))) | |
125 ((pcomplete-test "--scripts") | |
126 (if (pcomplete-match "^--\\(.*\\)" 0) | |
127 (pcomplete-here* '("--triggers")))) | |
128 ((pcomplete-test "--triggeredby") | |
129 (pcomplete-here* (pcmpl-rpm-packages))) | |
130 ((pcomplete-test "--whatprovides") | |
131 (pcomplete-here* | |
132 (pcmpl-rpm-all-query "--provides"))) | |
133 ((pcomplete-test "--whatrequires") | |
134 (pcomplete-here* | |
135 (pcmpl-rpm-all-query "--requires"))))) | |
136 (if (pcomplete-match "^-" 0) | |
137 (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
|
138 (if (pcomplete-test "-[^-]*p" 'first 1) |
d78006bea879
(pcomplete/rpm): Make "rpm -qp" use file completion.
Chong Yidong <cyd@stupidchicken.com>
parents:
99069
diff
changeset
|
139 (pcomplete-here (pcmpl-rpm-files)) |
d78006bea879
(pcomplete/rpm): Make "rpm -qp" use file completion.
Chong Yidong <cyd@stupidchicken.com>
parents:
99069
diff
changeset
|
140 (pcomplete-here (pcmpl-rpm-packages)))))) |
29959 | 141 ((pcomplete-test "--pipe") |
142 (pcomplete-here* (funcall pcomplete-command-completion-function))) | |
143 ((pcomplete-test "--rmsource") | |
144 (pcomplete-here* (pcomplete-entries)) | |
145 (throw 'pcomplete-completions nil)) | |
146 ((pcomplete-match "\\`--re\\(build\\|compile\\)\\'") | |
147 (pcomplete-here (pcmpl-rpm-files)) | |
148 (throw 'pcomplete-completions nil)) | |
149 ((pcomplete-match "\\`--\\(resign\\|addsign\\)\\'") | |
150 (while (pcomplete-here (pcmpl-rpm-files)))) | |
151 ((or (eq mode 'checksig) | |
152 (pcomplete-test "--checksig")) | |
153 (setq mode 'checksig) | |
154 (if (pcomplete-match "^--\\(.*\\)" 0) | |
155 (progn | |
156 (pcomplete-here* | |
157 '("--nopgp" | |
158 "--nogpg" | |
159 "--nomd5" | |
160 "--rcfile")) | |
161 (cond | |
162 ((pcomplete-test "--rcfile") | |
163 (pcomplete-here* (pcomplete-entries))))) | |
164 (if (pcomplete-match "^-" 0) | |
165 (pcomplete-opt "v") | |
166 (pcomplete-here (pcmpl-rpm-files))))) | |
167 ((or (eq mode 'rebuilddb) | |
168 (pcomplete-test "--rebuilddb")) | |
169 (setq mode 'rebuilddb) | |
170 (if (pcomplete-match "^--\\(.*\\)" 0) | |
171 (progn | |
172 (pcomplete-here* | |
173 '("--dbpath" | |
174 "--root" | |
175 "--rcfile")) | |
176 (cond | |
177 ((pcomplete-test "--dbpath") | |
178 (pcomplete-here* (pcomplete-dirs))) | |
179 ((pcomplete-test "--root") | |
180 (pcomplete-here* (pcomplete-dirs))) | |
181 ((pcomplete-test "--rcfile") | |
182 (pcomplete-here* (pcomplete-entries))))) | |
183 (if (pcomplete-match "^-" 0) | |
184 (pcomplete-opt "v") | |
185 (pcomplete-here)))) | |
186 ((memq mode '(install upgrade)) | |
187 (if (pcomplete-match "^--\\(.*\\)" 0) | |
188 (progn | |
189 (pcomplete-here* | |
190 (append | |
191 '("--allfiles" | |
192 "--badreloc" | |
193 "--dbpath" | |
194 "--excludedocs" | |
195 "--excludepath" | |
196 "--force" | |
197 "--hash" | |
198 "--ignorearch" | |
199 "--ignoreos" | |
200 "--ignoresize" | |
201 "--includedocs" | |
202 "--justdb" | |
203 "--nodeps" | |
204 "--noorder" | |
205 "--noscripts" | |
206 "--notriggers") | |
207 (if (eq mode 'upgrade) | |
208 '("--oldpackage")) | |
209 '("--percent" | |
210 "--prefix" | |
211 "--rcfile" | |
212 "--relocate" | |
213 "--replacefiles" | |
214 "--replacepkgs" | |
215 "--root"))) | |
216 (cond | |
217 ((pcomplete-test "--dbpath") | |
218 (pcomplete-here* (pcomplete-dirs))) | |
219 ((pcomplete-test "--relocate") | |
220 (pcomplete-here*)) | |
221 ((pcomplete-test "--rcfile") | |
222 (pcomplete-here* (pcomplete-entries))) | |
223 ((pcomplete-test "--excludepath") | |
224 (pcomplete-here* (pcomplete-entries))) | |
225 ((pcomplete-test "--root") | |
226 (pcomplete-here* (pcomplete-dirs))) | |
227 ((pcomplete-test "--prefix") | |
228 (pcomplete-here* (pcomplete-dirs))))) | |
229 (if (pcomplete-match "^-" 0) | |
230 (pcomplete-opt "vh") | |
231 (pcomplete-here (pcmpl-rpm-files))))) | |
232 ((or (pcomplete-test "--install") | |
233 (pcomplete-match "-[^-]*i")) | |
234 (setq mode 'install)) | |
235 ((or (pcomplete-test "--upgrade") | |
236 (pcomplete-match "-[^-]*U")) | |
237 (setq mode 'upgrade)) | |
238 ((or (eq mode 'erase) | |
239 (pcomplete-test "--erase") | |
240 (pcomplete-match "-[^-]*e")) | |
241 (setq mode 'erase) | |
242 (if (pcomplete-match "^--\\(.*\\)" 0) | |
243 (progn | |
244 (pcomplete-here* | |
245 '("--allmatches" | |
246 "--dbpath" | |
247 "--justdb" | |
248 "--nodeps" | |
249 "--noorder" | |
250 "--noscripts" | |
251 "--notriggers" | |
252 "--rcfile" | |
253 "--root")) | |
254 (cond | |
255 ((pcomplete-test "--dbpath") | |
256 (pcomplete-here* (pcomplete-dirs))) | |
257 ((pcomplete-test "--rcfile") | |
258 (pcomplete-here* (pcomplete-entries))) | |
259 ((pcomplete-test "--root") | |
260 (pcomplete-here* (pcomplete-dirs))))) | |
261 (if (pcomplete-match "^-" 0) | |
262 (pcomplete-opt "v") | |
263 (pcomplete-here (pcmpl-rpm-packages))))) | |
264 ((or (eq mode 'verify) | |
265 (pcomplete-test "--verify")) | |
266 (setq mode 'verify) | |
267 (if (pcomplete-match "^--\\(.*\\)" 0) | |
268 (progn | |
269 (pcomplete-here* | |
270 '("--dbpath" | |
271 "--nodeps" | |
272 "--nofiles" | |
273 "--nomd5" | |
274 "--rcfile" | |
275 "--root" | |
276 "--triggeredby" | |
277 "--whatprovides" | |
278 "--whatrequires")) | |
279 (cond | |
280 ((pcomplete-test "--dbpath") | |
281 (pcomplete-here* (pcomplete-dirs))) | |
282 ((pcomplete-test "--rcfile") | |
283 (pcomplete-here* (pcomplete-entries))) | |
284 ((pcomplete-test "--root") | |
285 (pcomplete-here* (pcomplete-dirs))) | |
286 ((pcomplete-test "--triggeredby") | |
287 (pcomplete-here* (pcmpl-rpm-packages))) | |
288 ((pcomplete-test "--whatprovides") | |
289 (pcomplete-here* | |
290 (pcmpl-rpm-all-query "--provides"))) | |
291 ((pcomplete-test "--whatrequires") | |
292 (pcomplete-here* | |
293 (pcmpl-rpm-all-query "--requires"))))) | |
294 (if (pcomplete-match "^-" 0) | |
295 (pcomplete-opt "af.p(pcmpl-rpm-files)v") | |
296 (pcomplete-here (pcmpl-rpm-packages))))) | |
297 ((or (memq mode '(build test)) | |
298 (pcomplete-match "\\`-[bt]")) | |
299 (setq mode (if (pcomplete-match "\\`-b") | |
300 'build | |
301 'test)) | |
302 (if (pcomplete-match "^--\\(.*\\)" 0) | |
303 (progn | |
304 (pcomplete-here* | |
305 '("--buildroot" | |
306 "--clean" | |
307 "--nobuild" | |
308 "--rcfile" | |
309 "--rmsource" | |
310 "--short-circuit" | |
311 "--sign" | |
312 "--target" | |
313 "--timecheck")) | |
314 (cond | |
315 ((pcomplete-test "--buildroot") | |
316 (pcomplete-here* (pcomplete-dirs))) | |
317 ((pcomplete-test "--rcfile") | |
318 (pcomplete-here* (pcomplete-entries))) | |
319 ((pcomplete-test "--timecheck") | |
320 (pcomplete-here*)))) | |
321 (if (pcomplete-match "^-" 0) | |
322 (pcomplete-opt "v") | |
323 (pcomplete-here | |
324 (if (eq mode 'test) | |
325 (pcomplete-dirs-or-entries "\\.tar\\'") | |
326 (pcomplete-dirs-or-entries "\\.spec\\'")))))) | |
327 (t | |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
29959
diff
changeset
|
328 (error "You must select a mode: -q, -i, -U, --verify, etc")))))) |
29959 | 329 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
330 ;; arch-tag: 4e64b490-fecf-430e-b2b9-70a8ad64b8c1 |
29959 | 331 ;;; pcmpl-rpm.el ends here |