unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Unwanted ^M in the output from shell-command-on-region
@ 2006-05-16 20:07 Lennart Borgman
  2006-05-17  1:33 ` Kenichi Handa
  0 siblings, 1 reply; 3+ messages in thread
From: Lennart Borgman @ 2006-05-16 20:07 UTC (permalink / raw)


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
  "
<html>
<head>
</head>
</html>
") ;; 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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Unwanted ^M in the output from shell-command-on-region
  2006-05-16 20:07 Unwanted ^M in the output from shell-command-on-region Lennart Borgman
@ 2006-05-17  1:33 ` Kenichi Handa
  2006-05-17  6:14   ` Lennart Borgman
  0 siblings, 1 reply; 3+ messages in thread
From: Kenichi Handa @ 2006-05-17  1:33 UTC (permalink / raw)
  Cc: emacs-devel

In article <446A3101.5020007@student.lu.se>, Lennart Borgman <lennart.borgman.073@student.lu.se> 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 ---
<html>
<head>
</head>
</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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Unwanted ^M in the output from shell-command-on-region
  2006-05-17  1:33 ` Kenichi Handa
@ 2006-05-17  6:14   ` Lennart Borgman
  0 siblings, 0 replies; 3+ messages in thread
From: Lennart Borgman @ 2006-05-17  6:14 UTC (permalink / raw)
  Cc: emacs-devel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-17  6:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-16 20:07 Unwanted ^M in the output from shell-command-on-region Lennart Borgman
2006-05-17  1:33 ` Kenichi Handa
2006-05-17  6:14   ` Lennart Borgman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).