unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Comint read-only-prompt
@ 2005-06-07 16:36 JD Smith
  2005-06-07 17:38 ` Luc Teirlinck
  0 siblings, 1 reply; 9+ messages in thread
From: JD Smith @ 2005-06-07 16:36 UTC (permalink / raw)



I maintain the Emacs programming mode IDLWAVE, and have previously
hacked up a comint read-only prompt with an advice to snapshot-last-
prompt.

I just compiled a CVS Emacs v22, and was pleased to find that there is
a new comint- prompt-read-only variable.  However, when I enable that
variable, I get the following non-desired behavior:

     1. At each prompt, I am warned "Text is read-only".
     2. All my input is echoed back to me (I use process-echoes).  

I thought my prompt pattern could be at fault; it contains a \r
character (which IDL throws in at odd intervals).  I changed it to
something simple, and get the same behavior.  I noticed that it works
fine in simple Shell mode, so I must have something mis-configured.

Any thoughts?

Thanks,

JD

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

* Re: Comint read-only-prompt
  2005-06-07 16:36 Comint read-only-prompt JD Smith
@ 2005-06-07 17:38 ` Luc Teirlinck
  2005-06-07 20:59   ` JD Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Luc Teirlinck @ 2005-06-07 17:38 UTC (permalink / raw)
  Cc: emacs-devel

JD Smith wrote:

   I just compiled a CVS Emacs v22, and was pleased to find that there is
   a new comint- prompt-read-only variable.  However, when I enable that
   variable, I get the following non-desired behavior:

	1. At each prompt, I am warned "Text is read-only".
	2. All my input is echoed back to me (I use process-echoes).  

   I thought my prompt pattern could be at fault; it contains a \r
   character (which IDL throws in at odd intervals).  I changed it to
   something simple, and get the same behavior.

Unless you set comint-use-prompt-regexp (formerly
comint-use-prompt-regexp-instead-of-fields) to t, the value of
shell-prompt-pattern will not matter very much.  It looks like part of
the echoed input is considered part of the prompt.  The prompt
read-only region includes the prompt and the newline before it.

It is really difficult for me to look into this, because I can not
duplicate the problem.  Trying to use idlwave-shell-mode (assuming
that is what we are talking about) I got:

apply: Searching for program: no such file or directory, idl

Sincerely,

Luc.

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

* Re: Comint read-only-prompt
  2005-06-07 17:38 ` Luc Teirlinck
@ 2005-06-07 20:59   ` JD Smith
  2005-06-07 21:28     ` Luc Teirlinck
  0 siblings, 1 reply; 9+ messages in thread
From: JD Smith @ 2005-06-07 20:59 UTC (permalink / raw)
  Cc: emacs-devel

On Tue, 2005-06-07 at 12:38 -0500, Luc Teirlinck wrote:
> JD Smith wrote:
> 
>    I just compiled a CVS Emacs v22, and was pleased to find that there is
>    a new comint- prompt-read-only variable.  However, when I enable that
>    variable, I get the following non-desired behavior:
> 
> 	1. At each prompt, I am warned "Text is read-only".
> 	2. All my input is echoed back to me (I use process-echoes).  
> 
>    I thought my prompt pattern could be at fault; it contains a \r
>    character (which IDL throws in at odd intervals).  I changed it to
>    something simple, and get the same behavior.
> 
> Unless you set comint-use-prompt-regexp (formerly
> comint-use-prompt-regexp-instead-of-fields) to t, the value of
> shell-prompt-pattern will not matter very much.  It looks like part of
> the echoed input is considered part of the prompt.  The prompt
> read-only region includes the prompt and the newline before it.
> 
> It is really difficult for me to look into this, because I can not
> duplicate the problem.  Trying to use idlwave-shell-mode (assuming
> that is what we are talking about) I got:
> 
> apply: Searching for program: no such file or directory, idl

I turned on comint-use-prompt-regexp, with the same results.  I have
comint-process-echoes set, since IDL echoes input.  If I turn it off, I
don't get the "Text is read-only" warning, but of course get the echoed
input.  It appears that comint is attempting to delete some of the input
which has already been marked read-only as a result of prompt-read-only.
I've isolated the "Text is read-only" warning to line 1550 of comint.el:

		  (delete-region comint-last-input-end
				 (+ comint-last-input-end echo-len)))))

This is in the segment of code which removes the duplicate input echoed.
When process-echoes is set, this gets called, and results in the warning
above.  This results because the echoed input has apparently already
been marked read-only, perhaps by having inherited that status from the
prior prompt somehow.  Here is an example input which delete-region
failed to delete after having matched it:

#("print,'foo'\n" 0 9 (front-sticky (read-only) read-only t inhibit-
line-move-field-capture t field output rear-nonsticky t) 9 12 (inhibit-
line-move-field-capture t field output rear-nonsticky t))

Thanks,

JD

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

* Re: Comint read-only-prompt
  2005-06-07 20:59   ` JD Smith
@ 2005-06-07 21:28     ` Luc Teirlinck
  2005-06-07 22:10       ` JD Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Luc Teirlinck @ 2005-06-07 21:28 UTC (permalink / raw)
  Cc: emacs-devel

I managed to duplicate the "Text is read-only" warning with a
different program.  But if I understand you correctly, if you set
comint-prompt-read-only to nil, you of course no longer get the
warning, but the duplicate input still does not get deleted.  That is
the behavior I observe with my program too (the mathematical software
package GAP).  GAP has a special command line option to get around
this when it is called from within Emacs.

I do not know which situations comint-process-echoes was designed to
handle, so I do not know whether the behavior I observe is a bug in
the comint-process-echoes implementation.

I will take a look at the "Text is read-only" warning.

Sincerely,

Luc.

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

* Re: Comint read-only-prompt
  2005-06-07 21:28     ` Luc Teirlinck
