Article View: gnu.emacs.bug
Article #100101Re: ^M in shell buffers
From: Jeff Peck
Date: Mon, 06 Nov 1989 18:53
Date: Mon, 06 Nov 1989 18:53
67 lines
2763 bytes
2763 bytes
I'm running 18.54 on sunOS 4.0, i only notice the ^M when doing rlogin.
These routines work for me, may help you.
caveat:
I'm using cmushell mostly.
I'm not sure if the "a-filter" (marker version) really works.
"b-filter" does.
(defun a-filter-function (process string)
"process-filter which strips out extra CR chars from rlogin."
;; version using markers
(let ((buffer (process-buffer process)))
(when (bufferp buffer)
(set-buffer buffer)
(save-excursion
(goto-char (marker-position (process-mark process)))
(let ((opoint (point)))
;; need extra char to keep from inserting *at* point
(insert-before-markers string " ")
(move-marker (process-mark process) (point))
(save-restriction
(narrow-to-region opoint (point))
(goto-char opoint)
(replace-string "
)
(goto-char (marker-position (process-mark process)))
(delete-backward-char 1)
)))))
(defun b-filter-function (process string)
"process-filter which strips out extra CR chars from rlogin."
;; version using points
(let ((buffer (process-buffer process)))
(when (bufferp buffer)
(set-buffer buffer)
(let ((opoint (point))
(spoint (marker-position (process-mark process)))
(length (length string)))
(goto-char spoint)
(insert string)
(save-restriction
(narrow-to-region spoint (point))
(goto-char spoint)
(replace-string "
)
(move-marker (process-mark process) (+ spoint length))
(if (<= spoint opoint)
(goto-char (+ opoint length))
(goto-char opoint))
))))
;(setq p (get-buffer-process (get-buffer "*cmushell*")))
;(set-process-filter p 'a-filter-function)
;(set-process-filter p 'b-filter-function)
;(set-process-filter p nil)
(defun filter-ctrl-m (arg)
"Turn Ctrl-M filter on/off for this buffer."
(interactive "P")
(let ((proc (get-buffer-process (current-buffer))))
(if proc
(if arg
(progn
(set-process-filter proc nil)
(message "no ^M filter"))
(progn
(set-process-filter proc 'b-filter-function)
(message "filtering out ^M")))
(error "no process for this buffer"))))
Technical Details
Message-ID:
<8911061853.AA04993@denali.sun.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!SUN.COM!peckReferences:
<8911061614.AA01724@august>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,d00038b8661e45a5 X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1989-11-06 18:47:17 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!SUN.COM!peck From: peck@SUN.COM (Jeff Peck) Newsgroups: gnu.emacs.bug Subject: Re: ^M in shell buffers Message-ID: <8911061853.AA04993@denali.sun.com> Date: 6 Nov 89 18:53:36 GMT References: <8911061614.AA01724@august> Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 67 Posted: Mon Nov 6 19:53:36 1989