gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comint-ctrl-m: handle ^M intelligently in subprocess output


From: Michael . Cook
Subject: Re: comint-ctrl-m: handle ^M intelligently in subprocess output
Date: 21 Apr 2001 16:32:11 -0400
User-agent: Gnus/5.090002 (Oort Gnus v0.02) Emacs/20.7

i wrote:
> here's a patch to handle the ^[[60G sequence that the
> /etc/rc.d/init.d scripts tend to output under linux.

looks like i should have used insert-before-markers.

(defun process-tab-to-column-filter (&optional string)
  "Treat output of ^[[60G characters by tabbing to column 60.
This sequence is used in /etc/rc.d/init.d scripts."
  (let* ((point-marker (point-marker))
         (end (process-mark (get-buffer-process (current-buffer))))
         (beg (process-filter-last-output-start string end)))
    (save-match-data
      (goto-char beg)
      (while (and (< (point) end)
                  (re-search-forward "\e\[[0-9]+G" end t))
        (let ((n (string-to-number
                  (buffer-substring (+ (match-beginning 0) 2)
                                    (- (match-end 0) 1)))))
          (delete-region (match-beginning 0) (match-end 0))
          (setq n (- n (current-column)))
          (while (>= (setq n (1- n)) 0)
            (insert-before-markers ? )))))
    (goto-char point-marker)))

(is there a more-efficient way to insert several characters before
markers than to do it in a `while' loop?)

m.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]