[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r102931: Add pcomplete support for ho
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r102931: Add pcomplete support for hosts defined in .ssh/config. |
Date: |
Fri, 21 Jan 2011 21:20:57 -0500 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 102931
author: Phil Hagelberg <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Fri 2011-01-21 21:20:57 -0500
message:
Add pcomplete support for hosts defined in .ssh/config.
* lisp/pcmpl-unix.el (pcmpl-ssh-config-file): New option.
(pcmpl-ssh-known-hosts): Rename from pcmpl-ssh-hosts.
(pcmpl-ssh-config-hosts): New function.
(pcmpl-ssh-hosts): Use pcmpl-ssh-config-hosts in addition to
pcmpl-ssh-known-hosts.
modified:
lisp/ChangeLog
lisp/pcmpl-unix.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2011-01-21 16:36:24 +0000
+++ b/lisp/ChangeLog 2011-01-22 02:20:57 +0000
@@ -1,3 +1,11 @@
+2011-01-22 Phil Hagelberg <address@hidden>
+
+ * pcmpl-unix.el (pcmpl-ssh-config-file): New option.
+ (pcmpl-ssh-known-hosts): Rename from pcmpl-ssh-hosts.
+ (pcmpl-ssh-config-hosts): New function.
+ (pcmpl-ssh-hosts): Use pcmpl-ssh-config-hosts in addition to
+ pcmpl-ssh-known-hosts.
+
2011-01-21 Jay Belanger <address@hidden>
* calc/calc-undo.el (calc-undo): Autoload it.
=== modified file 'lisp/pcmpl-unix.el'
--- a/lisp/pcmpl-unix.el 2011-01-15 23:16:57 +0000
+++ b/lisp/pcmpl-unix.el 2011-01-22 02:20:57 +0000
@@ -40,14 +40,23 @@
(defcustom pcmpl-ssh-known-hosts-file "~/.ssh/known_hosts"
"If non-nil, a string naming your SSH \"known_hosts\" file.
-This allows completion of SSH host names. Note that newer
-versions of ssh hash the hosts by default to prevent
-Island-hopping SSH attacks. This can be disabled, at some risk,
-with the SSH option \"HashKnownHosts no\"."
+This allows one method of completion of SSH host names, the other
+being via `pcmpl-ssh-config-file'. Note that newer versions of
+ssh hash the hosts by default, to prevent Island-hopping SSH
+attacks. This can be disabled, at some risk, with the SSH option
+\"HashKnownHosts no\"."
:type '(choice file (const nil))
:group 'pcmpl-unix
:version "23.1")
+(defcustom pcmpl-ssh-config-file "~/.ssh/config"
+ "If non-nil, a string naming your SSH \"config\" file.
+This allows one method of completion of SSH host names, the other
+being via `pcmpl-ssh-known-hosts-file'."
+ :type '(choice file (const nil))
+ :group 'pcmpl-unix
+ :version "24.1")
+
;; Functions:
;;;###autoload
@@ -138,7 +147,7 @@
;; ssh support by Phil Hagelberg.
;; http://www.emacswiki.org/cgi-bin/wiki/pcmpl-ssh.el
-(defun pcmpl-ssh-hosts ()
+(defun pcmpl-ssh-known-hosts ()
"Return a list of hosts found in `pcmpl-ssh-known-hosts-file'."
(when (and pcmpl-ssh-known-hosts-file
(file-readable-p pcmpl-ssh-known-hosts-file))
@@ -153,6 +162,27 @@
(add-to-list 'ssh-hosts-list (match-string 1))))
ssh-hosts-list))))
+(defun pcmpl-ssh-config-hosts ()
+ "Return a list of hosts found in `pcmpl-ssh-config-file'."
+ (when (and pcmpl-ssh-config-file
+ (file-readable-p pcmpl-ssh-config-file))
+ (with-temp-buffer
+ (insert-file-contents-literally pcmpl-ssh-config-file)
+ (let (ssh-hosts-list
+ (case-fold-search t))
+ (while (re-search-forward "^ *host\\(name\\)? +\\([-.[:alnum:]]+\\)"
+ nil t)
+ (add-to-list 'ssh-hosts-list (match-string 2)))
+ ssh-hosts-list))))
+
+(defun pcmpl-ssh-hosts ()
+ "Return a list of known SSH hosts.
+Uses both `pcmpl-ssh-config-file' and `pcmpl-ssh-known-hosts-file'."
+ (let ((hosts (pcmpl-ssh-known-hosts)))
+ (dolist (h (pcmpl-ssh-config-hosts))
+ (add-to-list 'hosts h))
+ hosts))
+
;;;###autoload
(defun pcomplete/ssh ()
"Completion rules for the `ssh' command."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r102931: Add pcomplete support for hosts defined in .ssh/config.,
Chong Yidong <=