Mercurial > emacs
annotate lisp/pcmpl-rpm.el @ 96138:41be5bc2426e
Fix autoload building command in src Makefile
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1268
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 21 Jun 2008 02:37:02 +0000 |
parents | ee5932bf781d |
children | c61c4d079bc9 |
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, |
79721 | 4 ;; 2005, 2006, 2007, 2008 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 | |
64017
660d78f5be5a
(pcmpl-rpm): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
32 "Functions for dealing with CVS 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. | |
60 You can use \\[eshell-report-bug] to do so." | |
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") | |
138 (pcomplete-here (pcmpl-rpm-packages))))) | |
139 ((pcomplete-test "--pipe") | |
140 (pcomplete-here* (funcall pcomplete-command-completion-function))) | |
141 ((pcomplete-test "--rmsource") | |
142 (pcomplete-here* (pcomplete-entries)) | |
143 (throw 'pcomplete-completions nil)) | |
144 ((pcomplete-match "\\`--re\\(build\\|compile\\)\\'") | |
145 (pcomplete-here (pcmpl-rpm-files)) | |
146 (throw 'pcomplete-completions nil)) | |
147 ((pcomplete-match "\\`--\\(resign\\|addsign\\)\\'") | |
148 (while (pcomplete-here (pcmpl-rpm-files)))) | |
149 ((or (eq mode 'checksig) | |
150 (pcomplete-test "--checksig")) | |
151 (setq mode 'checksig) | |
152 (if (pcomplete-match "^--\\(.*\\)" 0) | |
153 (progn | |
154 (pcomplete-here* | |
155 '("--nopgp" | |
156 "--nogpg" | |
157 "--nomd5" | |
158 "--rcfile")) | |
159 (cond | |
160 ((pcomplete-test "--rcfile") | |
161 (pcomplete-here* (pcomplete-entries))))) | |
162 (if (pcomplete-match "^-" 0) | |
163 (pcomplete-opt "v") | |
164 (pcomplete-here (pcmpl-rpm-files))))) | |
165 ((or (eq mode 'rebuilddb) | |
166 (pcomplete-test "--rebuilddb")) | |
167 (setq mode 'rebuilddb) | |
168 (if (pcomplete-match "^--\\(.*\\)" 0) | |
169 (progn | |
170 (pcomplete-here* | |
171 '("--dbpath" | |
172 "--root" | |
173 "--rcfile")) | |
174 (cond | |
175 ((pcomplete-test "--dbpath") | |
176 (pcomplete-here* (pcomplete-dirs))) | |
177 ((pcomplete-test "--root") | |
178 (pcomplete-here* (pcomplete-dirs))) | |
179 ((pcomplete-test "--rcfile") | |
180 (pcomplete-here* (pcomplete-entries))))) | |
181 (if (pcomplete-match "^-" 0) | |
182 (pcomplete-opt "v") | |
183 (pcomplete-here)))) | |
184 ((memq mode '(install upgrade)) | |
185 (if (pcomplete-match "^--\\(.*\\)" 0) | |
186 (progn | |
187 (pcomplete-here* | |
188 (append | |
189 '("--allfiles" | |
190 "--badreloc" | |
191 "--dbpath" | |
192 "--excludedocs" | |
193 "--excludepath" | |
194 "--force" | |
195 "--hash" | |
196 "--ignorearch" | |
197 "--ignoreos" | |
198 "--ignoresize" | |
199 "--includedocs" | |
200 "--justdb" | |
201 "--nodeps" | |
202 "--noorder" | |
203 "--noscripts" | |
204 "--notriggers") | |
205 (if (eq mode 'upgrade) | |
206 '("--oldpackage")) | |
207 '("--percent" | |
208 "--prefix" | |
209 "--rcfile" | |
210 "--relocate" | |
211 "--replacefiles" | |
212 "--replacepkgs" | |
213 "--root"))) | |
214 (cond | |
215 ((pcomplete-test "--dbpath") | |
216 (pcomplete-here* (pcomplete-dirs))) | |
217 ((pcomplete-test "--relocate") | |
218 (pcomplete-here*)) | |
219 ((pcomplete-test "--rcfile") | |
220 (pcomplete-here* (pcomplete-entries))) | |
221 ((pcomplete-test "--excludepath") | |
222 (pcomplete-here* (pcomplete-entries))) | |
223 ((pcomplete-test "--root") | |
224 (pcomplete-here* (pcomplete-dirs))) | |
225 ((pcomplete-test "--prefix") | |
226 (pcomplete-here* (pcomplete-dirs))))) | |
227 (if (pcomplete-match "^-" 0) | |
228 (pcomplete-opt "vh") | |
229 (pcomplete-here (pcmpl-rpm-files))))) | |
230 ((or (pcomplete-test "--install") | |
231 (pcomplete-match "-[^-]*i")) | |
232 (setq mode 'install)) | |
233 ((or (pcomplete-test "--upgrade") | |
234 (pcomplete-match "-[^-]*U")) | |
235 (setq mode 'upgrade)) | |
236 ((or (eq mode 'erase) | |
237 (pcomplete-test "--erase") | |
238 (pcomplete-match "-[^-]*e")) | |
239 (setq mode 'erase) | |
240 (if (pcomplete-match "^--\\(.*\\)" 0) | |
241 (progn | |
242 (pcomplete-here* | |
243 '("--allmatches" | |
244 "--dbpath" | |
245 "--justdb" | |
246 "--nodeps" | |
247 "--noorder" | |
248 "--noscripts" | |
249 "--notriggers" | |
250 "--rcfile" | |
251 "--root")) | |
252 (cond | |
253 ((pcomplete-test "--dbpath") | |
254 (pcomplete-here* (pcomplete-dirs))) | |
255 ((pcomplete-test "--rcfile") | |
256 (pcomplete-here* (pcomplete-entries))) | |
257 ((pcomplete-test "--root") | |
258 (pcomplete-here* (pcomplete-dirs))))) | |
259 (if (pcomplete-match "^-" 0) | |
260 (pcomplete-opt "v") | |
261 (pcomplete-here (pcmpl-rpm-packages))))) | |
262 ((or (eq mode 'verify) | |
263 (pcomplete-test "--verify")) | |
264 (setq mode 'verify) | |
265 (if (pcomplete-match "^--\\(.*\\)" 0) | |
266 (progn | |
267 (pcomplete-here* | |
268 '("--dbpath" | |
269 "--nodeps" | |
270 "--nofiles" | |
271 "--nomd5" | |
272 "--rcfile" | |
273 "--root" | |
274 "--triggeredby" | |
275 "--whatprovides" | |
276 "--whatrequires")) | |
277 (cond | |
278 ((pcomplete-test "--dbpath") | |
279 (pcomplete-here* (pcomplete-dirs))) | |
280 ((pcomplete-test "--rcfile") | |
281 (pcomplete-here* (pcomplete-entries))) | |
282 ((pcomplete-test "--root") | |
283 (pcomplete-here* (pcomplete-dirs))) | |
284 ((pcomplete-test "--triggeredby") | |
285 (pcomplete-here* (pcmpl-rpm-packages))) | |
286 ((pcomplete-test "--whatprovides") | |
287 (pcomplete-here* | |
288 (pcmpl-rpm-all-query "--provides"))) | |
289 ((pcomplete-test "--whatrequires") | |
290 (pcomplete-here* | |
291 (pcmpl-rpm-all-query "--requires"))))) | |
292 (if (pcomplete-match "^-" 0) | |
293 (pcomplete-opt "af.p(pcmpl-rpm-files)v") | |
294 (pcomplete-here (pcmpl-rpm-packages))))) | |
295 ((or (memq mode '(build test)) | |
296 (pcomplete-match "\\`-[bt]")) | |
297 (setq mode (if (pcomplete-match "\\`-b") | |
298 'build | |
299 'test)) | |
300 (if (pcomplete-match "^--\\(.*\\)" 0) | |
301 (progn | |
302 (pcomplete-here* | |
303 '("--buildroot" | |
304 "--clean" | |
305 "--nobuild" | |
306 "--rcfile" | |
307 "--rmsource" | |
308 "--short-circuit" | |
309 "--sign" | |
310 "--target" | |
311 "--timecheck")) | |
312 (cond | |
313 ((pcomplete-test "--buildroot") | |
314 (pcomplete-here* (pcomplete-dirs))) | |
315 ((pcomplete-test "--rcfile") | |
316 (pcomplete-here* (pcomplete-entries))) | |
317 ((pcomplete-test "--timecheck") | |
318 (pcomplete-here*)))) | |
319 (if (pcomplete-match "^-" 0) | |
320 (pcomplete-opt "v") | |
321 (pcomplete-here | |
322 (if (eq mode 'test) | |
323 (pcomplete-dirs-or-entries "\\.tar\\'") | |
324 (pcomplete-dirs-or-entries "\\.spec\\'")))))) | |
325 (t | |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
29959
diff
changeset
|
326 (error "You must select a mode: -q, -i, -U, --verify, etc")))))) |
29959 | 327 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
328 ;; arch-tag: 4e64b490-fecf-430e-b2b9-70a8ad64b8c1 |
29959 | 329 ;;; pcmpl-rpm.el ends here |