Mercurial > emacs
annotate lisp/pcmpl-gnu.el @ 64612:6926a2764ae6
(gc_cons_threshold, gc_relative_threshold): Declared.
(gc_cons_combined_threshold): Declaration deleted.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 23 Jul 2005 19:08:32 +0000 |
parents | 6fb026ad601f |
children | 41bb365f41c4 f9a65d7ebd29 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
31241
diff
changeset
|
1 ;;; pcmpl-gnu.el --- completions for GNU project tools |
29959 | 2 |
3 ;; Copyright (C) 1999, 2000 Free Software Foundation | |
4 | |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 2, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 19 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 ;; Boston, MA 02110-1301, USA. | |
29959 | 21 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
31241
diff
changeset
|
22 ;;; Commentary: |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
31241
diff
changeset
|
23 |
29959 | 24 ;;; Code: |
25 | |
26 (provide 'pcmpl-gnu) | |
27 | |
28 (require 'pcomplete) | |
29 (require 'pcmpl-unix) | |
30 | |
31 (defgroup pcmpl-gnu nil | |
32 "Completions for GNU project tools." | |
33 :group 'pcomplete) | |
34 | |
35 ;; User Variables: | |
36 | |
37 (defcustom pcmpl-gnu-makefile-regexps | |
31241 | 38 '("\\`GNUmakefile" "\\`Makefile" "\\.mak\\'") |
29959 | 39 "*A list of regexps that will match Makefile names." |
40 :type '(repeat regexp) | |
41 :group 'pcmpl-gnu) | |
42 | |
43 ;; Functions: | |
44 | |
45 ;;;###autoload | |
46 (defun pcomplete/gzip () | |
47 "Completion for `gzip'." | |
48 (let ((pcomplete-help "(gzip)")) | |
49 (pcomplete-opt "cdfhlLnNqrStvV123456789") | |
50 (while (pcomplete-here | |
51 (pcmpl-gnu-zipped-files | |
52 (catch 'has-d-flag | |
53 (let ((args pcomplete-args)) | |
54 (while args | |
55 (if (string-match "\\`-.*[dt]" (car args)) | |
56 (throw 'has-d-flag t)) | |
57 (setq args (cdr args)))))))))) | |
58 | |
59 (defun pcmpl-gnu-zipped-files (unzip-p) | |
60 "Find all zipped or unzipped files: the inverse of UNZIP-P." | |
61 (pcomplete-entries | |
62 nil | |
63 (function | |
64 (lambda (entry) | |
65 (when (and (file-readable-p entry) | |
66 (file-regular-p entry)) | |
67 (let ((zipped (string-match "\\.\\(t?gz\\|\\(ta\\)?Z\\)\\'" | |
68 entry))) | |
69 (or (and unzip-p zipped) | |
70 (and (not unzip-p) (not zipped))))))))) | |
71 | |
72 ;;;###autoload | |
73 (defun pcomplete/bzip2 () | |
74 "Completion for `bzip2'." | |
75 (pcomplete-opt "hdzkftcqvLVs123456789") | |
76 (while (pcomplete-here | |
77 (pcmpl-gnu-bzipped-files | |
78 (catch 'has-d-flag | |
79 (let ((args pcomplete-args)) | |
80 (while args | |
81 (if (string-match "\\`-.*[dt]" (car args)) | |
82 (throw 'has-d-flag t)) | |
83 (setq args (cdr args))))))))) | |
84 | |
85 (defun pcmpl-gnu-bzipped-files (unzip-p) | |
86 "Find all zipped or unzipped files: the inverse of UNZIP-P." | |
87 (pcomplete-entries | |
88 nil | |
89 (function | |
90 (lambda (entry) | |
91 (when (and (file-readable-p entry) | |
92 (file-regular-p entry)) | |
93 (let ((zipped (string-match "\\.\\(t?z2\\|bz2\\)\\'" entry))) | |
94 (or (and unzip-p zipped) | |
95 (and (not unzip-p) (not zipped))))))))) | |
96 | |
97 ;;;###autoload | |
98 (defun pcomplete/make () | |
99 "Completion for GNU `make'." | |
100 (let ((pcomplete-help "(make)Top")) | |
101 (pcomplete-opt "bmC/def(pcmpl-gnu-makefile-names)hiI/j?kl?no.pqrsStvwW.") | |
102 (while (pcomplete-here (pcmpl-gnu-make-rule-names) nil 'identity)))) | |
103 | |
104 (defun pcmpl-gnu-makefile-names () | |
105 "Return a list of possible makefile names." | |
106 (let ((names (list t)) | |
107 (reg pcmpl-gnu-makefile-regexps)) | |
108 (while reg | |
109 (nconc names (pcomplete-entries (car reg))) | |
110 (setq reg (cdr reg))) | |
111 (cdr names))) | |
112 | |
113 (defun pcmpl-gnu-make-rule-names () | |
114 "Return a list of possible make rule names in MAKEFILE." | |
115 (let* ((minus-f (member "-f" pcomplete-args)) | |
31241 | 116 (makefile (or (cadr minus-f) |
117 (if (file-exists-p "GNUmakefile") | |
118 "GNUmakefile" | |
119 "Makefile"))) | |
29959 | 120 rules) |
121 (if (not (file-readable-p makefile)) | |
122 (unless minus-f (list "-f")) | |
123 (with-temp-buffer | |
124 (insert-file-contents-literally makefile) | |
125 (while (re-search-forward | |
126 (concat "^\\s-*\\([^\n#%.$][^:=\n]*\\)\\s-*:[^=]") nil t) | |
127 (setq rules (append (split-string (match-string 1)) rules)))) | |
128 (pcomplete-uniqify-list rules)))) | |
129 | |
130 (defcustom pcmpl-gnu-tarfile-regexp | |
131 "\\.t\\(ar\\(\\.\\(gz\\|bz2\\|Z\\)\\)?\\|gz\\|a[zZ]\\|z2\\)\\'" | |
132 "*A regexp which matches any tar archive." | |
133 :type 'regexp | |
134 :group 'pcmpl-gnu) | |
135 | |
136 (defvar pcmpl-gnu-tar-buffer nil) | |
137 | |
138 ;;;###autoload | |
139 (defun pcomplete/tar () | |
140 "Completion for the GNU tar utility." | |
141 ;; options that end in an equal sign will want further completion... | |
142 (let (saw-option complete-within) | |
143 (setq pcomplete-suffix-list (cons ?= pcomplete-suffix-list)) | |
144 (while (pcomplete-match "^-" 0) | |
145 (setq saw-option t) | |
146 (if (pcomplete-match "^--" 0) | |
147 (if (pcomplete-match "^--\\([^= \t\n\f]*\\)\\'" 0) | |
148 (pcomplete-here* | |
149 '("--absolute-names" | |
150 "--after-date=" | |
151 "--append" | |
152 "--atime-preserve" | |
153 "--backup" | |
154 "--block-number" | |
155 "--blocking-factor=" | |
156 "--catenate" | |
157 "--checkpoint" | |
158 "--compare" | |
159 "--compress" | |
160 "--concatenate" | |
161 "--confirmation" | |
162 "--create" | |
163 "--delete" | |
164 "--dereference" | |
165 "--diff" | |
166 "--directory=" | |
167 "--exclude=" | |
168 "--exclude-from=" | |
169 "--extract" | |
170 "--file=" | |
171 "--files-from=" | |
172 "--force-local" | |
173 "--get" | |
174 "--group=" | |
175 "--gzip" | |
176 "--help" | |
177 "--ignore-failed-read" | |
178 "--ignore-zeros" | |
179 "--incremental" | |
180 "--info-script=" | |
181 "--interactive" | |
182 "--keep-old-files" | |
183 "--label=" | |
184 "--list" | |
185 "--listed-incremental" | |
186 "--mode=" | |
187 "--modification-time" | |
188 "--multi-volume" | |
189 "--new-volume-script=" | |
190 "--newer=" | |
191 "--newer-mtime" | |
192 "--no-recursion" | |
193 "--null" | |
194 "--numeric-owner" | |
195 "--old-archive" | |
196 "--one-file-system" | |
197 "--owner=" | |
198 "--portability" | |
199 "--posix" | |
200 "--preserve" | |
201 "--preserve-order" | |
202 "--preserve-permissions" | |
203 "--read-full-records" | |
204 "--record-size=" | |
205 "--recursive-unlink" | |
206 "--remove-files" | |
207 "--rsh-command=" | |
208 "--same-order" | |
209 "--same-owner" | |
210 "--same-permissions" | |
211 "--sparse" | |
212 "--starting-file=" | |
213 "--suffix=" | |
214 "--tape-length=" | |
215 "--to-stdout" | |
216 "--totals" | |
217 "--uncompress" | |
218 "--ungzip" | |
219 "--unlink-first" | |
220 "--update" | |
221 "--use-compress-program=" | |
222 "--verbose" | |
223 "--verify" | |
224 "--version" | |
225 "--volno-file="))) | |
226 (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")) | |
227 (cond | |
228 ((pcomplete-match "\\`--after-date=" 0) | |
229 (pcomplete-here*)) | |
230 ((pcomplete-match "\\`--backup=" 0) | |
231 (pcomplete-here*)) | |
232 ((pcomplete-match "\\`--blocking-factor=" 0) | |
233 (pcomplete-here*)) | |
234 ((pcomplete-match "\\`--directory=\\(.*\\)" 0) | |
235 (pcomplete-here* (pcomplete-dirs) | |
236 (pcomplete-match-string 1 0))) | |
237 ((pcomplete-match "\\`--exclude-from=\\(.*\\)" 0) | |
238 (pcomplete-here* (pcomplete-entries) | |
239 (pcomplete-match-string 1 0))) | |
240 ((pcomplete-match "\\`--exclude=" 0) | |
241 (pcomplete-here*)) | |
242 ((pcomplete-match "\\`--\\(extract\\|list\\)\\'" 0) | |
243 (setq complete-within t)) | |
244 ((pcomplete-match "\\`--file=\\(.*\\)" 0) | |
245 (pcomplete-here* (pcomplete-dirs-or-entries pcmpl-gnu-tarfile-regexp) | |
246 (pcomplete-match-string 1 0))) | |
247 ((pcomplete-match "\\`--files-from=\\(.*\\)" 0) | |
248 (pcomplete-here* (pcomplete-entries) | |
249 (pcomplete-match-string 1 0))) | |
250 ((pcomplete-match "\\`--group=\\(.*\\)" 0) | |
251 (pcomplete-here* (pcmpl-unix-group-names) | |
252 (pcomplete-match-string 1 0))) | |
253 ((pcomplete-match "\\`--info-script=\\(.*\\)" 0) | |
254 (pcomplete-here* (pcomplete-entries) | |
255 (pcomplete-match-string 1 0))) | |
256 ((pcomplete-match "\\`--label=" 0) | |
257 (pcomplete-here*)) | |
258 ((pcomplete-match "\\`--mode=" 0) | |
259 (pcomplete-here*)) | |
260 ((pcomplete-match "\\`--new-volume-script=\\(.*\\)" 0) | |
261 (pcomplete-here* (pcomplete-entries) | |
262 (pcomplete-match-string 1 0))) | |
263 ((pcomplete-match "\\`--newer=" 0) | |
264 (pcomplete-here*)) | |
265 ((pcomplete-match "\\`--owner=\\(.*\\)" 0) | |
266 (pcomplete-here* (pcmpl-unix-user-names) | |
267 (pcomplete-match-string 1 0))) | |
268 ((pcomplete-match "\\`--record-size=" 0) | |
269 (pcomplete-here*)) | |
270 ((pcomplete-match "\\`--rsh-command=\\(.*\\)" 0) | |
271 (pcomplete-here* (funcall pcomplete-command-completion-function) | |
272 (pcomplete-match-string 1 0))) | |
273 ((pcomplete-match "\\`--starting-file=\\(.*\\)" 0) | |
274 (pcomplete-here* (pcomplete-entries) | |
275 (pcomplete-match-string 1 0))) | |
276 ((pcomplete-match "\\`--suffix=" 0) | |
277 (pcomplete-here*)) | |
278 ((pcomplete-match "\\`--tape-length=" 0) | |
279 (pcomplete-here*)) | |
280 ((pcomplete-match "\\`--use-compress-program=\\(.*\\)" 0) | |
281 (pcomplete-here* (funcall pcomplete-command-completion-function) | |
282 (pcomplete-match-string 1 0))) | |
283 ((pcomplete-match "\\`--volno-file=\\(.*\\)" 0) | |
284 (pcomplete-here* (pcomplete-entries) | |
285 (pcomplete-match-string 1 0))))) | |
286 (setq pcomplete-suffix-list (cdr pcomplete-suffix-list)) | |
287 (unless saw-option | |
288 (pcomplete-here | |
289 (mapcar 'char-to-string | |
290 (string-to-list | |
291 "01234567ABCFGIKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz"))) | |
292 (if (pcomplete-match "[xt]" 'first 1) | |
293 (setq complete-within t))) | |
294 (pcomplete-here (pcomplete-dirs-or-entries pcmpl-gnu-tarfile-regexp)) | |
295 (setq pcmpl-gnu-tar-buffer (find-file-noselect (pcomplete-arg 1))) | |
296 (while (pcomplete-here | |
297 (if complete-within | |
298 (with-current-buffer pcmpl-gnu-tar-buffer | |
299 (mapcar | |
300 (function | |
301 (lambda (entry) | |
302 (tar-header-name (cdr entry)))) | |
303 tar-parse-info)) | |
304 (pcomplete-entries)) | |
305 nil 'identity)))) | |
306 | |
307 ;;;###autoload | |
308 (defalias 'pcomplete/gdb 'pcomplete/xargs) | |
309 | |
52401 | 310 ;;; arch-tag: 06d2b429-dcb1-4a57-84e1-f70d87781183 |
29959 | 311 ;;; pcmpl-gnu.el ends here |