@ 2005-06-07 22:10       ` JD Smith
  2005-06-07 22:25         ` Luc Teirlinck
  2005-06-07 23:53         ` Luc Teirlinck
  0 siblings, 2 replies; 9+ messages in thread
From: JD Smith @ 2005-06-07 22:10 UTC (permalink / raw)
  Cc: emacs-devel

On Tue, 2005-06-07 at 16:28 -0500, Luc Teirlinck wrote:
> I managed to duplicate the "Text is read-only" warning with a
> different program.  But if I understand you correctly, if you set
> comint-prompt-read-only to nil, you of course no longer get the
> warning, but the duplicate input still does not get deleted.  That is
> the behavior I observe with my program too (the mathematical software
> package GAP).  GAP has a special command line option to get around
> this when it is called from within Emacs.

When read-only is nil, process-echoes functions normally, and I get only
one input echoed; i.e. the duplicate input *is* deleted (but the prompt
is erasable).  So, by default, I have the same usability as before
(modulo my hacked up idlw-roprompt advise functions), but am looking
forward to using prompt-read-only.

Thanks,

JD

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

* Re: Comint read-only-prompt
  2005-06-07 22:10       ` JD Smith
@ 2005-06-07 22:25         ` Luc Teirlinck
  2005-06-07 23:53         ` Luc Teirlinck
  1 sibling, 0 replies; 9+ messages in thread
From: Luc Teirlinck @ 2005-06-07 22:25 UTC (permalink / raw)
  Cc: emacs-devel

JD Smith wrote:

   When read-only is nil, process-echoes functions normally, and I get only
   one input echoed; i.e. the duplicate input *is* deleted (but the prompt
   is erasable).

Indeed, the duplication gets correctly removed for the program I am
working with (GAP) too.  My impression to the contrary must have been
due to the fact that I did something wrong.

Sincerely,

Luc.

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

* Re: Comint read-only-prompt
  2005-06-07 22:10       ` JD Smith
  2005-06-07 22:25         ` Luc Teirlinck
@ 2005-06-07 23:53         ` Luc Teirlinck
  2005-06-08  1:29           ` JD Smith
  2005-06-08 16:06           ` Stefan Monnier
  1 sibling, 2 replies; 9+ messages in thread
From: Luc Teirlinck @ 2005-06-07 23:53 UTC (permalink / raw)
  Cc: emacs-devel

The following simple patch seems to fix the problem completely for the
program I am experimenting with (GAP).  It allows some text to be
misfontified, but that text gets erased anyway.

If it works for you too and if there are no objections in the next two
days or so, I will install it.

===File ~/comint-b-diff=====================================
*** comint.el	26 May 2005 09:05:21 -0500	1.319
--- comint.el	07 Jun 2005 17:57:09 -0500	
***************
*** 1547,1554 ****
  		     nil comint-last-input-start comint-last-input-end
  		     nil comint-last-input-end
  		     (+ comint-last-input-end echo-len))))
! 		  (delete-region comint-last-input-end
! 				 (+ comint-last-input-end echo-len)))))
  
  	  ;; This used to call comint-output-filter-functions,
  	  ;; but that scrolled the buffer in undesirable ways.
--- 1547,1555 ----
  		     nil comint-last-input-start comint-last-input-end
  		     nil comint-last-input-end
  		     (+ comint-last-input-end echo-len))))
! 		  (let ((inhibit-read-only t))
! 		    (delete-region comint-last-input-end
! 				   (+ comint-last-input-end echo-len))))))
  
  	  ;; This used to call comint-output-filter-functions,
  	  ;; but that scrolled the buffer in undesirable ways.
============================================================

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

* Re: Comint read-only-prompt
  2005-06-07 23:53         ` Luc Teirlinck
@ 2005-06-08  1:29           ` JD Smith
  2005-06-08 16:06           ` Stefan Monnier
  1 sibling, 0 replies; 9+ messages in thread
From: JD Smith @ 2005-06-08  1:29 UTC (permalink / raw)
  Cc: emacs-devel

On Tue, 2005-06-07 at 18:53 -0500, Luc Teirlinck wrote:
> The following simple patch seems to fix the problem completely for the
> program I am experimenting with (GAP).  It allows some text to be
> misfontified, but that text gets erased anyway.
> 
> If it works for you too and if there are no objections in the next two
> days or so, I will install it.

This seems to do the trick!

Thanks,

JD

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

* Re: Comint read-only-prompt
  2005-06-07 23:53         ` Luc Teirlinck
  2005-06-08  1:29           ` JD Smith
@ 2005-06-08 16:06           ` Stefan Monnier
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2005-06-08 16:06 UTC (permalink / raw)
  Cc: emacs-devel, jdsmith

> ! 		  (let ((inhibit-read-only t))
> ! 		    (delete-region comint-last-input-end
> ! 				   (+ comint-last-input-end echo-len))))))

Please add a one-line comment explaining why the let-binding was added.


        Stefan

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

end of thread, other threads:[~2005-06-08 16:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-07 16:36 Comint read-only-prompt JD Smith
2005-06-07 17:38 ` Luc Teirlinck
2005-06-07 20:59   ` JD Smith
2005-06-07 21:28     ` Luc Teirlinck
2005-06-07 22:10       ` JD Smith
2005-06-07 22:25         ` Luc Teirlinck
2005-06-07 23:53         ` Luc Teirlinck
2005-06-08  1:29           ` JD Smith
2005-06-08 16:06           ` Stefan Monnier

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).