mirror of https://github.com/nealey/ssh-el
Update to the version kicking around my ~/.emacs.d
This commit is contained in:
parent
64087eb004
commit
61f8171ae0
58
ssh.el
58
ssh.el
|
@ -7,7 +7,7 @@
|
||||||
;; Keywords: unix, comm
|
;; Keywords: unix, comm
|
||||||
;; Created: 1996-07-03
|
;; Created: 1996-07-03
|
||||||
|
|
||||||
;; $Id: ssh.el,v 1.11 2012/07/09 22:15:45 friedman Exp $
|
;; $Id: ssh.el,v 1.1 2005/10/18 08:31:33 davidswelt Exp $
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
;; it under the terms of the GNU General Public License as published by
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,7 +20,9 @@
|
||||||
;; GNU General Public License for more details.
|
;; GNU General Public License for more details.
|
||||||
;;
|
;;
|
||||||
;; You should have received a copy of the GNU General Public License
|
;; You should have received a copy of the GNU General Public License
|
||||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
;; along with this program; if not, you can either send email to this
|
||||||
|
;; program's maintainer or write to: The Free Software Foundation,
|
||||||
|
;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
|
@ -135,6 +137,11 @@ this variable is set from that."
|
||||||
|
|
||||||
(defvar ssh-history nil)
|
(defvar ssh-history nil)
|
||||||
|
|
||||||
|
;;;###
|
||||||
|
(defun ssh-hostname-at-point ()
|
||||||
|
(let ((hostname (thing-at-point 'url)))
|
||||||
|
(and hostname (substring-no-properties hostname 7))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun ssh (input-args &optional buffer)
|
(defun ssh (input-args &optional buffer)
|
||||||
"Open a network login connection via `ssh' with args INPUT-ARGS.
|
"Open a network login connection via `ssh' with args INPUT-ARGS.
|
||||||
|
@ -177,18 +184,21 @@ The variable `ssh-x-display-follow-current-frame' can be used to specify
|
||||||
how ssh X display tunelling interacts with frames on remote displays."
|
how ssh X display tunelling interacts with frames on remote displays."
|
||||||
(interactive (list
|
(interactive (list
|
||||||
(read-from-minibuffer "ssh arguments (hostname first): "
|
(read-from-minibuffer "ssh arguments (hostname first): "
|
||||||
nil nil nil 'ssh-history)
|
(ssh-hostname-at-point)
|
||||||
|
nil nil 'ssh-history)
|
||||||
current-prefix-arg))
|
current-prefix-arg))
|
||||||
|
|
||||||
(let* ((process-connection-type ssh-process-connection-type)
|
(let* ((process-connection-type ssh-process-connection-type)
|
||||||
(args (ssh-parse-words input-args))
|
(args (ssh-parse-words input-args))
|
||||||
(host (car args))
|
(host-parts (split-string (car args) "@"))
|
||||||
(user (or (car (cdr (member "-l" args)))
|
(host (car (last host-parts)))
|
||||||
|
(user (or (cadr (member "-l" args))
|
||||||
|
(if (= 2 (length host-parts)) (car host-parts))
|
||||||
(user-login-name)))
|
(user-login-name)))
|
||||||
(buffer-name (if (string= user (user-login-name))
|
(buffer-name (if (string= user (user-login-name))
|
||||||
(format "*ssh-%s*" host)
|
(format "*ssh %s*" host)
|
||||||
(format "*ssh-%s@%s*" user host)))
|
(format "*ssh %s@%s*" user host)))
|
||||||
proc)
|
proc)
|
||||||
|
|
||||||
(and ssh-explicit-args
|
(and ssh-explicit-args
|
||||||
(setq args (append ssh-explicit-args args)))
|
(setq args (append ssh-explicit-args args)))
|
||||||
|
@ -210,14 +220,28 @@ how ssh X display tunelling interacts with frames on remote displays."
|
||||||
((comint-check-proc buffer-name))
|
((comint-check-proc buffer-name))
|
||||||
(t
|
(t
|
||||||
(ssh-with-check-display-override
|
(ssh-with-check-display-override
|
||||||
(lambda ()
|
#'(lambda ()
|
||||||
(comint-exec buffer buffer-name ssh-program nil args)))
|
(comint-exec buffer buffer-name ssh-program nil args)))
|
||||||
(setq proc (get-buffer-process buffer))
|
(setq proc (get-buffer-process buffer))
|
||||||
;; Set process-mark to point-max in case there is text in the
|
;; Set process-mark to point-max in case there is text in the
|
||||||
;; buffer from a previous exited process.
|
;; buffer from a previous exited process.
|
||||||
(set-marker (process-mark proc) (point-max))
|
(set-marker (process-mark proc) (point-max))
|
||||||
|
|
||||||
|
;; comint-output-filter-functions is treated like a hook: it is
|
||||||
|
;; processed via run-hooks or run-hooks-with-args in later versions
|
||||||
|
;; of emacs.
|
||||||
|
;; comint-output-filter-functions should already have a
|
||||||
|
;; permanent-local property, at least in emacs 19.27 or later.
|
||||||
|
(cond
|
||||||
|
((fboundp 'make-local-hook)
|
||||||
|
(make-local-hook 'comint-output-filter-functions)
|
||||||
|
(add-hook 'comint-output-filter-functions 'ssh-carriage-filter nil t))
|
||||||
|
(t
|
||||||
|
(make-local-variable 'comint-output-filter-functions)
|
||||||
|
(add-hook 'comint-output-filter-functions 'ssh-carriage-filter)))
|
||||||
|
|
||||||
(ssh-mode)
|
(ssh-mode)
|
||||||
|
|
||||||
(make-local-variable 'ssh-host)
|
(make-local-variable 'ssh-host)
|
||||||
(setq ssh-host host)
|
(setq ssh-host host)
|
||||||
(make-local-variable 'ssh-remote-user)
|
(make-local-variable 'ssh-remote-user)
|
||||||
|
@ -234,7 +258,8 @@ how ssh X display tunelling interacts with frames on remote displays."
|
||||||
((null ssh-directory-tracking-mode))
|
((null ssh-directory-tracking-mode))
|
||||||
(t
|
(t
|
||||||
(cd-absolute (concat comint-file-name-prefix "~/"))))
|
(cd-absolute (concat comint-file-name-prefix "~/"))))
|
||||||
(error nil))))))
|
(error nil)))))
|
||||||
|
buffer)
|
||||||
|
|
||||||
(put 'ssh-mode 'mode-class 'special)
|
(put 'ssh-mode 'mode-class 'special)
|
||||||
|
|
||||||
|
@ -362,6 +387,17 @@ local one share the same directories (through NFS)."
|
||||||
(kill-buffer buf))
|
(kill-buffer buf))
|
||||||
(nreverse list)))
|
(nreverse list)))
|
||||||
|
|
||||||
|
(defun ssh-carriage-filter (string)
|
||||||
|
(let* ((point-marker (point-marker))
|
||||||
|
(end (process-mark (get-buffer-process (current-buffer))))
|
||||||
|
(beg (or (and (boundp 'comint-last-output-start)
|
||||||
|
comint-last-output-start)
|
||||||
|
(- end (length string)))))
|
||||||
|
(goto-char beg)
|
||||||
|
(while (search-forward "\C-m" end t)
|
||||||
|
(delete-char -1))
|
||||||
|
(goto-char point-marker)))
|
||||||
|
|
||||||
(defun ssh-send-Ctrl-C ()
|
(defun ssh-send-Ctrl-C ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(process-send-string nil "\C-c"))
|
(process-send-string nil "\C-c"))
|
||||||
|
|
Loading…
Reference in New Issue