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)