Subject: bug#4343 closed by Juri Linkov <[email-masked]> (Re: bug#4343: comint-carriage-motion for async-shell-command)

From: [email-masked] (Emacs bug Tracking System)
Date: Thu, 10 Sep 2009 01:05:05 +0000

This is an automatic notification regarding your bug report
which was filed against the emacs package:

#4343: comint-carriage-motion for async-shell-command

It has been closed by Juri Linkov <[email-masked]>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Juri Linkov <[email-masked]> by
replying to this email.

-- 
4343: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4343
Emacs Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#4343: comint-carriage-motion for async-shell-command
From: Juri Linkov <[email-masked]>
To: Stefan Monnier <[email-masked]>
Cc: [email-masked]
Date: Thu, 10 Sep 2009 03:55:21 +0300

>> Other than setting `comint-output-filter', `comint-exec' also starts
>> a process.  But starting a process is not necessary in `shell-command'
>> that starts it explicitly.
>
> OK, then.
>
>>> And try and move this into a new function `comint-setup-process' which
>>> both compile.el and M-& could then use?
>
>> They can't be merged because `compilation-filter' runs a compile-specific
>> hook `compilation-filter-hook'.
>
> Too bad.  Please install your patch, then.

Done.

-- 
Juri Linkov
http://www.jurta.org/emacs/

Subject: comint-carriage-motion for async-shell-command
From: Juri Linkov <[email-masked]>
To: [email-masked]
Date: Sat, 05 Sep 2009 00:02:33 +0300

Often an asynchronous shell command run with M-& produces the output
that looks like garbage when programs use carriage control characters ^M
to display progress with percentages.

Even the `compile' command is better in this regard because its
`compilation-filter' handles carriage motion using the function
`comint-carriage-motion'.

The following patch does the same for asynchronous commands in
`shell-command'.  It seems it was intended to do this anyway because
`*Async Shell Command*' uses `shell-mode'.  But `shell-mode' doesn't set
the filter that processes carriage control characters.  It is the `shell'
command that sets the filter via `comint-exec' before enabling `shell-mode'.
So it's necessary to set the filter explicitly in `shell-command'
after enabling `shell-mode':

Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.1008
diff -u -r1.1008 simple.el
--- lisp/simple.el	28 Aug 2009 04:21:17 -0000	1.1008
+++ lisp/simple.el	4 Sep 2009 21:02:21 -0000
@@ -2214,7 +2220,11 @@
 		  (setq mode-line-process '(":%s"))
 		  (require 'shell) (shell-mode)
 		  (set-process-sentinel proc 'shell-command-sentinel)
+		  ;; Use the comint filter for proper handling of carriage motion
+		  ;; (see `comint-inhibit-carriage-motion'),.
+		  (set-process-filter proc 'comint-output-filter)
 		  ))
 	    (shell-command-on-region (point) (point) command
 				     output-buffer nil error-buffer)))))))

-- 
Juri Linkov
http://www.jurta.org/emacs/