-(defun rlogin-filter (proc string)
- (let ((old-buffer (current-buffer))
- (old-match-data (match-data))
- at-max-pos
- moving)
- (unwind-protect
- (progn
- (set-buffer (process-buffer proc))
- (setq moving (= (point) (process-mark proc)))
- (save-excursion
- (goto-char (process-mark proc))
- (save-restriction
- (let ((beg (point)))
- (insert-before-markers string)
- (narrow-to-region beg (point))
- (goto-char (point-min))
- (while (search-forward "\C-m" nil t)
- (delete-char -1))
- (and rlogin-password-paranoia
- (setq string (buffer-substring (point-min) (point-max))))
- (goto-char (point-max))))
- (set-marker (process-mark proc) (point)))
- (and moving
- (goto-char (process-mark proc))))
- (set-buffer old-buffer)
- (store-match-data old-match-data)))
- (and rlogin-password-paranoia
- (string= "Password:" string)
- (let ((input (comint-read-noecho "Enter password: " 'stars)))
- (and input
- (progn
- (insert-before-markers "\n")
- (comint-send-string proc (format "%s\n" input)))))))
+(defun rlogin-directory-tracking-mode (&optional prefix)
+ "Do remote or local directory tracking, or disable entirely.
+
+If called with no prefix argument or a unspecified prefix argument (just
+``\\[universal-argument]'' with no number) do remote directory tracking via
+ange-ftp. If called as a function, give it no argument.
+
+If called with a negative prefix argument, disable directory tracking
+entirely.
+
+If called with a positive, numeric prefix argument, e.g.
+``\\[universal-argument] 1 M-x rlogin-directory-tracking-mode\'',
+then do directory tracking but assume the remote filesystem is the same as
+the local system. This only works in general if the remote machine and the
+local one share the same directories (through NFS)."
+ (interactive "P")
+ (cond
+ ((or (null prefix)
+ (consp prefix))
+ (setq rlogin-directory-tracking-mode t)
+ (setq shell-dirtrackp t)
+ (setq comint-file-name-prefix
+ (concat "/" rlogin-remote-user "@" rlogin-host ":")))
+ ((< prefix 0)
+ (setq rlogin-directory-tracking-mode nil)
+ (setq shell-dirtrackp nil))
+ (t
+ (setq rlogin-directory-tracking-mode 'local)
+ (setq comint-file-name-prefix "")
+ (setq shell-dirtrackp t)))
+ (cond
+ (shell-dirtrackp
+ (let* ((proc (get-buffer-process (current-buffer)))
+ (proc-mark (process-mark proc))
+ (current-input (buffer-substring proc-mark (point-max)))
+ (orig-point (point))
+ (offset (and (>= orig-point proc-mark)
+ (- (point-max) orig-point))))
+ (unwind-protect
+ (progn
+ (delete-region proc-mark (point-max))
+ (goto-char (point-max))
+ (shell-resync-dirs))
+ (goto-char proc-mark)
+ (insert current-input)
+ (if offset
+ (goto-char (- (point-max) offset))
+ (goto-char orig-point)))))))
+
+\f
+;; Parse a line into its constituent parts (words separated by
+;; whitespace). Return a list of the words.
+(defun rlogin-parse-words (line)
+ (let ((list nil)
+ (posn 0)
+ (match-data (match-data)))
+ (while (string-match "[^ \t\n]+" line posn)
+ (setq list (cons (substring line (match-beginning 0) (match-end 0))
+ list))
+ (setq posn (match-end 0)))
+ (set-match-data (match-data))
+ (nreverse list)))
+
+(defun rlogin-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)))