Mercurial > emacs
annotate lisp/pcmpl-gnu.el @ 98789:e94744a9d7b1
(pmail): Remove a redundant message counter reset call; try to
minimize the attempts to show a message (ideally it should be done
once and only once).
(pmail-convert-babyl-to-mbox): Set up the global message variables
after inserting the converted mbox file into the Pmail buffer; avoid
an unecessary message display function call.
(pmail-show-message-maybe): Use the current message number when the
optional argument is not passed.
author | Paul Reilly <pmr@pajato.com> |
---|---|
date | Fri, 17 Oct 2008 02:43:35 +0000 |
parents | ee5932bf781d |
children | d42aff5ca541 |
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 |
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 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
31241
diff
changeset
|
21 ;;; Commentary: |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
31241
diff
changeset
|
22 |
29959 | 23 ;;; Code: |
24 | |
25 (provide 'pcmpl-gnu) | |
26 | |
27 (require 'pcomplete) | |
28 (require 'pcmpl-unix) | |
29 | |
30 (defgroup pcmpl-gnu nil | |
31 "Completions for GNU project tools." | |
32 :group 'pcomplete) | |
33 | |
34 ;; User Variables: | |
35 | |
36 (defcustom pcmpl-gnu-makefile-regexps | |
31241 | 37 '("\\`GNUmakefile" "\\`Makefile" "\\.mak\\'") |
29959 | 38 "*A list of regexps that will match Makefile names." |
39 :type '(repeat regexp) | |
40 :group 'pcmpl-gnu) | |
41 | |
42 ;; Functions: | |
43 | |
44 ;;;###autoload | |
45 (defun pcomplete/gzip () | |
46 "Completion for `gzip'." | |
47 (let ((pcomplete-help "(gzip)")) | |
48 (pcomplete-opt "cdfhlLnNqrStvV123456789") | |
49 (while (pcomplete-here | |
50 (pcmpl-gnu-zipped-files | |
51 (catch 'has-d-flag | |
52 (let ((args pcomplete-args)) | |
53 (while args | |
54 (if (string-match "\\`-.*[dt]" (car args)) | |
55 (throw 'has-d-flag t)) | |
56 (setq args (cdr args)))))))))) | |
57 | |
58 (defun pcmpl-gnu-zipped-files (unzip-p) | |
59 "Find all zipped or unzipped files: the inverse of UNZIP-P." | |
60 (pcomplete-entries | |
61 nil | |
62 (function | |
63 (lambda (entry) | |
64 (when (and (file-readable-p entry) | |
65 (file-regular-p entry)) | |
66 (let ((zipped (string-match "\\.\\(t?gz\\|\\(ta\\)?Z\\)\\'" | |
67 entry))) | |
68 (or (and unzip-p zipped) | |
69 (and (not unzip-p) (not zipped))))))))) | |
70 | |
71 ;;;###autoload | |
72 (defun pcomplete/bzip2 () | |
73 "Completion for `bzip2'." | |
74 (pcomplete-opt "hdzkftcqvLVs123456789") | |
75 (while (pcomplete-here | |
76 (pcmpl-gnu-bzipped-files | |
77 (catch 'has-d-flag | |
78 (let ((args pcomplete-args)) | |
79 (while args | |
80 (if (string-match "\\`-.*[dt]" (car args)) | |
81 (throw 'has-d-flag t)) | |
82 (setq args (cdr args))))))))) | |
83 | |
84 (defun pcmpl-gnu-bzipped-files (unzip-p) | |
85 "Find all zipped or unzipped files: the inverse of UNZIP-P." | |
86 (pcomplete-entries | |
87 nil | |
88 (function | |
89 (lambda (entry) | |
90 (when (and (file-readable-p entry) | |
91 (file-regular-p entry)) | |
92 (let ((zipped (string-match "\\.\\(t?z2\\|bz2\\)\\'" entry))) | |
93 (or (and unzip-p zipped) | |
94 (and (not unzip-p) (not zipped))))))))) | |
95 | |
96 ;;;###autoload | |
97 (defun pcomplete/make () | |
98 "Completion for GNU `make'." | |
99 (let ((pcomplete-help "(make)Top")) | |
100 (pcomplete-opt "bmC/def(pcmpl-gnu-makefile-names)hiI/j?kl?no.pqrsStvwW.") | |
101 (while (pcomplete-here (pcmpl-gnu-make-rule-names) nil 'identity)))) | |
102 | |
103 (defun pcmpl-gnu-makefile-names () | |
104 "Return a list of possible makefile names." | |
105 (let ((names (list t)) | |
106 (reg pcmpl-gnu-makefile-regexps)) | |
107 (while reg | |
108 (nconc names (pcomplete-entries (car reg))) | |
109 (setq reg (cdr reg))) | |
110 (cdr names))) | |
111 | |
112 (defun pcmpl-gnu-make-rule-names () | |
113 "Return a list of possible make rule names in MAKEFILE." | |
114 (let* ((minus-f (member "-f" pcomplete-args)) | |
31241 | 115 (makefile (or (cadr minus-f) |
116 (if (file-exists-p "GNUmakefile") | |
117 "GNUmakefile" | |
118 "Makefile"))) | |
29959 | 119 rules) |
120 (if (not (file-readable-p makefile)) | |
121 (unless minus-f (list "-f")) | |
122 (with-temp-buffer | |
123 (insert-file-contents-literally makefile) | |
124 (while (re-search-forward | |
125 (concat "^\\s-*\\([^\n#%.$][^:=\n]*\\)\\s-*:[^=]") nil t) | |
126 (setq rules (append (split-string (match-string 1)) rules)))) | |
127 (pcomplete-uniqify-list rules)))) | |
128 | |
129 (defcustom pcmpl-gnu-tarfile-regexp | |
130 "\\.t\\(ar\\(\\.\\(gz\\|bz2\\|Z\\)\\)?\\|gz\\|a[zZ]\\|z2\\)\\'" | |
131 "*A regexp which matches any tar archive." | |
132 :type 'regexp | |
133 :group 'pcmpl-gnu) | |
134 | |
135 (defvar pcmpl-gnu-tar-buffer nil) | |
136 | |
137 ;;;###autoload | |
138 (defun pcomplete/tar () | |
139 "Completion for the GNU tar utility." | |
140 ;; options that end in an equal sign will want further completion... | |
141 (let (saw-option complete-within) | |
142 (setq pcomplete-suffix-list (cons ?= pcomplete-suffix-list)) | |
143 (while (pcomplete-match "^-" 0) | |
144 (setq saw-option t) | |
145 (if (pcomplete-match "^--" 0) | |
146 (if (pcomplete-match "^--\\([^= \t\n\f]*\\)\\'" 0) | |
147 (pcomplete-here* | |
148 '("--absolute-names" | |
149 "--after-date=" | |
150 "--append" | |
151 "--atime-preserve" | |
152 "--backup" | |
153 "--block-number" | |
154 "--blocking-factor=" | |
155 "--catenate" | |
156 "--checkpoint" | |
157 "--compare" | |
158 "--compress" | |
159 "--concatenate" | |
160 "--confirmation" | |
161 "--create" | |
162 "--delete" | |
163 "--dereference" | |
164 "--diff" | |
165 "--directory=" | |
166 "--exclude=" | |
167 "--exclude-from=" | |
168 "--extract" | |
169 "--file=" | |
170 "--files-from=" | |
171 "--force-local" | |
172 "--get" | |
173 "--group=" | |
174 "--gzip" | |
175 "--help" | |
176 "--ignore-failed-read" | |
177 "--ignore-zeros" | |
178 "--incremental" | |
179 "--info-script=" | |
180 "--interactive" | |
181 "--keep-old-files" | |
182 "--label=" | |
183 "--list" | |
184 "--listed-incremental" | |
185 "--mode=" | |
186 "--modification-time" | |
187 "--multi-volume" | |
188 "--new-volume-script=" | |
189 "--newer=" | |
190 "--newer-mtime" | |
191 "--no-recursion" | |
192 "--null" | |
193 "--numeric-owner" | |
194 "--old-archive" | |
195 "--one-file-system" | |
196 "--owner=" | |
197 "--portability" | |
198 "--posix" | |
199 "--preserve" | |
200 "--preserve-order" | |
201 "--preserve-permissions" | |
202 "--read-full-records" | |
203 "--record-size=" | |
204 "--recursive-unlink" | |
205 "--remove-files" | |
206 "--rsh-command=" | |
207 "--same-order" | |
208 "--same-owner" | |
209 "--same-permissions" | |
210 "--sparse" | |
211 "--starting-file=" | |
212 "--suffix=" | |
213 "--tape-length=" | |
214 "--to-stdout" | |
215 "--totals" | |
216 "--uncompress" | |
217 "--ungzip" | |
218 "--unlink-first" | |
219 "--update" | |
220 "--use-compress-program=" | |
221 "--verbose" | |
222 "--verify" | |
223 "--version" | |
224 "--volno-file="))) | |
225 (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")) | |
226 (cond | |
227 ((pcomplete-match "\\`--after-date=" 0) | |
228 (pcomplete-here*)) | |
229 ((pcomplete-match "\\`--backup=" 0) | |
230 (pcomplete-here*)) | |
231 ((pcomplete-match "\\`--blocking-factor=" 0) | |
232 (pcomplete-here*)) | |
233 ((pcomplete-match "\\`--directory=\\(.*\\)" 0) | |
234 (pcomplete-here* (pcomplete-dirs) | |
235 (pcomplete-match-string 1 0))) | |
236 ((pcomplete-match "\\`--exclude-from=\\(.*\\)" 0) | |
237 (pcomplete-here* (pcomplete-entries) | |
238 (pcomplete-match-string 1 0))) | |
239 ((pcomplete-match "\\`--exclude=" 0) | |
240 (pcomplete-here*)) | |
241 ((pcomplete-match "\\`--\\(extract\\|list\\)\\'" 0) | |
242 (setq complete-within t)) | |
243 ((pcomplete-match "\\`--file=\\(.*\\)" 0) | |
244 (pcomplete-here* (pcomplete-dirs-or-entries pcmpl-gnu-tarfile-regexp) | |
245 (pcomplete-match-string 1 0))) | |
246 ((pcomplete-match "\\`--files-from=\\(.*\\)" 0) | |
247 (pcomplete-here* (pcomplete-entries) | |
248 (pcomplete-match-string 1 0))) | |
249 ((pcomplete-match "\\`--group=\\(.*\\)" 0) | |
250 (pcomplete-here* (pcmpl-unix-group-names) | |
251 (pcomplete-match-string 1 0))) | |
252 ((pcomplete-match "\\`--info-script=\\(.*\\)" 0) | |
253 (pcomplete-here* (pcomplete-entries) | |
254 (pcomplete-match-string 1 0))) | |
255 ((pcomplete-match "\\`--label=" 0) | |
256 (pcomplete-here*)) | |
257 ((pcomplete-match "\\`--mode=" 0) | |
258 (pcomplete-here*)) | |
259 ((pcomplete-match "\\`--new-volume-script=\\(.*\\)" 0) | |
260 (pcomplete-here* (pcomplete-entries) | |
261 (pcomplete-match-string 1 0))) | |
262 ((pcomplete-match "\\`--newer=" 0) | |
263 (pcomplete-here*)) | |
264 ((pcomplete-match "\\`--owner=\\(.*\\)" 0) | |
265 (pcomplete-here* (pcmpl-unix-user-names) | |
266 (pcomplete-match-string 1 0))) | |
267 ((pcomplete-match "\\`--record-size=" 0) | |
268 (pcomplete-here*)) | |
269 ((pcomplete-match "\\`--rsh-command=\\(.*\\)" 0) | |
270 (pcomplete-here* (funcall pcomplete-command-completion-function) | |
271 (pcomplete-match-string 1 0))) | |
272 ((pcomplete-match "\\`--starting-file=\\(.*\\)" 0) | |
273 (pcomplete-here* (pcomplete-entries) | |
274 (pcomplete-match-string 1 0))) | |
275 ((pcomplete-match "\\`--suffix=" 0) | |
276 (pcomplete-here*)) | |
277 ((pcomplete-match "\\`--tape-length=" 0) | |
278 (pcomplete-here*)) | |
279 ((pcomplete-match "\\`--use-compress-program=\\(.*\\)" 0) | |
280 (pcomplete-here* (funcall pcomplete-command-completion-function) | |
281 (pcomplete-match-string 1 0))) | |
282 ((pcomplete-match "\\`--volno-file=\\(.*\\)" 0) | |
283 (pcomplete-here* (pcomplete-entries) | |
284 (pcomplete-match-string 1 0))))) | |
285 (setq pcomplete-suffix-list (cdr pcomplete-suffix-list)) | |
286 (unless saw-option | |
287 (pcomplete-here | |
288 (mapcar 'char-to-string | |
289 (string-to-list | |
290 "01234567ABCFGIKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz"))) | |
291 (if (pcomplete-match "[xt]" 'first 1) | |
292 (setq complete-within t))) | |
293 (pcomplete-here (pcomplete-dirs-or-entries pcmpl-gnu-tarfile-regexp)) | |
294 (setq pcmpl-gnu-tar-buffer (find-file-noselect (pcomplete-arg 1))) | |
295 (while (pcomplete-here | |
296 (if complete-within | |
297 (with-current-buffer pcmpl-gnu-tar-buffer | |
298 (mapcar | |
299 (function | |
300 (lambda (entry) | |
301 (tar-header-name (cdr entry)))) | |
302 tar-parse-info)) | |
303 (pcomplete-entries)) | |
304 nil 'identity)))) | |
305 | |
306 ;;;###autoload | |
307 (defalias 'pcomplete/gdb 'pcomplete/xargs) | |
308 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
309 ;; arch-tag: 06d2b429-dcb1-4a57-84e1-f70d87781183 |
29959 | 310 ;;; pcmpl-gnu.el ends here |