- commit
- 61f8171
- parent
- 64087eb
- author
- Ian Eure
- date
- 2012-09-04 14:30:53 -0600 MDT
Update to the version kicking around my ~/.emacs.d
1 files changed,
+47,
-11
M
ssh.el
M
ssh.el
+47,
-11
1@@ -7,7 +7,7 @@
2 ;; Keywords: unix, comm
3 ;; Created: 1996-07-03
4
5-;; $Id: ssh.el,v 1.11 2012/07/09 22:15:45 friedman Exp $
6+;; $Id: ssh.el,v 1.1 2005/10/18 08:31:33 davidswelt Exp $
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10@@ -20,7 +20,9 @@
11 ;; GNU General Public License for more details.
12 ;;
13 ;; You should have received a copy of the GNU General Public License
14-;; along with this program. If not, see <http://www.gnu.org/licenses/>.
15+;; along with this program; if not, you can either send email to this
16+;; program's maintainer or write to: The Free Software Foundation,
17+;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
18
19 ;;; Commentary:
20
21@@ -135,6 +137,11 @@ this variable is set from that."
22
23 (defvar ssh-history nil)
24
25+;;;###
26+(defun ssh-hostname-at-point ()
27+ (let ((hostname (thing-at-point 'url)))
28+ (and hostname (substring-no-properties hostname 7))))
29+
30 ;;;###autoload
31 (defun ssh (input-args &optional buffer)
32 "Open a network login connection via `ssh' with args INPUT-ARGS.
33@@ -177,18 +184,21 @@ The variable `ssh-x-display-follow-current-frame' can be used to specify
34 how ssh X display tunelling interacts with frames on remote displays."
35 (interactive (list
36 (read-from-minibuffer "ssh arguments (hostname first): "
37- nil nil nil 'ssh-history)
38+ (ssh-hostname-at-point)
39+ nil nil 'ssh-history)
40 current-prefix-arg))
41
42 (let* ((process-connection-type ssh-process-connection-type)
43 (args (ssh-parse-words input-args))
44- (host (car args))
45- (user (or (car (cdr (member "-l" args)))
46+ (host-parts (split-string (car args) "@"))
47+ (host (car (last host-parts)))
48+ (user (or (cadr (member "-l" args))
49+ (if (= 2 (length host-parts)) (car host-parts))
50 (user-login-name)))
51 (buffer-name (if (string= user (user-login-name))
52- (format "*ssh-%s*" host)
53- (format "*ssh-%s@%s*" user host)))
54- proc)
55+ (format "*ssh %s*" host)
56+ (format "*ssh %s@%s*" user host)))
57+ proc)
58
59 (and ssh-explicit-args
60 (setq args (append ssh-explicit-args args)))
61@@ -210,14 +220,28 @@ how ssh X display tunelling interacts with frames on remote displays."
62 ((comint-check-proc buffer-name))
63 (t
64 (ssh-with-check-display-override
65- (lambda ()
66- (comint-exec buffer buffer-name ssh-program nil args)))
67+ #'(lambda ()
68+ (comint-exec buffer buffer-name ssh-program nil args)))
69 (setq proc (get-buffer-process buffer))
70 ;; Set process-mark to point-max in case there is text in the
71 ;; buffer from a previous exited process.
72 (set-marker (process-mark proc) (point-max))
73
74+ ;; comint-output-filter-functions is treated like a hook: it is
75+ ;; processed via run-hooks or run-hooks-with-args in later versions
76+ ;; of emacs.
77+ ;; comint-output-filter-functions should already have a
78+ ;; permanent-local property, at least in emacs 19.27 or later.
79+ (cond
80+ ((fboundp 'make-local-hook)
81+ (make-local-hook 'comint-output-filter-functions)
82+ (add-hook 'comint-output-filter-functions 'ssh-carriage-filter nil t))
83+ (t
84+ (make-local-variable 'comint-output-filter-functions)
85+ (add-hook 'comint-output-filter-functions 'ssh-carriage-filter)))
86+
87 (ssh-mode)
88+
89 (make-local-variable 'ssh-host)
90 (setq ssh-host host)
91 (make-local-variable 'ssh-remote-user)
92@@ -234,7 +258,8 @@ how ssh X display tunelling interacts with frames on remote displays."
93 ((null ssh-directory-tracking-mode))
94 (t
95 (cd-absolute (concat comint-file-name-prefix "~/"))))
96- (error nil))))))
97+ (error nil)))))
98+ buffer)
99
100 (put 'ssh-mode 'mode-class 'special)
101
102@@ -362,6 +387,17 @@ local one share the same directories (through NFS)."
103 (kill-buffer buf))
104 (nreverse list)))
105
106+(defun ssh-carriage-filter (string)
107+ (let* ((point-marker (point-marker))
108+ (end (process-mark (get-buffer-process (current-buffer))))
109+ (beg (or (and (boundp 'comint-last-output-start)
110+ comint-last-output-start)
111+ (- end (length string)))))
112+ (goto-char beg)
113+ (while (search-forward "\C-m" end t)
114+ (delete-char -1))
115+ (goto-char point-marker)))
116+
117 (defun ssh-send-Ctrl-C ()
118 (interactive)
119 (process-send-string nil "\C-c"))