-;;;###autoload
-(defun rlogin-password (&optional proc)
- "Read a password and send it to an rlogin session.
-For each character typed, a `*' is echoed in the minibuffer.
-End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line.
-C-g aborts attempt to read and send password.
-
-Optional argument PROC is the process to which the password should be sent.
-If not provided, send to the process in the current buffer. This argument
-is intended primarily for use by `rlogin-filter'."
- (interactive)
- (or proc (setq proc (get-buffer-process (current-buffer))))
- (let* ((buffer-name (buffer-name (process-buffer proc)))
- (pass (comint-read-noecho (format "Password for buffer \"%s\": "
- buffer-name)
- 'stars)))
- (and pass
- (save-excursion
- (set-buffer buffer-name)
- (insert-before-markers "\n")
- (comint-send-string proc (format "%s\n" pass))))))
+ (cond ((null buffer))
+ ((stringp buffer)
+ (setq buffer-name buffer))
+ ((bufferp buffer)
+ (setq buffer-name (buffer-name buffer)))
+ ((numberp buffer)
+ (setq buffer-name (format "%s<%d>" buffer-name buffer)))
+ (t
+ (setq buffer-name (generate-new-buffer-name buffer-name))))
+
+ (setq buffer (get-buffer-create buffer-name))
+ (pop-to-buffer buffer-name)
+
+ (cond
+ ((comint-check-proc buffer-name))
+ (t
+ (comint-exec buffer buffer-name rlogin-program nil args)
+ (setq proc (get-buffer-process buffer))
+ ;; Set process-mark to point-max in case there is text in the
+ ;; buffer from a previous exited process.
+ (set-marker (process-mark proc) (point-max))
+
+ ;; comint-output-filter-functions is just like a hook, except that the
+ ;; functions in that list are passed arguments. add-hook serves well
+ ;; enough for modifying it.
+ ;; comint-output-filter-functions should already have a
+ ;; permanent-local property, at least in emacs 19.27 or later.
+ (if (fboundp 'make-local-hook)
+ (make-local-hook 'comint-output-filter-functions)
+ (make-local-variable 'comint-output-filter-functions))
+ (add-hook 'comint-output-filter-functions 'rlogin-carriage-filter)
+
+ (rlogin-mode)
+
+ (make-local-variable 'rlogin-host)
+ (setq rlogin-host host)
+ (make-local-variable 'rlogin-remote-user)
+ (setq rlogin-remote-user user)
+
+ (condition-case ()
+ (cond ((eq rlogin-directory-tracking-mode t)
+ ;; Do this here, rather than calling the tracking mode
+ ;; function, to avoid a gratuitous resync check; the default
+ ;; should be the user's home directory, be it local or remote.
+ (setq comint-file-name-prefix
+ (concat "/" rlogin-remote-user "@" rlogin-host ":"))
+ (cd-absolute comint-file-name-prefix))
+ ((null rlogin-directory-tracking-mode))
+ (t
+ (cd-absolute (concat comint-file-name-prefix "~/"))))
+ (error nil))))))
+
+(put 'rlogin-mode 'mode-class 'special)