diff options
| author | Gerd Moellmann | 2000-06-27 10:55:46 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-06-27 10:55:46 +0000 |
| commit | 4fa9f63662512bbf5107aafce22f1c12d292ab03 (patch) | |
| tree | 2138ed07789a931625df9c2a2164a119af56a660 | |
| parent | d365421f859f6c88e3dc4b610c87adaef3cb099c (diff) | |
| download | emacs-4fa9f63662512bbf5107aafce22f1c12d292ab03.tar.gz emacs-4fa9f63662512bbf5107aafce22f1c12d292ab03.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/pcmpl-cvs.el | 186 | ||||
| -rw-r--r-- | lisp/pcmpl-gnu.el | 305 | ||||
| -rw-r--r-- | lisp/pcmpl-linux.el | 108 | ||||
| -rw-r--r-- | lisp/pcmpl-rpm.el | 329 | ||||
| -rw-r--r-- | lisp/pcmpl-unix.el | 123 |
6 files changed, 1056 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c4d6fc6eec4..d5cf54fe107 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2000-06-27 Gerd Moellmann <gerd@gnu.org> | 1 | 2000-06-27 Gerd Moellmann <gerd@gnu.org> |
| 2 | 2 | ||
| 3 | * help.el (describe-variable): Don't insert a second `'s' in front | ||
| 4 | of the string `value is shown below'. Since the syntax-table is | ||
| 5 | set to emacs-lisp-mode-syntax-table, forward-sexp skips over | ||
| 6 | an existing `'s', so that this won't be deleted. | ||
| 7 | |||
| 3 | * pcmpl-cvs.el, pcmpl-gnu.el, pcmpl-linux.el, pcmpl-rpm.el: | 8 | * pcmpl-cvs.el, pcmpl-gnu.el, pcmpl-linux.el, pcmpl-rpm.el: |
| 4 | * pcmpl-unix.el: New files. | 9 | * pcmpl-unix.el: New files. |
| 5 | 10 | ||
diff --git a/lisp/pcmpl-cvs.el b/lisp/pcmpl-cvs.el new file mode 100644 index 00000000000..854479d4305 --- /dev/null +++ b/lisp/pcmpl-cvs.el | |||
| @@ -0,0 +1,186 @@ | |||
| 1 | ;;; pcmpl-cvs --- functions for dealing with cvs completions | ||
| 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 | ||
| 19 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 20 | ;; Boston, MA 02111-1307, USA. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; These functions provide completion rules for the `cvs' tool. | ||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | |||
| 28 | (provide 'pcmpl-cvs) | ||
| 29 | |||
| 30 | (require 'pcomplete) | ||
| 31 | (require 'executable) | ||
| 32 | |||
| 33 | (defgroup pcmpl-cvs nil | ||
| 34 | "Functions for dealing with CVS completions" | ||
| 35 | :group 'pcomplete) | ||
| 36 | |||
| 37 | ;; User Variables: | ||
| 38 | |||
| 39 | (defcustom pcmpl-cvs-binary (or (executable-find "cvs") "cvs") | ||
| 40 | "*The full path of the 'cvs' binary." | ||
| 41 | :type 'file | ||
| 42 | :group 'pcmpl-cvs) | ||
| 43 | |||
| 44 | ;; Functions: | ||
| 45 | |||
| 46 | ;;;###autoload | ||
| 47 | (defun pcomplete/cvs () | ||
| 48 | "Completion rules for the `cvs' command." | ||
| 49 | (let ((pcomplete-help "(cvs)Invoking CVS")) | ||
| 50 | (pcomplete-opt "HQqrwlntvfab/T/e*d/z?s") | ||
| 51 | (pcomplete-here* (pcmpl-cvs-commands)) | ||
| 52 | (cond ((pcomplete-test "add") | ||
| 53 | (setq pcomplete-help "(cvs)Adding files") | ||
| 54 | (pcomplete-opt "k?m?") | ||
| 55 | (while (pcomplete-here (pcmpl-cvs-entries '(??))))) | ||
| 56 | ((pcomplete-test "remove") | ||
| 57 | (setq pcomplete-help "(cvs)Removing files") | ||
| 58 | (pcomplete-opt "flR") | ||
| 59 | (while (pcomplete-here (pcmpl-cvs-entries '(?U))))) | ||
| 60 | ((pcomplete-test "init") | ||
| 61 | (setq pcomplete-help "(cvs)Creating a repository")) | ||
| 62 | ((pcomplete-test '("login" "logout")) | ||
| 63 | (setq pcomplete-help "(cvs)Password authentication client")) | ||
| 64 | ((pcomplete-test "import") | ||
| 65 | (setq pcomplete-help "(cvs)import") | ||
| 66 | (pcomplete-opt "dk?I(pcmpl-cvs-entries '(??))b?m?W?")) | ||
| 67 | ((pcomplete-test "checkout") | ||
| 68 | (setq pcomplete-help "(cvs)checkout") | ||
| 69 | (pcomplete-opt "ANPRcflnpsr?D?d/k?j?") | ||
| 70 | (pcomplete-here (pcmpl-cvs-modules))) | ||
| 71 | ((pcomplete-test "rtag") | ||
| 72 | (setq pcomplete-help "(cvs)Creating a branch") | ||
| 73 | (pcomplete-opt "aflRndbr?DF") | ||
| 74 | (pcomplete-here (pcmpl-cvs-modules))) | ||
| 75 | ((pcomplete-test "release") | ||
| 76 | (setq pcomplete-help "(cvs)release") | ||
| 77 | (pcomplete-opt "d") | ||
| 78 | (while (pcomplete-here (pcomplete-dirs)))) | ||
| 79 | ((pcomplete-test "export") | ||
| 80 | (setq pcomplete-help "(cvs)export") | ||
| 81 | (pcomplete-opt "NflRnr?D?d/k?") | ||
| 82 | (pcomplete-here (pcmpl-cvs-modules))) | ||
| 83 | ((pcomplete-test "commit") | ||
| 84 | (setq pcomplete-help "(cvs)commit files") | ||
| 85 | (pcomplete-opt "nRlfF.m?r(pcmpl-cvs-tags '(?M ?R ?A))") | ||
| 86 | (while (pcomplete-here (pcmpl-cvs-entries '(?M ?R ?A))))) | ||
| 87 | ((pcomplete-test "diff") | ||
| 88 | (setq pcomplete-help "(cvs)Viewing differences") | ||
| 89 | (let ((opt-index pcomplete-index) | ||
| 90 | saw-backdate) | ||
| 91 | (pcomplete-opt "lRD?Nr(pcmpl-cvs-tags)") | ||
| 92 | (while (< opt-index pcomplete-index) | ||
| 93 | (if (pcomplete-match "^-[Dr]" (- pcomplete-index opt-index)) | ||
| 94 | (setq saw-backdate t opt-index pcomplete-index) | ||
| 95 | (setq opt-index (1+ opt-index)))) | ||
| 96 | (while (pcomplete-here | ||
| 97 | (pcmpl-cvs-entries (unless saw-backdate '(?M))))))) | ||
| 98 | ((pcomplete-test "unedit") | ||
| 99 | (setq pcomplete-help "(cvs)Editing files") | ||
| 100 | (pcomplete-opt "lR") | ||
| 101 | (while (pcomplete-here (pcmpl-cvs-entries '(?M ?R ?A))))) | ||
| 102 | ((pcomplete-test "update") | ||
| 103 | (setq pcomplete-help "(cvs)update") | ||
| 104 | (pcomplete-opt | ||
| 105 | (concat "APdflRpk?r(pcmpl-cvs-tags '(?U ?P))D?" | ||
| 106 | "j(pcmpl-cvs-tags '(?U ?P))" | ||
| 107 | "I(pcmpl-cvs-entries '(??))W?")) | ||
| 108 | (while (pcomplete-here (pcmpl-cvs-entries '(?U ?P))))) | ||
| 109 | (t | ||
| 110 | (while (pcomplete-here (pcmpl-cvs-entries))))))) | ||
| 111 | |||
| 112 | (defun pcmpl-cvs-commands () | ||
| 113 | "Return a list of available CVS commands." | ||
| 114 | (with-temp-buffer | ||
| 115 | (call-process pcmpl-cvs-binary nil t nil "--help-commands") | ||
| 116 | (goto-char (point-min)) | ||
| 117 | (let (cmds) | ||
| 118 | (while (re-search-forward "^\\s-+\\([a-z]+\\)" nil t) | ||
| 119 | (setq cmds (cons (match-string 1) cmds))) | ||
| 120 | (pcomplete-uniqify-list cmds)))) | ||
| 121 | |||
| 122 | (defun pcmpl-cvs-modules () | ||
| 123 | "Return a list of available modules under CVS." | ||
| 124 | (with-temp-buffer | ||
| 125 | (call-process pcmpl-cvs-binary nil t nil "checkout" "-c") | ||
| 126 | (goto-char (point-min)) | ||
| 127 | (let (entries) | ||
| 128 | (while (re-search-forward "\\(\\S-+\\)$" nil t) | ||
| 129 | (setq entries (cons (match-string 1) entries))) | ||
| 130 | (pcomplete-uniqify-list entries)))) | ||
| 131 | |||
| 132 | (defun pcmpl-cvs-tags (&optional opers) | ||
| 133 | "Return all the tags which could apply to the files related to OPERS." | ||
| 134 | (let ((entries (pcmpl-cvs-entries opers)) | ||
| 135 | tags) | ||
| 136 | (with-temp-buffer | ||
| 137 | (apply 'call-process pcmpl-cvs-binary nil t nil | ||
| 138 | "status" "-v" entries) | ||
| 139 | (goto-char (point-min)) | ||
| 140 | (while (re-search-forward "Existing Tags:" nil t) | ||
| 141 | (forward-line) | ||
| 142 | (while (not (looking-at "^$")) | ||
| 143 | (unless (looking-at "^\\s-+\\(\\S-+\\)\\s-+") | ||
| 144 | (error "Error in output from `cvs status -v'")) | ||
| 145 | (setq tags (cons (match-string 1) tags)) | ||
| 146 | (forward-line)))) | ||
| 147 | (pcomplete-uniqify-list tags))) | ||
| 148 | |||
| 149 | (defun pcmpl-cvs-entries (&optional opers) | ||
| 150 | "Return the Entries for the current directory. | ||
| 151 | If OPERS is a list of characters, return entries for which that | ||
| 152 | operation character applies, as displayed by 'cvs -n update'." | ||
| 153 | (let* ((arg (pcomplete-arg)) | ||
| 154 | (dir (file-name-as-directory | ||
| 155 | (or (file-name-directory arg) ""))) | ||
| 156 | (nondir (or (file-name-nondirectory arg) "")) | ||
| 157 | entries) | ||
| 158 | (if opers | ||
| 159 | (with-temp-buffer | ||
| 160 | (and dir (cd dir)) | ||
| 161 | (call-process pcmpl-cvs-binary nil t nil | ||
| 162 | "-q" "-n" "-f" "update"); "-l") | ||
| 163 | (goto-char (point-min)) | ||
| 164 | (while (re-search-forward "^\\(.\\) \\(.+\\)$" nil t) | ||
| 165 | (if (memq (string-to-char (match-string 1)) opers) | ||
| 166 | (setq entries (cons (match-string 2) entries))))) | ||
| 167 | (with-temp-buffer | ||
| 168 | (insert-file-contents (concat dir "CVS/Entries")) | ||
| 169 | (goto-char (point-min)) | ||
| 170 | (while (not (eobp)) | ||
| 171 | (let* ((line (buffer-substring (line-beginning-position) | ||
| 172 | (line-end-position))) | ||
| 173 | (fields (split-string line "/")) | ||
| 174 | text) | ||
| 175 | (if (eq (aref line 0) ?/) | ||
| 176 | (setq fields (cons "" fields))) | ||
| 177 | (setq text (nth 1 fields)) | ||
| 178 | (when text | ||
| 179 | (if (string= (nth 0 fields) "D") | ||
| 180 | (setq text (file-name-as-directory text))) | ||
| 181 | (setq entries (cons text entries)))) | ||
| 182 | (forward-line)))) | ||
| 183 | (setq pcomplete-stub nondir) | ||
| 184 | (pcomplete-uniqify-list entries))) | ||
| 185 | |||
| 186 | ;;; pcmpl-cvs.el ends here | ||
diff --git a/lisp/pcmpl-gnu.el b/lisp/pcmpl-gnu.el new file mode 100644 index 00000000000..f390f541e25 --- /dev/null +++ b/lisp/pcmpl-gnu.el | |||
| @@ -0,0 +1,305 @@ | |||
| 1 | ;;; pcmpl-gnu --- completions for GNU project tools | ||
| 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 | ||
| 19 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 20 | ;; Boston, MA 02111-1307, USA. | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (provide 'pcmpl-gnu) | ||
| 25 | |||
| 26 | (require 'pcomplete) | ||
| 27 | (require 'pcmpl-unix) | ||
| 28 | |||
| 29 | (defgroup pcmpl-gnu nil | ||
| 30 | "Completions for GNU project tools." | ||
| 31 | :group 'pcomplete) | ||
| 32 | |||
| 33 | ;; User Variables: | ||
| 34 | |||
| 35 | (defcustom pcmpl-gnu-makefile-regexps | ||
| 36 | '("\\`Makefile\\." "\\.mak\\'") | ||
| 37 | "*A list of regexps that will match Makefile names." | ||
| 38 | :type '(repeat regexp) | ||
| 39 | :group 'pcmpl-gnu) | ||
| 40 | |||
| 41 | ;; Functions: | ||
| 42 | |||
| 43 | ;;;###autoload | ||
| 44 | (defun pcomplete/gzip () | ||
| 45 | "Completion for `gzip'." | ||
| 46 | (let ((pcomplete-help "(gzip)")) | ||
| 47 | (pcomplete-opt "cdfhlLnNqrStvV123456789") | ||
| 48 | (while (pcomplete-here | ||
| 49 | (pcmpl-gnu-zipped-files | ||
| 50 | (catch 'has-d-flag | ||
| 51 | (let ((args pcomplete-args)) | ||
| 52 | (while args | ||
| 53 | (if (string-match "\\`-.*[dt]" (car args)) | ||
| 54 | (throw 'has-d-flag t)) | ||
| 55 | (setq args (cdr args)))))))))) | ||
| 56 | |||
| 57 | (defun pcmpl-gnu-zipped-files (unzip-p) | ||
| 58 | "Find all zipped or unzipped files: the inverse of UNZIP-P." | ||
| 59 | (pcomplete-entries | ||
| 60 | nil | ||
| 61 | (function | ||
| 62 | (lambda (entry) | ||
| 63 | (when (and (file-readable-p entry) | ||
| 64 | (file-regular-p entry)) | ||
| 65 | (let ((zipped (string-match "\\.\\(t?gz\\|\\(ta\\)?Z\\)\\'" | ||
| 66 | entry))) | ||
| 67 | (or (and unzip-p zipped) | ||
| 68 | (and (not unzip-p) (not zipped))))))))) | ||
| 69 | |||
| 70 | ;;;###autoload | ||
| 71 | (defun pcomplete/bzip2 () | ||
| 72 | "Completion for `bzip2'." | ||
| 73 | (pcomplete-opt "hdzkftcqvLVs123456789") | ||
| 74 | (while (pcomplete-here | ||
| 75 | (pcmpl-gnu-bzipped-files | ||
| 76 | (catch 'has-d-flag | ||
| 77 | (let ((args pcomplete-args)) | ||
| 78 | (while args | ||
| 79 | (if (string-match "\\`-.*[dt]" (car args)) | ||
| 80 | (throw 'has-d-flag t)) | ||
| 81 | (setq args (cdr args))))))))) | ||
| 82 | |||
| 83 | (defun pcmpl-gnu-bzipped-files (unzip-p) | ||
| 84 | "Find all zipped or unzipped files: the inverse of UNZIP-P." | ||
| 85 | (pcomplete-entries | ||
| 86 | nil | ||
| 87 | (function | ||
| 88 | (lambda (entry) | ||
| 89 | (when (and (file-readable-p entry) | ||
| 90 | (file-regular-p entry)) | ||
| 91 | (let ((zipped (string-match "\\.\\(t?z2\\|bz2\\)\\'" entry))) | ||
| 92 | (or (and unzip-p zipped) | ||
| 93 | (and (not unzip-p) (not zipped))))))))) | ||
| 94 | |||
| 95 | ;;;###autoload | ||
| 96 | (defun pcomplete/make () | ||
| 97 | "Completion for GNU `make'." | ||
| 98 | (let ((pcomplete-help "(make)Top")) | ||
| 99 | (pcomplete-opt "bmC/def(pcmpl-gnu-makefile-names)hiI/j?kl?no.pqrsStvwW.") | ||
| 100 | (while (pcomplete-here (pcmpl-gnu-make-rule-names) nil 'identity)))) | ||
| 101 | |||
| 102 | (defun pcmpl-gnu-makefile-names () | ||
| 103 | "Return a list of possible makefile names." | ||
| 104 | (let ((names (list t)) | ||
| 105 | (reg pcmpl-gnu-makefile-regexps)) | ||
| 106 | (while reg | ||
| 107 | (nconc names (pcomplete-entries (car reg))) | ||
| 108 | (setq reg (cdr reg))) | ||
| 109 | (cdr names))) | ||
| 110 | |||
| 111 | (defun pcmpl-gnu-make-rule-names () | ||
| 112 | "Return a list of possible make rule names in MAKEFILE." | ||
| 113 | (let* ((minus-f (member "-f" pcomplete-args)) | ||
| 114 | (makefile (or (cadr minus-f) "Makefile")) | ||
| 115 | rules) | ||
| 116 | (if (not (file-readable-p makefile)) | ||
| 117 | (unless minus-f (list "-f")) | ||
| 118 | (with-temp-buffer | ||
| 119 | (insert-file-contents-literally makefile) | ||
| 120 | (while (re-search-forward | ||
| 121 | (concat "^\\s-*\\([^\n#%.$][^:=\n]*\\)\\s-*:[^=]") nil t) | ||
| 122 | (setq rules (append (split-string (match-string 1)) rules)))) | ||
| 123 | (pcomplete-uniqify-list rules)))) | ||
| 124 | |||
| 125 | (defcustom pcmpl-gnu-tarfile-regexp | ||
| 126 | "\\.t\\(ar\\(\\.\\(gz\\|bz2\\|Z\\)\\)?\\|gz\\|a[zZ]\\|z2\\)\\'" | ||
| 127 | "*A regexp which matches any tar archive." | ||
| 128 | :type 'regexp | ||
| 129 | :group 'pcmpl-gnu) | ||
| 130 | |||
| 131 | (defvar pcmpl-gnu-tar-buffer nil) | ||
| 132 | |||
| 133 | ;;;###autoload | ||
| 134 | (defun pcomplete/tar () | ||
| 135 | "Completion for the GNU tar utility." | ||
| 136 | ;; options that end in an equal sign will want further completion... | ||
| 137 | (let (saw-option complete-within) | ||
| 138 | (setq pcomplete-suffix-list (cons ?= pcomplete-suffix-list)) | ||
| 139 | (while (pcomplete-match "^-" 0) | ||
| 140 | (setq saw-option t) | ||
| 141 | (if (pcomplete-match "^--" 0) | ||
| 142 | (if (pcomplete-match "^--\\([^= \t\n\f]*\\)\\'" 0) | ||
| 143 | (pcomplete-here* | ||
| 144 | '("--absolute-names" | ||
| 145 | "--after-date=" | ||
| 146 | "--append" | ||
| 147 | "--atime-preserve" | ||
| 148 | "--backup" | ||
| 149 | "--block-number" | ||
| 150 | "--blocking-factor=" | ||
| 151 | "--catenate" | ||
| 152 | "--checkpoint" | ||
| 153 | "--compare" | ||
| 154 | "--compress" | ||
| 155 | "--concatenate" | ||
| 156 | "--confirmation" | ||
| 157 | "--create" | ||
| 158 | "--delete" | ||
| 159 | "--dereference" | ||
| 160 | "--diff" | ||
| 161 | "--directory=" | ||
| 162 | "--exclude=" | ||
| 163 | "--exclude-from=" | ||
| 164 | "--extract" | ||
| 165 | "--file=" | ||
| 166 | "--files-from=" | ||
| 167 | "--force-local" | ||
| 168 | "--get" | ||
| 169 | "--group=" | ||
| 170 | "--gzip" | ||
| 171 | "--help" | ||
| 172 | "--ignore-failed-read" | ||
| 173 | "--ignore-zeros" | ||
| 174 | "--incremental" | ||
| 175 | "--info-script=" | ||
| 176 | "--interactive" | ||
| 177 | "--keep-old-files" | ||
| 178 | "--label=" | ||
| 179 | "--list" | ||
| 180 | "--listed-incremental" | ||
| 181 | "--mode=" | ||
| 182 | "--modification-time" | ||
| 183 | "--multi-volume" | ||
| 184 | "--new-volume-script=" | ||
| 185 | "--newer=" | ||
| 186 | "--newer-mtime" | ||
| 187 | "--no-recursion" | ||
| 188 | "--null" | ||
| 189 | "--numeric-owner" | ||
| 190 | "--old-archive" | ||
| 191 | "--one-file-system" | ||
| 192 | "--owner=" | ||
| 193 | "--portability" | ||
| 194 | "--posix" | ||
| 195 | "--preserve" | ||
| 196 | "--preserve-order" | ||
| 197 | "--preserve-permissions" | ||
| 198 | "--read-full-records" | ||
| 199 | "--record-size=" | ||
| 200 | "--recursive-unlink" | ||
| 201 | "--remove-files" | ||
| 202 | "--rsh-command=" | ||
| 203 | "--same-order" | ||
| 204 | "--same-owner" | ||
| 205 | "--same-permissions" | ||
| 206 | "--sparse" | ||
| 207 | "--starting-file=" | ||
| 208 | "--suffix=" | ||
| 209 | "--tape-length=" | ||
| 210 | "--to-stdout" | ||
| 211 | "--totals" | ||
| 212 | "--uncompress" | ||
| 213 | "--ungzip" | ||
| 214 | "--unlink-first" | ||
| 215 | "--update" | ||
| 216 | "--use-compress-program=" | ||
| 217 | "--verbose" | ||
| 218 | "--verify" | ||
| 219 | "--version" | ||
| 220 | "--volno-file="))) | ||
| 221 | (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")) | ||
| 222 | (cond | ||
| 223 | ((pcomplete-match "\\`--after-date=" 0) | ||
| 224 | (pcomplete-here*)) | ||
| 225 | ((pcomplete-match "\\`--backup=" 0) | ||
| 226 | (pcomplete-here*)) | ||
| 227 | ((pcomplete-match "\\`--blocking-factor=" 0) | ||
| 228 | (pcomplete-here*)) | ||
| 229 | ((pcomplete-match "\\`--directory=\\(.*\\)" 0) | ||
| 230 | (pcomplete-here* (pcomplete-dirs) | ||
| 231 | (pcomplete-match-string 1 0))) | ||
| 232 | ((pcomplete-match "\\`--exclude-from=\\(.*\\)" 0) | ||
| 233 | (pcomplete-here* (pcomplete-entries) | ||
| 234 | (pcomplete-match-string 1 0))) | ||
| 235 | ((pcomplete-match "\\`--exclude=" 0) | ||
| 236 | (pcomplete-here*)) | ||
| 237 | ((pcomplete-match "\\`--\\(extract\\|list\\)\\'" 0) | ||
| 238 | (setq complete-within t)) | ||
| 239 | ((pcomplete-match "\\`--file=\\(.*\\)" 0) | ||
| 240 | (pcomplete-here* (pcomplete-dirs-or-entries pcmpl-gnu-tarfile-regexp) | ||
| 241 | (pcomplete-match-string 1 0))) | ||
| 242 | ((pcomplete-match "\\`--files-from=\\(.*\\)" 0) | ||
| 243 | (pcomplete-here* (pcomplete-entries) | ||
| 244 | (pcomplete-match-string 1 0))) | ||
| 245 | ((pcomplete-match "\\`--group=\\(.*\\)" 0) | ||
| 246 | (pcomplete-here* (pcmpl-unix-group-names) | ||
| 247 | (pcomplete-match-string 1 0))) | ||
| 248 | ((pcomplete-match "\\`--info-script=\\(.*\\)" 0) | ||
| 249 | (pcomplete-here* (pcomplete-entries) | ||
| 250 | (pcomplete-match-string 1 0))) | ||
| 251 | ((pcomplete-match "\\`--label=" 0) | ||
| 252 | (pcomplete-here*)) | ||
| 253 | ((pcomplete-match "\\`--mode=" 0) | ||
| 254 | (pcomplete-here*)) | ||
| 255 | ((pcomplete-match "\\`--new-volume-script=\\(.*\\)" 0) | ||
| 256 | (pcomplete-here* (pcomplete-entries) | ||
| 257 | (pcomplete-match-string 1 0))) | ||
| 258 | ((pcomplete-match "\\`--newer=" 0) | ||
| 259 | (pcomplete-here*)) | ||
| 260 | ((pcomplete-match "\\`--owner=\\(.*\\)" 0) | ||
| 261 | (pcomplete-here* (pcmpl-unix-user-names) | ||
| 262 | (pcomplete-match-string 1 0))) | ||
| 263 | ((pcomplete-match "\\`--record-size=" 0) | ||
| 264 | (pcomplete-here*)) | ||
| 265 | ((pcomplete-match "\\`--rsh-command=\\(.*\\)" 0) | ||
| 266 | (pcomplete-here* (funcall pcomplete-command-completion-function) | ||
| 267 | (pcomplete-match-string 1 0))) | ||
| 268 | ((pcomplete-match "\\`--starting-file=\\(.*\\)" 0) | ||
| 269 | (pcomplete-here* (pcomplete-entries) | ||
| 270 | (pcomplete-match-string 1 0))) | ||
| 271 | ((pcomplete-match "\\`--suffix=" 0) | ||
| 272 | (pcomplete-here*)) | ||
| 273 | ((pcomplete-match "\\`--tape-length=" 0) | ||
| 274 | (pcomplete-here*)) | ||
| 275 | ((pcomplete-match "\\`--use-compress-program=\\(.*\\)" 0) | ||
| 276 | (pcomplete-here* (funcall pcomplete-command-completion-function) | ||
| 277 | (pcomplete-match-string 1 0))) | ||
| 278 | ((pcomplete-match "\\`--volno-file=\\(.*\\)" 0) | ||
| 279 | (pcomplete-here* (pcomplete-entries) | ||
| 280 | (pcomplete-match-string 1 0))))) | ||
| 281 | (setq pcomplete-suffix-list (cdr pcomplete-suffix-list)) | ||
| 282 | (unless saw-option | ||
| 283 | (pcomplete-here | ||
| 284 | (mapcar 'char-to-string | ||
| 285 | (string-to-list | ||
| 286 | "01234567ABCFGIKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz"))) | ||
| 287 | (if (pcomplete-match "[xt]" 'first 1) | ||
| 288 | (setq complete-within t))) | ||
| 289 | (pcomplete-here (pcomplete-dirs-or-entries pcmpl-gnu-tarfile-regexp)) | ||
| 290 | (setq pcmpl-gnu-tar-buffer (find-file-noselect (pcomplete-arg 1))) | ||
| 291 | (while (pcomplete-here | ||
| 292 | (if complete-within | ||
| 293 | (with-current-buffer pcmpl-gnu-tar-buffer | ||
| 294 | (mapcar | ||
| 295 | (function | ||
| 296 | (lambda (entry) | ||
| 297 | (tar-header-name (cdr entry)))) | ||
| 298 | tar-parse-info)) | ||
| 299 | (pcomplete-entries)) | ||
| 300 | nil 'identity)))) | ||
| 301 | |||
| 302 | ;;;###autoload | ||
| 303 | (defalias 'pcomplete/gdb 'pcomplete/xargs) | ||
| 304 | |||
| 305 | ;;; pcmpl-gnu.el ends here | ||
diff --git a/lisp/pcmpl-linux.el b/lisp/pcmpl-linux.el new file mode 100644 index 00000000000..26e5373f66f --- /dev/null +++ b/lisp/pcmpl-linux.el | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | ;;; pcmpl-linux --- functions for dealing with cvs completions | ||
| 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 | ||
| 19 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 20 | ;; Boston, MA 02111-1307, USA. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; These functions are for use with GNU/Linux. Since they depend on a | ||
| 25 | ;; certain knowledge of the layout of such systems, they probably | ||
| 26 | ;; won't work very well on other operating systems. | ||
| 27 | |||
| 28 | ;;; Code: | ||
| 29 | |||
| 30 | (provide 'pcmpl-linux) | ||
| 31 | |||
| 32 | (require 'pcomplete) | ||
| 33 | |||
| 34 | (defgroup pcmpl-linux nil | ||
| 35 | "Functions for dealing with GNU/Linux completions." | ||
| 36 | :group 'pcomplete) | ||
| 37 | |||
| 38 | ;; Functions: | ||
| 39 | |||
| 40 | ;;;###autoload | ||
| 41 | (defun pcomplete/kill () | ||
| 42 | "Completion for GNU/Linux `kill', using /proc filesystem." | ||
| 43 | (if (pcomplete-match "^-\\(.*\\)" 0) | ||
| 44 | (pcomplete-here | ||
| 45 | (pcomplete-uniqify-list | ||
| 46 | (split-string | ||
| 47 | (pcomplete-process-result "kill" "-l"))) | ||
| 48 | (pcomplete-match-string 1 0))) | ||
| 49 | (while (pcomplete-here | ||
| 50 | (if (file-directory-p "/proc") | ||
| 51 | (let ((default-directory "/proc/")) | ||
| 52 | (mapcar 'directory-file-name | ||
| 53 | (pcomplete-entries "[0-9]+/$")))) | ||
| 54 | nil 'identity))) | ||
| 55 | |||
| 56 | ;;;###autoload | ||
| 57 | (defun pcomplete/umount () | ||
| 58 | "Completion for GNU/Linux `umount'." | ||
| 59 | (pcomplete-opt "hVafrnvt(pcmpl-linux-fs-types)") | ||
| 60 | (while (pcomplete-here (pcmpl-linux-mounted-directories) | ||
| 61 | nil 'identity))) | ||
| 62 | |||
| 63 | ;;;###autoload | ||
| 64 | (defun pcomplete/mount () | ||
| 65 | "Completion for GNU/Linux `mount'." | ||
| 66 | (pcomplete-opt "hVanfFrsvwt(pcmpl-linux-fs-types)o?L?U?") | ||
| 67 | (while (pcomplete-here (pcomplete-entries) nil 'identity))) | ||
| 68 | |||
| 69 | (defun pcmpl-linux-fs-types () | ||
| 70 | "Return a list of available fs modules on GNU/Linux systems." | ||
| 71 | (let ((kernel-ver (pcomplete-process-result "uname" "-r"))) | ||
| 72 | (mapcar | ||
| 73 | (function | ||
| 74 | (lambda (fsobj) | ||
| 75 | (substring fsobj 0 (- (length fsobj) 2)))) | ||
| 76 | (let ((default-directory | ||
| 77 | (concat "/lib/modules/" kernel-ver "/fs/"))) | ||
| 78 | (pcomplete-entries "\\.o$"))))) | ||
| 79 | |||
| 80 | (defun pcmpl-linux-mounted-directories () | ||
| 81 | "Return a list of mounted directory names." | ||
| 82 | (let (points) | ||
| 83 | (when (file-readable-p "/etc/mtab") | ||
| 84 | (with-temp-buffer | ||
| 85 | (insert-file-contents-literally "/etc/mtab") | ||
| 86 | (while (not (eobp)) | ||
| 87 | (let* ((line (buffer-substring (point) (line-end-position))) | ||
| 88 | (args (split-string line " "))) | ||
| 89 | (setq points (cons (nth 1 args) points))) | ||
| 90 | (forward-line))) | ||
| 91 | (pcomplete-uniqify-list points)))) | ||
| 92 | |||
| 93 | (defun pcmpl-linux-mountable-directories () | ||
| 94 | "Return a list of mountable directory names." | ||
| 95 | (let (points) | ||
| 96 | (when (file-readable-p "/etc/fstab") | ||
| 97 | (with-temp-buffer | ||
| 98 | (insert-file-contents-literally "/etc/fstab") | ||
| 99 | (while (not (eobp)) | ||
| 100 | (let* ((line (buffer-substring (point) (line-end-position))) | ||
| 101 | (args (split-string line "\\s-+"))) | ||
| 102 | (setq points (cons (nth 1 args) points))) | ||
| 103 | (forward-line))) | ||
| 104 | (pcomplete-pare-list | ||
| 105 | (pcomplete-uniqify-list points) | ||
| 106 | (cons "swap" (pcmpl-linux-mounted-directories)))))) | ||
| 107 | |||
| 108 | ;;; pcmpl-linux.el ends here | ||
diff --git a/lisp/pcmpl-rpm.el b/lisp/pcmpl-rpm.el new file mode 100644 index 00000000000..ae72e51ae55 --- /dev/null +++ b/lisp/pcmpl-rpm.el | |||
| @@ -0,0 +1,329 @@ | |||
| 1 | ;;; pcmpl-rpm --- functions for dealing with rpm completions | ||
| 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 | ||
| 19 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 20 | ;; Boston, MA 02111-1307, USA. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; These functions provide completion rules for RedHat's `rpm' tool. | ||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | |||
| 28 | (provide 'pcmpl-rpm) | ||
| 29 | |||
| 30 | (require 'pcomplete) | ||
| 31 | |||
| 32 | (defgroup pcmpl-rpm nil | ||
| 33 | "Functions for dealing with CVS completions" | ||
| 34 | :group 'pcomplete) | ||
| 35 | |||
| 36 | ;; Functions: | ||
| 37 | |||
| 38 | (defsubst pcmpl-rpm-packages () | ||
| 39 | (split-string (pcomplete-process-result "rpm" "-q" "-a"))) | ||
| 40 | |||
| 41 | (defun pcmpl-rpm-all-query (flag) | ||
| 42 | (message "Querying all packages with `%s'..." flag) | ||
| 43 | (let ((pkgs (pcmpl-rpm-packages)) | ||
| 44 | (provs (list t))) | ||
| 45 | (while pkgs | ||
| 46 | (nconc provs (split-string | ||
| 47 | (pcomplete-process-result | ||
| 48 | "rpm" "-q" (car pkgs) flag))) | ||
| 49 | (setq pkgs (cdr pkgs))) | ||
| 50 | (pcomplete-uniqify-list (cdr provs)))) | ||
| 51 | |||
| 52 | (defsubst pcmpl-rpm-files () | ||
| 53 | (pcomplete-dirs-or-entries "\\.rpm\\'")) | ||
| 54 | |||
| 55 | ;;;###autoload | ||
| 56 | (defun pcomplete/rpm () | ||
| 57 | "Completion for RedHat's `rpm' command. | ||
| 58 | These rules were taken from the output of `rpm --help' on a RedHat 6.1 | ||
| 59 | system. They follow my interpretation of what followed, but since I'm | ||
| 60 | not a major rpm user/builder, please send me any corrections you find. | ||
| 61 | You can use \\[eshell-report-bug] to do so." | ||
| 62 | (let (mode) | ||
| 63 | (while (<= pcomplete-index pcomplete-last) | ||
| 64 | (unless mode | ||
| 65 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 66 | (pcomplete-here* | ||
| 67 | '("--addsign" | ||
| 68 | "--checksig" | ||
| 69 | "--erase" | ||
| 70 | "--help" | ||
| 71 | "--initdb" | ||
| 72 | "--install" | ||
| 73 | "--pipe" | ||
| 74 | "--querytags" | ||
| 75 | "--rebuild" | ||
| 76 | "--rebuilddb" | ||
| 77 | "--recompile" | ||
| 78 | "--resign" | ||
| 79 | "--rmsource" | ||
| 80 | "--setperms" | ||
| 81 | "--setugids" | ||
| 82 | "--upgrade" | ||
| 83 | "--verify" | ||
| 84 | "--version")) | ||
| 85 | (pcomplete-opt "vqVyiUebtK"))) | ||
| 86 | ; -b<stage> <spec> | ||
| 87 | ; -t<stage> <tarball> - build package, where <stage> is one of: | ||
| 88 | ; p - prep (unpack sources and apply patches) | ||
| 89 | ; l - list check (do some cursory checks on %files) | ||
| 90 | ; c - compile (prep and compile) | ||
| 91 | ; i - install (prep, compile, install) | ||
| 92 | ; b - binary package (prep, compile, install, package) | ||
| 93 | ; a - bin/src package (prep, compile, install, package) | ||
| 94 | (cond | ||
| 95 | ((or (eq mode 'query) | ||
| 96 | (pcomplete-match "-[^-]*q")) | ||
| 97 | (setq mode 'query) | ||
| 98 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 99 | (progn | ||
| 100 | (pcomplete-here* | ||
| 101 | '("--changelog" | ||
| 102 | "--dbpath" | ||
| 103 | "--dump" | ||
| 104 | "--ftpport" ;nyi for the next four | ||
| 105 | "--ftpproxy" | ||
| 106 | "--httpport" | ||
| 107 | "--httpproxy" | ||
| 108 | "--provides" | ||
| 109 | "--queryformat" | ||
| 110 | "--rcfile" | ||
| 111 | "--requires" | ||
| 112 | "--root" | ||
| 113 | "--scripts" | ||
| 114 | "--triggeredby" | ||
| 115 | "--whatprovides" | ||
| 116 | "--whatrequires")) | ||
| 117 | (cond | ||
| 118 | ((pcomplete-test "--dbpath") | ||
| 119 | (pcomplete-here* (pcomplete-dirs))) | ||
| 120 | ((pcomplete-test "--queryformat") | ||
| 121 | (pcomplete-here*)) | ||
| 122 | ((pcomplete-test "--rcfile") | ||
| 123 | (pcomplete-here* (pcomplete-entries))) | ||
| 124 | ((pcomplete-test "--root") | ||
| 125 | (pcomplete-here* (pcomplete-dirs))) | ||
| 126 | ((pcomplete-test "--scripts") | ||
| 127 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 128 | (pcomplete-here* '("--triggers")))) | ||
| 129 | ((pcomplete-test "--triggeredby") | ||
| 130 | (pcomplete-here* (pcmpl-rpm-packages))) | ||
| 131 | ((pcomplete-test "--whatprovides") | ||
| 132 | (pcomplete-here* | ||
| 133 | (pcmpl-rpm-all-query "--provides"))) | ||
| 134 | ((pcomplete-test "--whatrequires") | ||
| 135 | (pcomplete-here* | ||
| 136 | (pcmpl-rpm-all-query "--requires"))))) | ||
| 137 | (if (pcomplete-match "^-" 0) | ||
| 138 | (pcomplete-opt "af.p(pcmpl-rpm-files)ilsdcvR") | ||
| 139 | (pcomplete-here (pcmpl-rpm-packages))))) | ||
| 140 | ((pcomplete-test "--pipe") | ||
| 141 | (pcomplete-here* (funcall pcomplete-command-completion-function))) | ||
| 142 | ((pcomplete-test "--rmsource") | ||
| 143 | (pcomplete-here* (pcomplete-entries)) | ||
| 144 | (throw 'pcomplete-completions nil)) | ||
| 145 | ((pcomplete-match "\\`--re\\(build\\|compile\\)\\'") | ||
| 146 | (pcomplete-here (pcmpl-rpm-files)) | ||
| 147 | (throw 'pcomplete-completions nil)) | ||
| 148 | ((pcomplete-match "\\`--\\(resign\\|addsign\\)\\'") | ||
| 149 | (while (pcomplete-here (pcmpl-rpm-files)))) | ||
| 150 | ((or (eq mode 'checksig) | ||
| 151 | (pcomplete-test "--checksig")) | ||
| 152 | (setq mode 'checksig) | ||
| 153 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 154 | (progn | ||
| 155 | (pcomplete-here* | ||
| 156 | '("--nopgp" | ||
| 157 | "--nogpg" | ||
| 158 | "--nomd5" | ||
| 159 | "--rcfile")) | ||
| 160 | (cond | ||
| 161 | ((pcomplete-test "--rcfile") | ||
| 162 | (pcomplete-here* (pcomplete-entries))))) | ||
| 163 | (if (pcomplete-match "^-" 0) | ||
| 164 | (pcomplete-opt "v") | ||
| 165 | (pcomplete-here (pcmpl-rpm-files))))) | ||
| 166 | ((or (eq mode 'rebuilddb) | ||
| 167 | (pcomplete-test "--rebuilddb")) | ||
| 168 | (setq mode 'rebuilddb) | ||
| 169 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 170 | (progn | ||
| 171 | (pcomplete-here* | ||
| 172 | '("--dbpath" | ||
| 173 | "--root" | ||
| 174 | "--rcfile")) | ||
| 175 | (cond | ||
| 176 | ((pcomplete-test "--dbpath") | ||
| 177 | (pcomplete-here* (pcomplete-dirs))) | ||
| 178 | ((pcomplete-test "--root") | ||
| 179 | (pcomplete-here* (pcomplete-dirs))) | ||
| 180 | ((pcomplete-test "--rcfile") | ||
| 181 | (pcomplete-here* (pcomplete-entries))))) | ||
| 182 | (if (pcomplete-match "^-" 0) | ||
| 183 | (pcomplete-opt "v") | ||
| 184 | (pcomplete-here)))) | ||
| 185 | ((memq mode '(install upgrade)) | ||
| 186 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 187 | (progn | ||
| 188 | (pcomplete-here* | ||
| 189 | (append | ||
| 190 | '("--allfiles" | ||
| 191 | "--badreloc" | ||
| 192 | "--dbpath" | ||
| 193 | "--excludedocs" | ||
| 194 | "--excludepath" | ||
| 195 | "--force" | ||
| 196 | "--hash" | ||
| 197 | "--ignorearch" | ||
| 198 | "--ignoreos" | ||
| 199 | "--ignoresize" | ||
| 200 | "--includedocs" | ||
| 201 | "--justdb" | ||
| 202 | "--nodeps" | ||
| 203 | "--noorder" | ||
| 204 | "--noscripts" | ||
| 205 | "--notriggers") | ||
| 206 | (if (eq mode 'upgrade) | ||
| 207 | '("--oldpackage")) | ||
| 208 | '("--percent" | ||
| 209 | "--prefix" | ||
| 210 | "--rcfile" | ||
| 211 | "--relocate" | ||
| 212 | "--replacefiles" | ||
| 213 | "--replacepkgs" | ||
| 214 | "--root"))) | ||
| 215 | (cond | ||
| 216 | ((pcomplete-test "--dbpath") | ||
| 217 | (pcomplete-here* (pcomplete-dirs))) | ||
| 218 | ((pcomplete-test "--relocate") | ||
| 219 | (pcomplete-here*)) | ||
| 220 | ((pcomplete-test "--rcfile") | ||
| 221 | (pcomplete-here* (pcomplete-entries))) | ||
| 222 | ((pcomplete-test "--excludepath") | ||
| 223 | (pcomplete-here* (pcomplete-entries))) | ||
| 224 | ((pcomplete-test "--root") | ||
| 225 | (pcomplete-here* (pcomplete-dirs))) | ||
| 226 | ((pcomplete-test "--prefix") | ||
| 227 | (pcomplete-here* (pcomplete-dirs))))) | ||
| 228 | (if (pcomplete-match "^-" 0) | ||
| 229 | (pcomplete-opt "vh") | ||
| 230 | (pcomplete-here (pcmpl-rpm-files))))) | ||
| 231 | ((or (pcomplete-test "--install") | ||
| 232 | (pcomplete-match "-[^-]*i")) | ||
| 233 | (setq mode 'install)) | ||
| 234 | ((or (pcomplete-test "--upgrade") | ||
| 235 | (pcomplete-match "-[^-]*U")) | ||
| 236 | (setq mode 'upgrade)) | ||
| 237 | ((or (eq mode 'erase) | ||
| 238 | (pcomplete-test "--erase") | ||
| 239 | (pcomplete-match "-[^-]*e")) | ||
| 240 | (setq mode 'erase) | ||
| 241 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 242 | (progn | ||
| 243 | (pcomplete-here* | ||
| 244 | '("--allmatches" | ||
| 245 | "--dbpath" | ||
| 246 | "--justdb" | ||
| 247 | "--nodeps" | ||
| 248 | "--noorder" | ||
| 249 | "--noscripts" | ||
| 250 | "--notriggers" | ||
| 251 | "--rcfile" | ||
| 252 | "--root")) | ||
| 253 | (cond | ||
| 254 | ((pcomplete-test "--dbpath") | ||
| 255 | (pcomplete-here* (pcomplete-dirs))) | ||
| 256 | ((pcomplete-test "--rcfile") | ||
| 257 | (pcomplete-here* (pcomplete-entries))) | ||
| 258 | ((pcomplete-test "--root") | ||
| 259 | (pcomplete-here* (pcomplete-dirs))))) | ||
| 260 | (if (pcomplete-match "^-" 0) | ||
| 261 | (pcomplete-opt "v") | ||
| 262 | (pcomplete-here (pcmpl-rpm-packages))))) | ||
| 263 | ((or (eq mode 'verify) | ||
| 264 | (pcomplete-test "--verify")) | ||
| 265 | (setq mode 'verify) | ||
| 266 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 267 | (progn | ||
| 268 | (pcomplete-here* | ||
| 269 | '("--dbpath" | ||
| 270 | "--nodeps" | ||
| 271 | "--nofiles" | ||
| 272 | "--nomd5" | ||
| 273 | "--rcfile" | ||
| 274 | "--root" | ||
| 275 | "--triggeredby" | ||
| 276 | "--whatprovides" | ||
| 277 | "--whatrequires")) | ||
| 278 | (cond | ||
| 279 | ((pcomplete-test "--dbpath") | ||
| 280 | (pcomplete-here* (pcomplete-dirs))) | ||
| 281 | ((pcomplete-test "--rcfile") | ||
| 282 | (pcomplete-here* (pcomplete-entries))) | ||
| 283 | ((pcomplete-test "--root") | ||
| 284 | (pcomplete-here* (pcomplete-dirs))) | ||
| 285 | ((pcomplete-test "--triggeredby") | ||
| 286 | (pcomplete-here* (pcmpl-rpm-packages))) | ||
| 287 | ((pcomplete-test "--whatprovides") | ||
| 288 | (pcomplete-here* | ||
| 289 | (pcmpl-rpm-all-query "--provides"))) | ||
| 290 | ((pcomplete-test "--whatrequires") | ||
| 291 | (pcomplete-here* | ||
| 292 | (pcmpl-rpm-all-query "--requires"))))) | ||
| 293 | (if (pcomplete-match "^-" 0) | ||
| 294 | (pcomplete-opt "af.p(pcmpl-rpm-files)v") | ||
| 295 | (pcomplete-here (pcmpl-rpm-packages))))) | ||
| 296 | ((or (memq mode '(build test)) | ||
| 297 | (pcomplete-match "\\`-[bt]")) | ||
| 298 | (setq mode (if (pcomplete-match "\\`-b") | ||
| 299 | 'build | ||
| 300 | 'test)) | ||
| 301 | (if (pcomplete-match "^--\\(.*\\)" 0) | ||
| 302 | (progn | ||
| 303 | (pcomplete-here* | ||
| 304 | '("--buildroot" | ||
| 305 | "--clean" | ||
| 306 | "--nobuild" | ||
| 307 | "--rcfile" | ||
| 308 | "--rmsource" | ||
| 309 | "--short-circuit" | ||
| 310 | "--sign" | ||
| 311 | "--target" | ||
| 312 | "--timecheck")) | ||
| 313 | (cond | ||
| 314 | ((pcomplete-test "--buildroot") | ||
| 315 | (pcomplete-here* (pcomplete-dirs))) | ||
| 316 | ((pcomplete-test "--rcfile") | ||
| 317 | (pcomplete-here* (pcomplete-entries))) | ||
| 318 | ((pcomplete-test "--timecheck") | ||
| 319 | (pcomplete-here*)))) | ||
| 320 | (if (pcomplete-match "^-" 0) | ||
| 321 | (pcomplete-opt "v") | ||
| 322 | (pcomplete-here | ||
| 323 | (if (eq mode 'test) | ||
| 324 | (pcomplete-dirs-or-entries "\\.tar\\'") | ||
| 325 | (pcomplete-dirs-or-entries "\\.spec\\'")))))) | ||
| 326 | (t | ||
| 327 | (error "You must select a mode: -q, -i, -U, --verify, etc.")))))) | ||
| 328 | |||
| 329 | ;;; pcmpl-rpm.el ends here | ||
diff --git a/lisp/pcmpl-unix.el b/lisp/pcmpl-unix.el new file mode 100644 index 00000000000..b990cb722d9 --- /dev/null +++ b/lisp/pcmpl-unix.el | |||
| @@ -0,0 +1,123 @@ | |||
| 1 | ;;; pcmpl-unix --- standard UNIX completions | ||
| 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 | ||
| 19 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 20 | ;; Boston, MA 02111-1307, USA. | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (provide 'pcmpl-unix) | ||
| 25 | |||
| 26 | (require 'pcomplete) | ||
| 27 | |||
| 28 | ;; User Variables: | ||
| 29 | |||
| 30 | (defcustom pcmpl-unix-group-file "/etc/group" | ||
| 31 | "*If non-nil, a string naming the group file on your system." | ||
| 32 | :type 'file | ||
| 33 | :group 'pcmpl-unix) | ||
| 34 | |||
| 35 | (defcustom pcmpl-unix-passwd-file "/etc/passwd" | ||
| 36 | "*If non-nil, a string naming the passwd file on your system." | ||
| 37 | :type 'file | ||
| 38 | :group 'pcmpl-unix) | ||
| 39 | |||
| 40 | ;; Functions: | ||
| 41 | |||
| 42 | ;;;###autoload | ||
| 43 | (defun pcomplete/cd () | ||
| 44 | "Completion for `cd'." | ||
| 45 | (pcomplete-here (pcomplete-dirs))) | ||
| 46 | |||
| 47 | ;;;###autoload | ||
| 48 | (defalias 'pcomplete/pushd 'pcomplete/cd) | ||
| 49 | |||
| 50 | ;;;###autoload | ||
| 51 | (defun pcomplete/rmdir () | ||
| 52 | "Completion for `rmdir'." | ||
| 53 | (while (pcomplete-here (pcomplete-dirs)))) | ||
| 54 | |||
| 55 | ;;;###autoload | ||
| 56 | (defun pcomplete/rm () | ||
| 57 | "Completion for `rm'." | ||
| 58 | (let ((pcomplete-help "(fileutils)rm invocation")) | ||
| 59 | (pcomplete-opt "dfirRv") | ||
| 60 | (while (pcomplete-here (pcomplete-all-entries) nil | ||
| 61 | 'expand-file-name)))) | ||
| 62 | |||
| 63 | ;;;###autoload | ||
| 64 | (defun pcomplete/xargs () | ||
| 65 | "Completion for `xargs'." | ||
| 66 | (pcomplete-here (funcall pcomplete-command-completion-function)) | ||
| 67 | (funcall (or (pcomplete-find-completion-function (pcomplete-arg 1)) | ||
| 68 | pcomplete-default-completion-function))) | ||
| 69 | |||
| 70 | ;;;###autoload | ||
| 71 | (defalias 'pcomplete/time 'pcomplete/xargs) | ||
| 72 | |||
| 73 | ;;;###autoload | ||
| 74 | (defun pcomplete/which () | ||
| 75 | "Completion for `which'." | ||
| 76 | (while (pcomplete-here (funcall pcomplete-command-completion-function)))) | ||
| 77 | |||
| 78 | (defun pcmpl-unix-read-passwd-file (file) | ||
| 79 | "Return an alist correlating gids to group names in FILE." | ||
| 80 | (let (names) | ||
| 81 | (when (file-readable-p file) | ||
| 82 | (with-temp-buffer | ||
| 83 | (insert-file-contents file) | ||
| 84 | (goto-char (point-min)) | ||
| 85 | (while (not (eobp)) | ||
| 86 | (let* ((fields | ||
| 87 | (split-string (buffer-substring | ||
| 88 | (point) (progn (end-of-line) | ||
| 89 | (point))) ":"))) | ||
| 90 | (setq names (cons (nth 0 fields) names))) | ||
| 91 | (forward-line)))) | ||
| 92 | (pcomplete-uniqify-list names))) | ||
| 93 | |||
| 94 | (defsubst pcmpl-unix-group-names () | ||
| 95 | "Read the contents of /etc/group for group names." | ||
| 96 | (if pcmpl-unix-group-file | ||
| 97 | (pcmpl-unix-read-passwd-file pcmpl-unix-group-file))) | ||
| 98 | |||
| 99 | (defsubst pcmpl-unix-user-names () | ||
| 100 | "Read the contents of /etc/passwd for user names." | ||
| 101 | (if pcmpl-unix-passwd-file | ||
| 102 | (pcmpl-unix-read-passwd-file pcmpl-unix-passwd-file))) | ||
| 103 | |||
| 104 | ;;;###autoload | ||
| 105 | (defun pcomplete/chown () | ||
| 106 | "Completion for the `chown' command." | ||
| 107 | (unless (pcomplete-match "\\`-") | ||
| 108 | (if (pcomplete-match "\\`[^.]*\\'" 0) | ||
| 109 | (pcomplete-here* (pcmpl-unix-user-names)) | ||
| 110 | (if (pcomplete-match "\\.\\([^.]*\\)\\'" 0) | ||
| 111 | (pcomplete-here* (pcmpl-unix-group-names) | ||
| 112 | (pcomplete-match-string 1 0)) | ||
| 113 | (pcomplete-here*)))) | ||
| 114 | (while (pcomplete-here (pcomplete-entries)))) | ||
| 115 | |||
| 116 | ;;;###autoload | ||
| 117 | (defun pcomplete/chgrp () | ||
| 118 | "Completion for the `chgrp' command." | ||
| 119 | (unless (pcomplete-match "\\`-") | ||
| 120 | (pcomplete-here* (pcmpl-unix-group-names))) | ||
| 121 | (while (pcomplete-here (pcomplete-entries)))) | ||
| 122 | |||
| 123 | ;;; pcmpl-unix.el ends here | ||