annotate lisp/rlogin.el @ 2447:6ff9eee5cdc9

* timer.el (timer-program): New defconst. (run-at-time): Use timer-program as the name of the program the subprocess should run, and search for it in exec-directory, rather than checking the entire exec path.
author Jim Blandy <jimb@redhat.com>
date Thu, 01 Apr 1993 01:07:38 +0000
parents f51bd6676409
children 577c77cfd199
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
1 ;;; rlogin.el --- remote login interface
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
2
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
3 ;; Maintainer: Noah Friedman <friedman@prep.ai.mit.edu>
2259
2ba32183ea62 Added keyword.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2233
diff changeset
4 ;; Keywords: unix, comm
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
5
2387
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
6 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
7 ;;
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
8 ;; This program is free software; you can redistribute it and/or modify
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
11 ;; any later version.
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
12 ;;
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
13 ;; This program is distributed in the hope that it will be useful,
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
16 ;; GNU General Public License for more details.
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
17 ;;
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
18 ;; You should have received a copy of the GNU General Public License
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
19 ;; along with this program; if not, write to: The Free Software Foundation,
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
20 ;; Inc.; 675 Massachusetts Avenue.; Cambridge, MA 02139, USA.
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
22 ;;; Commentary:
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
23
2387
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
24 ;; Support for remote logins using `rlogin'.
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
25 ;;
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
26 ;; Todo: add directory tracking using ange-ftp style patchnames for the cwd.
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
28 ;;; Code:
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
29
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
30 (require 'comint)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32 (defvar rlogin-program "rlogin"
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 "*Name of program to invoke rlogin")
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
35 (defvar rlogin-explicit-args nil
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
36 "*List of arguments to pass to rlogin on the command line.")
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
37
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38 (defvar rlogin-mode-hook nil
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39 "*Hooks to run after setting current buffer to rlogin-mode.")
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
41 ;; I think this is so obnoxious I refuse to enable it by default.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
42 ;; In any case, there is a bug with regards to generating a quit while
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
43 ;; reading keyboard input in a process filter, so until that's fixed it's
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
44 ;; not safe to enable this anyway.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
45 (defvar rlogin-password-paranoia nil
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
46 "*If non-`nil', query user for a password in the minibuffer when a
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
47 Password: prompt appears. Stars will echo as characters are type.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
48
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
49 It's also possible to selectively enter passwords without echoing them in
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
50 the minibuffer using the function `rlogin-password'.")
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
51
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
52 (defvar rlogin-last-input-line nil nil)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
53
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54 ;; Initialize rlogin mode map.
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55 (defvar rlogin-mode-map '())
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
56 (cond ((not rlogin-mode-map)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 (setq rlogin-mode-map (full-copy-sparse-keymap comint-mode-map))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58 ;(define-key rlogin-mode-map "\M-\t" 'comint-dynamic-complete)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 ;(define-key rlogin-mode-map "\M-?" 'comint-dynamic-list-completions)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60 (define-key rlogin-mode-map "\C-c\C-c" 'rlogin-send-Ctrl-C)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61 (define-key rlogin-mode-map "\C-c\C-z" 'rlogin-send-Ctrl-Z)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 (define-key rlogin-mode-map "\C-c\C-\\" 'rlogin-send-Ctrl-backslash)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 (define-key rlogin-mode-map "\C-d" 'rlogin-delchar-or-send-Ctrl-D)))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64
2387
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
65 ;;;###autoload
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
66 (defun rlogin (&optional prefix host)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
67 "Open a network login connection to HOST via the `rlogin' program.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
68 Input is sent line-at-a-time to the remote connection.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
69
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
70 Communication with HOST is recorded in a buffer *rlogin-HOST*.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
71 If a prefix argument is given and the buffer *rlogin-HOST* already exists,
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
72 a new buffer with a different connection will be made.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
73
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
74 The variable `rlogin-program' contains the name of the actual program to
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
75 run. It can be a relative or absolute path.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
76
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
77 The variable `rlogin-explicit-args' is a list of arguments to give to
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
78 the rlogin when starting."
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
79 (interactive (list current-prefix-arg
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
80 (read-from-minibuffer "Open rlogin connection to host: ")))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
81 (let* ((buffer-name (format "*rlogin-%s*" host))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
82 (args (if (and rlogin-explicit-args (listp rlogin-explicit-args))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
83 (cons host rlogin-explicit-args)
2405
f51bd6676409 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2404
diff changeset
84 (list host)))
f51bd6676409 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2404
diff changeset
85 proc)
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
86 (and prefix (setq buffer-name
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
87 (buffer-name (generate-new-buffer buffer-name))))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
88 (switch-to-buffer buffer-name)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
89 (or (comint-check-proc buffer-name)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
90 (progn
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
91 (comint-mode)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
92 (comint-exec (current-buffer) buffer-name rlogin-program nil args)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
93 (setq proc (get-process buffer-name))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
94 (set-marker (process-mark proc) (point-min))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
95 (set-process-filter proc 'rlogin-filter)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
96 (rlogin-mode)))))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
97
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
98 ;;;###autoload
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
99 (defun rlogin-with-args (host args)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
100 "Open a new rlogin connection to HOST, even if one already exists.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
101 String ARGS is given as arguments to the `rlogin' program, overriding the
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
102 value of `rlogin-explicit-args'."
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
103 (interactive (list (read-from-minibuffer "Open rlogin connection to host: ")
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
104 (read-from-minibuffer "with arguments: ")))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
105 (let ((old-match-data (match-data))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
106 (rlogin-explicit-args nil))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
107 (unwind-protect
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
108 (progn
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
109 (while (string-match "[ \t]*\\([^ \t]\\)+$" args)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
110 (setq rlogin-explicit-args
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
111 (cons (substring args
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
112 (match-beginning 1)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
113 (match-end 1))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
114 rlogin-explicit-args)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
115 args (substring args 0 (match-beginning 0)))))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
116 (store-match-data old-match-data))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
117 (rlogin 1 host)))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
118
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
119 ;;;###autoload
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
120 (defun rlogin-password ()
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
121 "Play the paranoia game by not echoing entered password in buffer
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
122 (stars will echo in the minibuffer instead."
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
123 (interactive)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
124 (let ((input (comint-read-noecho "Enter password: " 'stars)))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
125 (insert-before-markers "\n")
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
126 (comint-send-string (get-buffer-process (current-buffer))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
127 (format "%s\n" input))))
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
128
2387
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
129 ;;;###autoload
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
130 (defun rlogin-mode ()
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
131 (interactive)
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
132 (kill-all-local-variables)
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
133 (comint-mode)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
134 (setq comint-prompt-regexp shell-prompt-pattern)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
135 (setq major-mode 'rlogin-mode)
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
136 (setq mode-name "rlogin")
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
137 (use-local-map rlogin-mode-map)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
138 (run-hooks 'rlogin-mode-hook))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
139
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
140 (defun rlogin-filter (proc string)
2387
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
141 (let ((old-buffer (current-buffer))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
142 (old-match-data (match-data))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
143 at-max-pos
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
144 moving)
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
145 (unwind-protect
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
146 (progn
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
147 (set-buffer (process-buffer proc))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
148 (setq moving (= (point) (process-mark proc)))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
149 (save-excursion
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
150 (goto-char (process-mark proc))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
151 (save-restriction
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
152 (let ((beg (point)))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
153 (insert-before-markers string)
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
154 (narrow-to-region beg (point))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
155 (goto-char (point-min))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
156 (while (search-forward "\C-m" nil t)
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
157 (delete-char -1))
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
158 (and rlogin-password-paranoia
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
159 (setq string (buffer-substring (point-min) (point-max))))
2387
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
160 (goto-char (point-max))))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
161 (set-marker (process-mark proc) (point)))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
162 (and moving
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
163 (goto-char (process-mark proc))))
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
164 (set-buffer old-buffer)
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
165 (store-match-data old-match-data)))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
166 (and rlogin-password-paranoia
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
167 (string= "Password:" string)
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
168 (let ((input (comint-read-noecho "Enter password: " 'stars)))
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
169 (and input
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
170 (progn
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
171 (insert-before-markers "\n")
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
172 (comint-send-string proc (format "%s\n" input)))))))
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
173
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
174 (defun rlogin-send-Ctrl-C ()
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
175 (interactive)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
176 (send-string nil "\C-c"))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
177
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
178 (defun rlogin-send-Ctrl-Z ()
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
179 (interactive)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
180 (send-string nil "\C-z"))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
181
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
182 (defun rlogin-send-Ctrl-backslash ()
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
183 (interactive)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
184 (send-string nil "\C-\\"))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
185
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
186 (defun rlogin-delchar-or-send-Ctrl-D (arg)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
187 "Delete ARG characters forward, or send a C-d to process if at end of
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
188 buffer."
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
189 (interactive "p")
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
190 (if (eobp)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
191 (send-string nil "\C-d")
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
192 (delete-char arg)))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
193
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
194 ;;; rlogin.el ends here