changeset 10849:eb6af491e98f

(rlogin-carriage-filter): Don't assume region is narrowed to most recent output.
author Noah Friedman <friedman@splode.com>
date Tue, 28 Feb 1995 09:51:49 +0000
parents e591f74ac16e
children 0794141677db
files lisp/rlogin.el
diffstat 1 files changed, 20 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/rlogin.el	Tue Feb 28 06:24:39 1995 +0000
+++ b/lisp/rlogin.el	Tue Feb 28 09:51:49 1995 +0000
@@ -49,8 +49,8 @@
   "*Hooks to run after setting current buffer to rlogin-mode.")
 
 (defvar rlogin-process-connection-type nil
-  "*If non-`nil', use a pty for the local rlogin process.  
-If `nil', use a pipe (if pipes are supported on the local system).  
+  "*If non-`nil', use a pty for the local rlogin process.
+If `nil', use a pipe (if pipes are supported on the local system).
 
 Generally it is better not to waste ptys on systems which have a static
 number of them.  On the other hand, some implementations of `rlogin' assume
@@ -87,7 +87,7 @@
 
 ;; Initialize rlogin mode map.
 (defvar rlogin-mode-map '())
-(cond 
+(cond
  ((null rlogin-mode-map)
   (setq rlogin-mode-map (if (consp shell-mode-map)
                             (cons 'keymap shell-mode-map)
@@ -111,7 +111,7 @@
 a new buffer with a different connection will be made.
 
 The variable `rlogin-program' contains the name of the actual program to
-run.  It can be a relative or absolute path. 
+run.  It can be a relative or absolute path.
 
 The variable `rlogin-explicit-args' is a list of arguments to give to
 the rlogin when starting.  They are added after any arguments given in
@@ -172,7 +172,7 @@
       ;; buffer from a previous exited process.
       (set-marker (process-mark proc) (point-max))
       (rlogin-mode)
-      
+
       ;; 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.
@@ -188,7 +188,7 @@
         ;; 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 
+        (setq comint-file-name-prefix
               (concat "/" rlogin-remote-user "@" rlogin-host ":"))
         (cd-absolute comint-file-name-prefix))
        ((null rlogin-directory-tracking-mode))
@@ -196,7 +196,7 @@
         (cd-absolute (concat comint-file-name-prefix "~/"))))))))
 
 (defun rlogin-mode ()
-  "Set major-mode for rlogin sessions. 
+  "Set major-mode for rlogin sessions.
 If `rlogin-mode-hook' is set, run it."
   (interactive)
   (kill-all-local-variables)
@@ -218,7 +218,7 @@
 If called with a negative prefix argument, disable directory tracking
 entirely.
 
-If called with a positive, numeric prefix argument, e.g. 
+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
@@ -229,7 +229,7 @@
         (consp prefix))
     (setq rlogin-directory-tracking-mode t)
     (setq shell-dirtrack-p t)
-    (setq comint-file-name-prefix 
+    (setq comint-file-name-prefix
           (concat "/" rlogin-remote-user "@" rlogin-host ":")))
    ((< prefix 0)
     (setq rlogin-directory-tracking-mode nil)
@@ -238,7 +238,7 @@
     (setq rlogin-directory-tracking-mode 'local)
     (setq comint-file-name-prefix "")
     (setq shell-dirtrack-p t)))
-  (cond 
+  (cond
    (shell-dirtrack-p
     (let* ((proc (get-buffer-process (current-buffer)))
            (proc-mark (process-mark proc))
@@ -271,13 +271,14 @@
     (store-match-data (match-data))
     (nreverse list)))
 
-(defun rlogin-carriage-filter (&rest ignored)
-  ;; When this function is called, the buffer will already have been
-  ;; narrowed to the region containing the most recently-inserted text.
-  ;; (See `comint-output-filter' in comint.el.)  
-  (let ((point-marker (point-marker)))
-    (goto-char (point-min))
-    (while (search-forward "\C-m" (point-max) t)
+(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)))
 
@@ -299,8 +300,8 @@
 
 (defun rlogin-delchar-or-send-Ctrl-D (arg)
   "\
-Delete ARG characters forward, or send a C-d to process if at end of buffer."  
-  (interactive "p") 
+Delete ARG characters forward, or send a C-d to process if at end of buffer."
+  (interactive "p")
   (if (eobp)
       (rlogin-send-Ctrl-D)
     (delete-char arg)))