diff options
| author | Noah Friedman | 1993-03-28 07:25:36 +0000 |
|---|---|---|
| committer | Noah Friedman | 1993-03-28 07:25:36 +0000 |
| commit | 8d30fe178353b7687864428900e4b38e10c533d0 (patch) | |
| tree | 020271dae1f70f28e71a704c4a28e4402e7d1a1f | |
| parent | 1bbda2d6e09abccab133398e4623ae1a8a08d8fc (diff) | |
| download | emacs-8d30fe178353b7687864428900e4b38e10c533d0.tar.gz emacs-8d30fe178353b7687864428900e4b38e10c533d0.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/rlogin.el | 120 |
1 files changed, 91 insertions, 29 deletions
diff --git a/lisp/rlogin.el b/lisp/rlogin.el index eb022bbebb1..1f52c46a2d2 100644 --- a/lisp/rlogin.el +++ b/lisp/rlogin.el | |||
| @@ -16,13 +16,8 @@ | |||
| 16 | ;; GNU General Public License for more details. | 16 | ;; GNU General Public License for more details. |
| 17 | ;; | 17 | ;; |
| 18 | ;; You should have received a copy of the GNU General Public License | 18 | ;; You should have received a copy of the GNU General Public License |
| 19 | ;; along with this program; if not, you can either send email to this | 19 | ;; along with this program; if not, write to: The Free Software Foundation, |
| 20 | ;; program's author (see below) or write to: | 20 | ;; Inc.; 675 Massachusetts Avenue.; Cambridge, MA 02139, USA. |
| 21 | ;; | ||
| 22 | ;; The Free Software Foundation, Inc. | ||
| 23 | ;; 675 Massachusetts Avenue. | ||
| 24 | ;; Cambridge, MA 02139, USA. | ||
| 25 | ;; | ||
| 26 | 21 | ||
| 27 | ;;; Commentary: | 22 | ;;; Commentary: |
| 28 | 23 | ||
| @@ -37,9 +32,25 @@ | |||
| 37 | (defvar rlogin-program "rlogin" | 32 | (defvar rlogin-program "rlogin" |
| 38 | "*Name of program to invoke rlogin") | 33 | "*Name of program to invoke rlogin") |
| 39 | 34 | ||
| 35 | (defvar rlogin-explicit-args nil | ||
| 36 | "*List of arguments to pass to rlogin on the command line.") | ||
| 37 | |||
| 40 | (defvar rlogin-mode-hook nil | 38 | (defvar rlogin-mode-hook nil |
| 41 | "*Hooks to run after setting current buffer to rlogin-mode.") | 39 | "*Hooks to run after setting current buffer to rlogin-mode.") |
| 42 | 40 | ||
| 41 | ;; I think this is so obnoxious I refuse to enable it by default. | ||
| 42 | ;; In any case, there is a bug with regards to generating a quit while | ||
| 43 | ;; reading keyboard input in a process filter, so until that's fixed it's | ||
| 44 | ;; not safe to enable this anyway. | ||
| 45 | (defvar rlogin-password-paranoia nil | ||
| 46 | "*If non-`nil', query user for a password in the minibuffer when a | ||
| 47 | Password: prompt appears. Stars will echo as characters are type. | ||
| 48 | |||
| 49 | It's also possible to selectively enter passwords without echoing them in | ||
| 50 | the minibuffer using the function `rlogin-password'.") | ||
| 51 | |||
| 52 | (defvar rlogin-last-input-line nil nil) | ||
| 53 | |||
| 43 | ;; Initialize rlogin mode map. | 54 | ;; Initialize rlogin mode map. |
| 44 | (defvar rlogin-mode-map '()) | 55 | (defvar rlogin-mode-map '()) |
| 45 | (cond ((not rlogin-mode-map) | 56 | (cond ((not rlogin-mode-map) |
| @@ -52,32 +63,76 @@ | |||
| 52 | (define-key rlogin-mode-map "\C-d" 'rlogin-delchar-or-send-Ctrl-D))) | 63 | (define-key rlogin-mode-map "\C-d" 'rlogin-delchar-or-send-Ctrl-D))) |
| 53 | 64 | ||
| 54 | ;;;###autoload | 65 | ;;;###autoload |
| 55 | (defun rlogin (host) | 66 | (defun rlogin (&optional prefix host) |
| 56 | (interactive "sOpen rlogin connection to host: ") | 67 | "Open a network login connection to HOST via the `rlogin' program. |
| 57 | (let* ((buffer-name (concat "rlogin-" host)) | 68 | Input is sent line-at-a-time to the remote connection. |
| 58 | (*buffer-name* (concat "*" buffer-name "*"))) | 69 | |
| 59 | (cond ((not (comint-check-proc *buffer-name*)) | 70 | Communication with HOST is recorded in a buffer *rlogin-HOST*. |
| 60 | (let* ((xargs-name (intern-soft "explicit-rlogin-args")) | 71 | If a prefix argument is given and the buffer *rlogin-HOST* already exists, |
| 61 | (xargs (and xargs-name (boundp xargs-name) (symbol-value xargs-name))) | 72 | a new buffer with a different connection will be made. |
| 62 | (process-connection-type nil) | 73 | |
| 63 | proc) | 74 | The variable `rlogin-program' contains the name of the actual program to |
| 64 | (if xargs | 75 | run. It can be a relative or absolute path. |
| 65 | (setq xargs (append xargs host)) | 76 | |
| 66 | (setq xargs (list host))) | 77 | The variable `rlogin-explicit-args' is a list of arguments to give to |
| 67 | (set-buffer (apply 'make-comint buffer-name rlogin-program nil xargs)) | 78 | the rlogin when starting." |
| 68 | (setq proc (get-process buffer-name)) | 79 | (interactive (list current-prefix-arg |
| 69 | (set-marker (process-mark proc) (point-min)) | 80 | (read-from-minibuffer "Open rlogin connection to host: "))) |
| 70 | (set-process-filter proc 'rlogin-filter) | 81 | (let* ((buffer-name (format "*rlogin-%s*" host)) |
| 71 | (rlogin-mode)))) | 82 | (args (if (and rlogin-explicit-args (listp rlogin-explicit-args)) |
| 72 | (switch-to-buffer *buffer-name*))) | 83 | (cons host rlogin-explicit-args) |
| 84 | (list host)))) | ||
| 85 | (and prefix (setq buffer-name | ||
| 86 | (buffer-name (generate-new-buffer buffer-name)))) | ||
| 87 | (switch-to-buffer buffer-name) | ||
| 88 | (or (comint-check-proc buffer-name) | ||
| 89 | (progn | ||
| 90 | (comint-mode) | ||
| 91 | (comint-exec (current-buffer) buffer-name rlogin-program nil args) | ||
| 92 | (setq proc (get-process buffer-name)) | ||
| 93 | (set-marker (process-mark proc) (point-min)) | ||
| 94 | (set-process-filter proc 'rlogin-filter) | ||
| 95 | (rlogin-mode))))) | ||
| 96 | |||
| 97 | ;;;###autoload | ||
| 98 | (defun rlogin-with-args (host args) | ||
| 99 | "Open a new rlogin connection to HOST, even if one already exists. | ||
| 100 | String ARGS is given as arguments to the `rlogin' program, overriding the | ||
| 101 | value of `rlogin-explicit-args'." | ||
| 102 | (interactive (list (read-from-minibuffer "Open rlogin connection to host: ") | ||
| 103 | (read-from-minibuffer "with arguments: "))) | ||
| 104 | (let ((old-match-data (match-data)) | ||
| 105 | (rlogin-explicit-args nil)) | ||
| 106 | (unwind-protect | ||
| 107 | (progn | ||
| 108 | (while (string-match "[ \t]*\\([^ \t]\\)+$" args) | ||
| 109 | (setq rlogin-explicit-args | ||
| 110 | (cons (substring args | ||
| 111 | (match-beginning 1) | ||
| 112 | (match-end 1)) | ||
| 113 | rlogin-explicit-args) | ||
| 114 | args (substring args 0 (match-beginning 0))))) | ||
| 115 | (store-match-data old-match-data)) | ||
| 116 | (rlogin 1 host))) | ||
| 117 | |||
| 118 | ;;;###autoload | ||
| 119 | (defun rlogin-password () | ||
| 120 | "Play the paranoia game by not echoing entered password in buffer | ||
| 121 | (stars will echo in the minibuffer instead." | ||
| 122 | (interactive) | ||
| 123 | (let ((input (comint-read-noecho "Enter password: " 'stars))) | ||
| 124 | (insert-before-markers "\n") | ||
| 125 | (comint-send-string (get-buffer-process (current-buffer)) | ||
| 126 | (format "%s\n" input)))) | ||
| 73 | 127 | ||
| 74 | ;;;###autoload | 128 | ;;;###autoload |
| 75 | (defun rlogin-mode () | 129 | (defun rlogin-mode () |
| 76 | (interactive) | 130 | (interactive) |
| 131 | (kill-all-local-variables) | ||
| 77 | (comint-mode) | 132 | (comint-mode) |
| 78 | (setq comint-prompt-regexp shell-prompt-pattern) | 133 | (setq comint-prompt-regexp shell-prompt-pattern) |
| 79 | (setq major-mode 'rlogin-mode) | 134 | (setq major-mode 'rlogin-mode) |
| 80 | (setq mode-name "Rlogin") | 135 | (setq mode-name "rlogin") |
| 81 | (use-local-map rlogin-mode-map) | 136 | (use-local-map rlogin-mode-map) |
| 82 | (run-hooks 'rlogin-mode-hook)) | 137 | (run-hooks 'rlogin-mode-hook)) |
| 83 | 138 | ||
| @@ -99,13 +154,21 @@ | |||
| 99 | (goto-char (point-min)) | 154 | (goto-char (point-min)) |
| 100 | (while (search-forward "\C-m" nil t) | 155 | (while (search-forward "\C-m" nil t) |
| 101 | (delete-char -1)) | 156 | (delete-char -1)) |
| 102 | (setq string (buffer-substring (point-min) (point-max))) | 157 | (and rlogin-password-paranoia |
| 158 | (setq string (buffer-substring (point-min) (point-max)))) | ||
| 103 | (goto-char (point-max)))) | 159 | (goto-char (point-max)))) |
| 104 | (set-marker (process-mark proc) (point))) | 160 | (set-marker (process-mark proc) (point))) |
| 105 | (and moving | 161 | (and moving |
| 106 | (goto-char (process-mark proc)))) | 162 | (goto-char (process-mark proc)))) |
| 107 | (set-buffer old-buffer) | 163 | (set-buffer old-buffer) |
| 108 | (store-match-data old-match-data)))) | 164 | (store-match-data old-match-data))) |
| 165 | (and rlogin-password-paranoia | ||
| 166 | (string= "Password:" string) | ||
| 167 | (let ((input (comint-read-noecho "Enter password: " 'stars))) | ||
| 168 | (and input | ||
| 169 | (progn | ||
| 170 | (insert-before-markers "\n") | ||
| 171 | (comint-send-string proc (format "%s\n" input))))))) | ||
| 109 | 172 | ||
| 110 | (defun rlogin-send-Ctrl-C () | 173 | (defun rlogin-send-Ctrl-C () |
| 111 | (interactive) | 174 | (interactive) |
| @@ -128,4 +191,3 @@ buffer." | |||
| 128 | (delete-char arg))) | 191 | (delete-char arg))) |
| 129 | 192 | ||
| 130 | ;;; rlogin.el ends here | 193 | ;;; rlogin.el ends here |
| 131 | |||