Subject: yet another fix for double echo in shell

From: [email-masked] (George D. Hadden)
Date: Mon, 30 Sep 96 11:23:51 CDT

i'm having a problem with processes echoing input that doesn't seem to
be fixed by setting comint-process-echoes to t.  i think there's a bug
in comint.el AND i have a suggested fix for it.  (can someone tell me
the appropriate protocol to submit this bug report and fix?  thanks.)
although, i DO wonder why this hasn't been reported on the newsgroup
... maybe something else i did broke it ... :-}

here's the problem.  note the unwanted echoing occurs either on the
same line as the input or the following line depending on whether
comint-process-echoes is t or nil.

	  Microsoft(R) Windows 95
	     (C)Copyright Microsoft Corp 1981-1995.

	  rem comint-process-echoes --> t
	  rem comint-input-autoexpand --> history

	  uh, clem?  C:\TEMP>dirdir

	   Volume in drive C is MS-DOS_62  
	   Volume Serial Number is 1CFD-182F
	   Directory of C:\TEMP

	  .              <DIR>        07-10-95  1:51p .
	  ..             <DIR>        07-10-95  1:51p ..
	  T                        0  09-30-96 10:58a t
		   1 file(s)              0 bytes
		   2 dir(s)      46,891,008 bytes free

	  rem comint-process-echoes --> nil

	  uh, clem?  C:\TEMP>dir
	  dir

	   Volume in drive C is MS-DOS_62  
	   Volume Serial Number is 1CFD-182F
	   Directory of C:\TEMP

	  .              <DIR>        07-10-95  1:51p .
	  ..             <DIR>        07-10-95  1:51p ..
	  T                        0  09-30-96 10:58a t
		   1 file(s)              0 bytes
		   2 dir(s)      46,891,008 bytes free

	  uh, clem?  C:\TEMP>

the reason for the problem and it's fix should be clear from my
comments in the function comint-send-input (from the file comint.el)
shown below: 

(defun comint-send-input () 
... stuff deleted ...
	       (history (if (not (eq comint-input-autoexpand 'history))
			    input
			  ;; This is messy 'cos ultimately the original
			  ;; functions used do insertion, rather than return
			  ;; strings.  We have to expand, then insert back.
			  (comint-replace-by-expanded-history t)
			  (let ((copy (buffer-substring pmark (point))))
			    ;; geo:  the following has the unfortunate
			    ;; consequence of eliminating the difference
			    ;; between pmark and point.  this causes a double
			    ;; same-line echo of the command because of the
			    ;; now ineffective delete-region below.
			    ;;
			    ;; changing insert-before-markers to insert
			    ;; seems to fix the problem by allowing pmark
			    ;; to remain before the input and thus allowing
			    ;; the subsequent delete-region to work correctly
			    ;;
			    (delete-region pmark (point))
;			    (insert-before-markers input)
			    (insert input)
			    copy))))
          (if comint-process-echoes
              (delete-region pmark (point))
	    (insert-before-markers ?\n))
... stuff deleted ...

here's the same shell command after evaluating the function with the
above changes:

	  uh, clem?  C:\TEMP>dir

	   Volume in drive C is MS-DOS_62  
	   Volume Serial Number is 1CFD-182F
	   Directory of C:\TEMP

	  .              <DIR>        07-10-95  1:51p .
	  ..             <DIR>        07-10-95  1:51p ..
	  T                        0  09-30-96 10:58a t
		   1 file(s)              0 bytes
		   2 dir(s)      46,858,240 bytes free

	  uh, clem?  C:\TEMP>

(no, i didn't fix the ^M problem - sorry :-)

comments?

-geo
---
George D. Hadden, Senior Research Fellow
Honeywell Technology Center, 3660 Technology Drive, Minneapolis, MN 55418
[email-masked], (612)951-7769(voice), (612)951-7438(fax)

> Date: Mon, 30 Sep 96 11:23:51 CDT
> From: [email-masked] (George D. Hadden)
> 
> i'm having a problem with processes echoing input that doesn't seem to
> be fixed by setting comint-process-echoes to t.

The correct fix is to start cmd.exe with the /q option via 

  (setq explicit-cmd.exe-args "/q")

where explicit-shell-file-name is "cmd.exe". If you use a different
explicit-shell-file-name, set the explicit-*-args variable accordingly.

That is, cmd.exe is echoing the commands, not comint

---

From: David Biesack <[email-masked]>
Date: Mon, 30 Sep 1996 15:59:24 -0400

---

From: [email-masked] (George D. Hadden)
Date: Mon, 30 Sep 96 18:03:48 CDT

>>>>> "DB" == David Biesack <[email-masked]> writes:

>> be fixed by setting comint-process-echoes to t.

DB> The correct fix is to start cmd.exe with the /q option via 

DB>   (setq explicit-cmd.exe-args "/q")

DB> where explicit-shell-file-name is "cmd.exe". If you use a different
DB> explicit-shell-file-name, set the explicit-*-args variable accordingly.

DB> That is, cmd.exe is echoing the commands, not comint

david, thanks for your response.  unfortunately, i tried this and it
doesn't work for me.  i think that there's a bug in the elisp
code, and i'm looking for verification of this and comments on the solution
proposed in my previous message.

again, here are the conditions that make this bug appear:
1) windows 95 (although this shouldn't matter)
2) comint-input-autoexpand --> 'history
3) comint-process-echoes --> t

incidentally, since they're buffer-local symbols, performing the 

(setq comint-input-autexpand 'history) 

and the 

(setq comint-process-echoes t) 

in the *scratch* buffer will not do what you want.  you must instead
execute the command "eval-expression", and then type the expressions to it
while in the *shell* buffer.  (there's probably a better way, but i don't
know it :-)

so, is there anyone out there for whom this also fails, or am i
halucinating? 

thanks,

-geo
---