Mercurial > emacs
annotate lisp/pcmpl-unix.el @ 99602:c94ec53df9d8
* net/ange-ftp.el (ange-ftp-multi-msgs, ange-ftp-good-msgs)
(ange-ftp-try-passive-mode, ange-ftp-data-buffer-name)
(ange-ftp-account-hashtable, ange-ftp-ls-cache-lsargs)
(ange-ftp-ls-cache-file, ange-ftp-ls-cache-res, ange-ftp-get-user)
(ange-ftp-ftp-name-component, ange-ftp-kill-ftp-process)
(ange-ftp-quote-string, ange-ftp-process-handle-line)
(ange-ftp-start-process, ange-ftp-send-cmd, ange-ftp-add-dumb-unix-host)
(ange-ftp-before-parse-ls-hook, ange-ftp-after-parse-ls-hook)
(ange-ftp-ls, ange-ftp-add-dl-dir, ange-ftp-get-file-entry)
(ange-ftp-set-binary-mode, ange-ftp-set-ascii-mode, ange-ftp-get-pwd)
(ange-ftp-file-name-as-directory-alist, ange-ftp-reread-dir)
(ange-ftp-vms-filename-regexp, ange-ftp-bs2000-fix-name-regexp-reverse)
(ange-ftp-bs2000-fix-name-regexp): Fix typos in docstrings.
(ange-ftp-name-format, ange-ftp-gateway-fatal-msgs)
(ange-ftp-xfer-size-msgs, ange-ftp-tmp-name-template)
(ange-ftp-netrc-filename, ange-ftp-disable-netrc-security-check)
(ange-ftp-default-user, ange-ftp-default-password)
(ange-ftp-default-account, ange-ftp-netrc-default-password)
(ange-ftp-netrc-default-account, ange-ftp-dumb-unix-host-regexp)
(ange-ftp-binary-file-name-regexp, ange-ftp-gateway-host)
(ange-ftp-gateway-prompt-pattern, ange-ftp-smart-gateway-port)
(ange-ftp-send-hash, ange-ftp-binary-hash-mark-size)
(ange-ftp-ascii-hash-mark-size, ange-ftp-process-verbose)
(ange-ftp-ftp-program-name, ange-ftp-gateway-ftp-program-name)
(ange-ftp-ftp-program-args, ange-ftp-nslookup-program)
(ange-ftp-make-backup-files, ange-ftp-retry-time)
(ange-ftp-bs2000-special-prefix): Remove * from defcustom docstrings.
(ange-ftp-skip-msgs, ange-ftp-potential-error-msgs)
(ange-ftp-gateway-tmp-name-template)
(ange-ftp-generate-anonymous-password, ange-ftp-local-host-regexp)
(ange-ftp-gateway-program-interactive, ange-ftp-smart-gateway)
(ange-ftp-raw-login): Remove * from defcustom docstrings; fix typos.
(ange-ftp-fatal-msgs): Remove * from defcustom docstring; doc fix.
(ange-ftp-gateway-program): Remove * from docstring and reflow.
(ange-ftp-hash-entry-exists-p, ange-ftp-hash-table-keys)
(ange-ftp-raw-send-cmd, ange-ftp-get-files, ange-ftp-canonize-filename)
(ange-ftp-file-name-as-directory, ange-ftp-directory-file-name):
(ange-ftp-copy-files-async, ange-ftp-rename-remote-to-remote):
(ange-ftp-rename-local-to-remote): Doc fixes.
(ange-ftp-set-xfer-size, ange-ftp-call-cont, ange-ftp-process-filter):
Use `when', `unless'.
(ange-ftp-set-passwd): Rename arg PASSWD to PASSWORD.
(ange-ftp-process-handle-hash): Rename arg STR to STRING.
(ange-ftp-nslookup-host): Rename arg HOST to HOSTNAME.
(ange-ftp-smart-login): Rename arg PASS to PASSWORD.
(ange-ftp-normal-login): Rename arg PASS to PASSWORD. Fix typo.
(ange-ftp-process-sentinel): Use `when'. Fix typo.
(ange-ftp-gwp-start): Use `let', not `let*'; use `when'. Fix typo.
(ange-ftp-fix-name-func-alist, ange-ftp-fix-dir-name-func-alist)
(ange-ftp-parse-list-func-alist, ange-ftp-add-file-entry-alist)
(ange-ftp-delete-file-entry-alist): Fix typos and reflow docstring.
(ange-ftp-dumb-unix-host, ange-ftp-binary-file)
(ange-ftp-directory-files, ange-ftp-file-modtime, ange-ftp-vms-host)
(ange-ftp-mts-host, ange-ftp-cms-host, ange-ftp-bs2000-host)
(ange-ftp-bs2000-posix-host): Use `string-match-p' instead of
`(save-match-data (string-match ...))'.
(ange-ftp-use-gateway-p, ange-ftp-use-smart-gateway-p)
(ange-ftp-file-name-directory, ange-ftp-file-name-nondirectory):
Use `string-match-p' instead of `(save-match-data (string-match ...))'.
Doc fixes.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Sun, 16 Nov 2008 05:50:23 +0000 |
parents | ee5932bf781d |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
29959
diff
changeset
|
1 ;;; pcmpl-unix.el --- standard UNIX 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:
91644
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:
91644
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:
91644
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:
91644
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:
29959
diff
changeset
|
21 ;;; Commentary: |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
29959
diff
changeset
|
22 |
29959 | 23 ;;; Code: |
24 | |
25 (require 'pcomplete) | |
26 | |
27 ;; User Variables: | |
28 | |
29 (defcustom pcmpl-unix-group-file "/etc/group" | |
91644
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
30 "If non-nil, a string naming the group file on your system." |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
31 :type '(choice file (const nil)) |
29959 | 32 :group 'pcmpl-unix) |
33 | |
34 (defcustom pcmpl-unix-passwd-file "/etc/passwd" | |
91644
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
35 "If non-nil, a string naming the passwd file on your system." |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
36 :type '(choice file (const nil)) |
29959 | 37 :group 'pcmpl-unix) |
38 | |
91643
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
39 (defcustom pcmpl-ssh-known-hosts-file "~/.ssh/known_hosts" |
91644
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
40 "If non-nil, a string naming your SSH \"known_hosts\" file. |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
41 This allows completion of SSH host names. Note that newer |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
42 versions of ssh hash the hosts by default to prevent |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
43 Island-hopping SSH attacks. This can be disabled, at some risk, |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
44 with the SSH option \"HashKnownHosts no\"." |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
45 :type '(choice file (const nil)) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
46 :group 'pcmpl-unix |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
47 :version "23.1") |
91643
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
48 |
29959 | 49 ;; Functions: |
50 | |
51 ;;;###autoload | |
52 (defun pcomplete/cd () | |
53 "Completion for `cd'." | |
54 (pcomplete-here (pcomplete-dirs))) | |
55 | |
56 ;;;###autoload | |
57 (defalias 'pcomplete/pushd 'pcomplete/cd) | |
58 | |
59 ;;;###autoload | |
60 (defun pcomplete/rmdir () | |
61 "Completion for `rmdir'." | |
62 (while (pcomplete-here (pcomplete-dirs)))) | |
63 | |
64 ;;;###autoload | |
65 (defun pcomplete/rm () | |
66 "Completion for `rm'." | |
67 (let ((pcomplete-help "(fileutils)rm invocation")) | |
68 (pcomplete-opt "dfirRv") | |
69 (while (pcomplete-here (pcomplete-all-entries) nil | |
70 'expand-file-name)))) | |
71 | |
72 ;;;###autoload | |
73 (defun pcomplete/xargs () | |
74 "Completion for `xargs'." | |
75 (pcomplete-here (funcall pcomplete-command-completion-function)) | |
76 (funcall (or (pcomplete-find-completion-function (pcomplete-arg 1)) | |
77 pcomplete-default-completion-function))) | |
78 | |
79 ;;;###autoload | |
80 (defalias 'pcomplete/time 'pcomplete/xargs) | |
81 | |
82 ;;;###autoload | |
83 (defun pcomplete/which () | |
84 "Completion for `which'." | |
85 (while (pcomplete-here (funcall pcomplete-command-completion-function)))) | |
86 | |
87 (defun pcmpl-unix-read-passwd-file (file) | |
88 "Return an alist correlating gids to group names in FILE." | |
89 (let (names) | |
90 (when (file-readable-p file) | |
91 (with-temp-buffer | |
92 (insert-file-contents file) | |
93 (goto-char (point-min)) | |
94 (while (not (eobp)) | |
95 (let* ((fields | |
96 (split-string (buffer-substring | |
97 (point) (progn (end-of-line) | |
98 (point))) ":"))) | |
99 (setq names (cons (nth 0 fields) names))) | |
100 (forward-line)))) | |
101 (pcomplete-uniqify-list names))) | |
102 | |
103 (defsubst pcmpl-unix-group-names () | |
104 "Read the contents of /etc/group for group names." | |
105 (if pcmpl-unix-group-file | |
106 (pcmpl-unix-read-passwd-file pcmpl-unix-group-file))) | |
107 | |
108 (defsubst pcmpl-unix-user-names () | |
109 "Read the contents of /etc/passwd for user names." | |
110 (if pcmpl-unix-passwd-file | |
111 (pcmpl-unix-read-passwd-file pcmpl-unix-passwd-file))) | |
112 | |
113 ;;;###autoload | |
114 (defun pcomplete/chown () | |
115 "Completion for the `chown' command." | |
116 (unless (pcomplete-match "\\`-") | |
117 (if (pcomplete-match "\\`[^.]*\\'" 0) | |
118 (pcomplete-here* (pcmpl-unix-user-names)) | |
119 (if (pcomplete-match "\\.\\([^.]*\\)\\'" 0) | |
120 (pcomplete-here* (pcmpl-unix-group-names) | |
121 (pcomplete-match-string 1 0)) | |
122 (pcomplete-here*)))) | |
123 (while (pcomplete-here (pcomplete-entries)))) | |
124 | |
125 ;;;###autoload | |
126 (defun pcomplete/chgrp () | |
127 "Completion for the `chgrp' command." | |
128 (unless (pcomplete-match "\\`-") | |
129 (pcomplete-here* (pcmpl-unix-group-names))) | |
130 (while (pcomplete-here (pcomplete-entries)))) | |
131 | |
91644
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
132 |
91643
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
133 ;; ssh support by Phil Hagelberg. |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
134 ;; http://www.emacswiki.org/cgi-bin/wiki/pcmpl-ssh.el |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
135 |
91644
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
136 (defun pcmpl-ssh-hosts () |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
137 "Return a list of hosts found in `pcmpl-ssh-known-hosts-file'." |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
138 (when (and pcmpl-ssh-known-hosts-file |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
139 (file-readable-p pcmpl-ssh-known-hosts-file)) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
140 (with-temp-buffer |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
141 (insert-file-contents-literally pcmpl-ssh-known-hosts-file) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
142 (let (ssh-hosts-list) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
143 (while (re-search-forward "^ *\\([-.[:alnum:]]+\\)[, ]" nil t) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
144 (add-to-list 'ssh-hosts-list (match-string 1)) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
145 (while (and (looking-back ",") |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
146 (re-search-forward "\\([-.[:alnum:]]+\\)[, ]" |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
147 (line-end-position) t)) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
148 (add-to-list 'ssh-hosts-list (match-string 1)))) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
149 ssh-hosts-list)))) |
91643
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
150 |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
151 ;;;###autoload |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
152 (defun pcomplete/ssh () |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
153 "Completion rules for the `ssh' command." |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
154 (pcomplete-opt "1246AaCfgKkMNnqsTtVvXxYbcDeFiLlmOopRSw" nil t) |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
155 (pcomplete-here (pcmpl-ssh-hosts))) |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
156 |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
157 ;;;###autoload |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
158 (defun pcomplete/scp () |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
159 "Completion rules for the `scp' command. |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
160 Includes files as well as host names followed by a colon." |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
161 (pcomplete-opt "1246BCpqrvcFiloPS") |
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
162 (while t (pcomplete-here (append (pcomplete-all-entries) |
91644
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
163 (mapcar (lambda (host) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
164 (concat host ":")) |
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
165 (pcmpl-ssh-hosts)))))) |
91643
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
166 |
91644
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
167 (provide 'pcmpl-unix) |
91643
d3922949ea68
Phil Hagelberg <phil at evri.com>
Glenn Morris <rgm@gnu.org>
parents:
79721
diff
changeset
|
168 |
91644
681a1b7488c2
(top-level): Move provide statement to end.
Glenn Morris <rgm@gnu.org>
parents:
91643
diff
changeset
|
169 ;; arch-tag: 3f9eb5af-7e0e-449d-b586-381cbbf8fc5c |
29959 | 170 ;;; pcmpl-unix.el ends here |