From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Unwanted ^M in the output from shell-command-on-region Date: Tue, 16 May 2006 22:07:29 +0200 Message-ID: <446A3101.5020007@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1147810084 10531 80.91.229.2 (16 May 2006 20:08:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 16 May 2006 20:08:04 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 16 22:08:01 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fg5pb-00036n-Qu for ged-emacs-devel@m.gmane.org; Tue, 16 May 2006 22:07:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fg5pb-0000US-B8 for ged-emacs-devel@m.gmane.org; Tue, 16 May 2006 16:07:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fg5pM-0000SB-Rz for emacs-devel@gnu.org; Tue, 16 May 2006 16:07:32 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fg5pL-0000R9-3O for emacs-devel@gnu.org; Tue, 16 May 2006 16:07:32 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fg5pL-0000R5-0N for emacs-devel@gnu.org; Tue, 16 May 2006 16:07:31 -0400 Original-Received: from [81.228.11.98] (helo=pne-smtpout1-sn1.fre.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fg5s2-0006h2-P6 for emacs-devel@gnu.org; Tue, 16 May 2006 16:10:18 -0400 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout1-sn1.fre.skanova.net (7.2.072.1) id 44609CD600215854 for emacs-devel@gnu.org; Tue, 16 May 2006 22:07:29 +0200 User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) Original-To: Emacs Devel X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:54608 Archived-At: This is a problem on w32, but might be more general. I can not understand how to get rid of ^M from the output of the program Tidy when I run it with `shell-command-on-region' (or in other ways). From the documentation it looks like `coding-system-for-read' or `coding-system-for-write' should be used, but setting them does not remove ^M. I have made an example below. It uses the program Tidy from http://tidy.sourceforge.net/trt/tidy_win32.zip. (Tidy is a program for (X)HTML curing.) I am doing this on w32 with GNU Emacs 22.0.50.1 (i386-mingw-nt5.0.2195) of 2006-05-13 *** Example code: (defvar temp-html ;; Start-here " ") ;; Stop-here (defun temp-c-m() (let* ((temp-buffer (get-buffer-create "temp-c-m")) (start (save-excursion (goto-char (point-min)) (search-forward "Start-here") (forward-line 2) (point))) (end (save-excursion (goto-char start) (search-forward "Stop-here") (beginning-of-line) (point))) (command (concat "c:/dl/programs/Tidy.exe" )) (coding-system-for-read 'undecided-dos) (coding-system-for-write 'undecided-dos) ) (with-current-buffer temp-buffer (erase-buffer)) (shell-command-on-region start end command temp-buffer nil) (with-current-buffer temp-buffer (goto-char (point-max)) (insert (current-time-string) "\n\n")) )) (temp-c-m) From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: Unwanted ^M in the output from shell-command-on-region Date: Wed, 17 May 2006 10:33:16 +0900 Message-ID: References: <446A3101.5020007@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1147829625 4460 80.91.229.2 (17 May 2006 01:33:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 17 May 2006 01:33:45 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 17 03:33:42 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FgAuw-0004TF-JS for ged-emacs-devel@m.gmane.org; Wed, 17 May 2006 03:33:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FgAuv-0002cd-I6 for ged-emacs-devel@m.gmane.org; Tue, 16 May 2006 21:33:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FgAuh-0002c4-9p for emacs-devel@gnu.org; Tue, 16 May 2006 21:33:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FgAuf-0002bj-Ld for emacs-devel@gnu.org; Tue, 16 May 2006 21:33:23 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FgAuf-0002bg-Fw for emacs-devel@gnu.org; Tue, 16 May 2006 21:33:21 -0400 Original-Received: from [192.47.44.130] (helo=tsukuba.m17n.org) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FgAxQ-0006aO-8M for emacs-devel@gnu.org; Tue, 16 May 2006 21:36:12 -0400 Original-Received: from nfs.m17n.org (nfs.m17n.org [192.47.44.7]) by tsukuba.m17n.org (8.13.4/8.13.4/Debian-3sarge1) with ESMTP id k4H1XHBT031681; Wed, 17 May 2006 10:33:17 +0900 Original-Received: from etlken (etlken.m17n.org [192.47.44.125]) by nfs.m17n.org (8.13.4/8.13.4/Debian-3sarge1) with ESMTP id k4H1XHhg007754; Wed, 17 May 2006 10:33:17 +0900 Original-Received: from handa by etlken with local (Exim 3.36 #1 (Debian)) id 1FgAua-0004Wi-00; Wed, 17 May 2006 10:33:16 +0900 Original-To: Lennart Borgman In-reply-to: <446A3101.5020007@student.lu.se> (message from Lennart Borgman on Tue, 16 May 2006 22:07:29 +0200) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/22.0.50 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:54611 Archived-At: In article <446A3101.5020007@student.lu.se>, Lennart Borgman writes: > This is a problem on w32, but might be more general. I can not > understand how to get rid of ^M from the output of the program Tidy when > I run it with `shell-command-on-region' (or in other ways). From the > documentation it looks like `coding-system-for-read' or > `coding-system-for-write' should be used, but setting them does not > remove ^M. > I have made an example below. It uses the program Tidy from > http://tidy.sourceforge.net/trt/tidy_win32.zip. (Tidy is a program for > (X)HTML curing.) I made this HTML file (with dos coding system): --- temp.html --- ----------------- and run Tidy.exe as this in Cygwin terminal. % Tidy.exe < temp.html 2>&1 | od -c Then the output was like this: 0000000 l i n e 1 c o l u m n 1 0000020 - W a r n i n g : m i s s i 0000040 n g < ! D O C T Y P E > d e 0000060 c l a r a t i o n \r \r \n l i n e 0000100 4 c o l u m n 1 - W a 0000120 r n i n g : d i s c a r d i n 0000140 g u n e x p e c t e d < / h 0000160 t m l > \r \r \n l i n e 2 c o As you see, the output contains \r\r\n sequence. But, undecided-dos docodes only the \r\n sequnce into \n. That's why you see the remaining \r. So, it seems that it is the problem of Tidy.exe. --- Kenichi Handa handa@m17n.org From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: Unwanted ^M in the output from shell-command-on-region Date: Wed, 17 May 2006 08:14:24 +0200 Message-ID: <446ABF40.7040202@student.lu.se> References: <446A3101.5020007@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1147846491 17256 80.91.229.2 (17 May 2006 06:14:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 17 May 2006 06:14:51 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 17 08:14:49 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FgFJ2-0003Pg-S7 for ged-emacs-devel@m.gmane.org; Wed, 17 May 2006 08:14:49 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FgFJ2-00087s-DW for ged-emacs-devel@m.gmane.org; Wed, 17 May 2006 02:14:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FgFIn-00085B-VB for emacs-devel@gnu.org; Wed, 17 May 2006 02:14:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FgFIn-00083Z-1M for emacs-devel@gnu.org; Wed, 17 May 2006 02:14:33 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FgFIm-00083G-OV for emacs-devel@gnu.org; Wed, 17 May 2006 02:14:32 -0400 Original-Received: from [81.228.8.83] (helo=pne-smtpout1-sn2.hy.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FgFLa-0001yg-5T for emacs-devel@gnu.org; Wed, 17 May 2006 02:17:26 -0400 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout1-sn2.hy.skanova.net (7.2.072.1) id 4469AC9000037324; Wed, 17 May 2006 08:14:25 +0200 User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) Original-To: Kenichi Handa In-Reply-To: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:54621 Archived-At: Kenichi Handa wrote: > As you see, the output contains \r\r\n sequence. But, > undecided-dos docodes only the \r\n sequnce into \n. That's > why you see the remaining \r. > > So, it seems that it is the problem of Tidy.exe. > Thanks Handa, I did not think of that at all. It is a bit hard to imagine how that error emerged. However there is already a bug report on this and I hope it will be solved: http://sourceforge.net/tracker/index.php?func=detail&aid=1425219&group_id=27659&atid=390963