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: 20 Apr 2001 12:30:57 -0400
User-agent: Gnus/5.090002 (Oort Gnus v0.02) Emacs/20.7

Noah Friedman <address@hidden> writes:

> Along these lines is proc-filter-shell-output-filter-mode.
> Require this file and then add 
> 
> (add-hook 'comint-output-filter-functions 'proc-filter-shell-output-filter)
> 
> to your .emacs.

hey, cool.

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

--- proc-filters.el.~1~ Fri Apr 20 11:59:37 2001
+++ proc-filters.el     Fri Apr 20 12:27:35 2001
@@ -49,6 +49,7 @@
 (defvar proc-filter-shell-output-filters
   '(process-ticker-filter
     process-backspace-filter
+    process-tab-to-column-filter
     process-color-ls-filter
     process-carriage-output-filter
     process-trailing-whitespace-filter)
@@ -146,7 +147,7 @@
 (defun process-re-output-filter (string &rest re)
   "Generic comint process output filter.
 The argument STRING is only used if the current buffer is not a comint
-process buffer; it is used compute the size of the region containging the
+process buffer; it is used compute the size of the region containing the
 most recent process output.  Otherwise, `comint-last-output-start' is used.
 The remaining arguments RE are a regexps which matches text to be removed
 from the region."
@@ -184,7 +185,7 @@
 Some versions of linux include a terminally cretinous version of
 `ls' which always outputs escape sequences to colorize file names.
 These don't work in emacs buffers (at least not without some font-lock
-like enhancements.  This function strips them out."
+like enhancements).  This function strips them out."
   (process-re-output-filter string "\C-[\\[[0-9;]*m"))
 
 (defun process-trailing-whitespace-filter (&optional string)
@@ -310,6 +311,22 @@
                           (- (match-end 0)
                              (match-beginning 0)))
                        (match-beginning 0))))
+    (goto-char point-marker)))
+
+(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 (re-search-forward "\e\[[0-9]+G" end t)
+       (let ((col (string-to-number
+                   (buffer-substring (+ (match-beginning 0) 2)
+                                     (- (match-end 0) 1)))))
+         (delete-region (match-beginning 0) (match-end 0))
+         (insert-char ?  (- col (current-column))))))
     (goto-char point-marker)))
 
 ;;;###autoload

m.



reply via email to

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