unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: JD Smith <jdsmith@as.arizona.edu>
Cc: rms@gnu.org, monnier+gnu/emacs@rum.cs.yale.edu,
	miles@lsi.nec.co.jp, simon.marshall@misys.com,
	emacs-devel@gnu.org
Subject: Re: comint read-only prompt
Date: 20 Aug 2002 18:24:33 -0700	[thread overview]
Message-ID: <1029893073.20783.290.camel@turtle.as.arizona.edu> (raw)
In-Reply-To: <20020821001812.GA23832@gnu.org>

On Tue, 2002-08-20 at 17:18, Miles Bader wrote:
> On Tue, Aug 20, 2002 at 03:01:32PM -0700, JD Smith wrote:
> > Sorry, poor choice of words.  I did notice that snapshot-last-prompt, in
> > the CVS version, now adds text properties as opposed to "freeing" the
> > overlay, and that it gets called not just when a new prompt is created,
> > but *many* times, e.g. every time a command is sent (which occurs in the
> > background all the time in IDLWAVE).
> 
> I'm confused by what you mean -- that's when snapshot-last-prompt has
> _always_ been called, when input is sent (and it's not called at all when `a
> new prompt is created').  It should be called exactly the same number of
> times now as it was before.

Sorry if I wasn't clear.  This is certainly true.  In the past, however,
snapshot was emptying out an overlay variable and then a new overlay was
being created in the filter.  Now it assigns text properties over the
top of the overlay, in anticipation of the overlay getting moved.

> > So, in the present scheme, the current prompt has either
> > overlay-properties, or redundant overlay+text-properties.  All old prompts
> > have just text-properties.  In this context, I can't see how overlays are
> > uniquely needed, since they aren't predictably present by themselves...
> 
> That simply isn't true; the _majority_ of the time, in a normal shell
> session, the overlay alone is responsible for the last prompt (there may be a
> brief instant after you've send a command, and before the process has sent
> any output, when they may overlap, but that's harmless).  As the process
> sends output after a command, the overlay is moved so that it covers anything
> that `looks like a prompt', which may happen many times.  [and
> snapshot-last-prompt is never called _at all_]
> 

I just realized the source of the confusion; I forgot to mention that
IDLWAVE uses comint in a potentially unusual mode: 

	(set-process-filter process 'idlwave-shell-filter)

In idlwave-shell-filter, output can be *hidden* (i.e. sent to a hidden
buffer, in which case the prompt overlay stays put), otherwise it is
just passed on to comint-output-filter and shows up in the shell buffer
like normal.  However, every time you send a command, whether hidden or
not, the prompt is snapshotted.  The problem is in assuming every
send-input will automatically be followed by a call to the
output-filter.  I'm not familiar with how other modes use comint, but
I'd bet setting your own process-filter (e.g. to send hidden commands)
is not too uncommon.

In any case, the CVS comint's method don't really hurt IDLWAVE: it's
just that you often have both overlay and text properties  on the same
piece of text at the same time (thanks to the zealous snapshotting). 
If, however, read-only properties were added and removed relying on the
"one send-input, one output-filter" assumption, then that could cause
problems.

A proposed solution: if snapshot were moved to the beginning of the
output-filter, these problems would disappear.  Something roughly like:

(defun comint-output-filter (process string)
  ...
  (comint-snapshot-last-prompt)
  ;;fiddle with overlays to ensure the right placement
  ...
  ;; move the overlay
  (move-overlay comint-last-prompt-overlay ...) 
  ...
  ;; or maybe make a new one
  (setq comint-last-prompt-overlay
	(make-overlay prompt-start (point)))
  (overlay-put comint-last-prompt-overlay
	       'font-lock-face 'comint-highlight-prompt)
  ...
  ;; add the read-only text properties
  (add-text-properties (overlay-start comint-last-prompt-overlay)
		       (overlay-end comint-last-prompt-overlay)
		       '(read-only t rear-nonsticky t))

(defun comint-snapshot-last-prompt ()
  (when comint-last-prompt-overlay
    (let ((inhibit-read-only t))
      (add-text-properties (overlay-start comint-last-prompt-overlay)
                           (overlay-end comint-last-prompt-overlay)
                           (nconc
			    (overlay-properties comint-last-prompt-overlay)
			    '(read-only nil))))))


That way, the read-only properties are removed and other text properties
(highlight, etc.) are applied to the soon-to-be-old prompt only just
before text (containing a new prompt, presumably) arrives.  Probably I'm
missing something simple, but it seems to me that would do it.

Thanks,

JD

-- 
 J.D. Smith            <=> 
 Steward Observatory   <=> 520-621-9532 <W>
 University of Arizona <=> 520-621-1532 <F>
 Tucson, Arizona 85721 <=> 

  reply	other threads:[~2002-08-21  1:24 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-19  8:24 comint read-only prompt Marshall, Simon
2002-08-19 10:59 ` Miles Bader
2002-08-19 15:40   ` Stefan Monnier
2002-08-19 15:57     ` JD Smith
2002-08-19 23:45       ` Miles Bader
2002-08-20 16:14         ` Stefan Monnier
2002-08-21  0:12           ` Richard Stallman
2002-08-21 15:06             ` Stefan Monnier
2002-08-21  0:11         ` Richard Stallman
2002-08-20 17:21       ` Richard Stallman
2002-08-20 18:03         ` JD Smith
2002-08-20 21:17           ` Miles Bader
2002-08-20 22:01             ` JD Smith
2002-08-21  0:18               ` Miles Bader
2002-08-21  1:24                 ` JD Smith [this message]
2002-08-21  1:36                   ` Miles Bader
2002-08-21 15:28                     ` Stefan Monnier
2002-08-20 18:36         ` Luc Teirlinck
2002-08-20 21:12         ` Miles Bader
2002-08-20 23:23           ` Kim F. Storm
2002-08-21 11:05         ` Kai Großjohann
2002-08-22  1:57           ` Richard Stallman
2002-08-22  2:21             ` JD Smith
2002-08-22  2:35             ` Miles Bader
2002-08-24  2:33               ` Richard Stallman
2002-08-19 23:41     ` Miles Bader
2002-08-19 20:46 ` Richard Stallman
2002-08-21  0:23   ` Noah Friedman
2002-08-21  0:23   ` Noah Friedman
2002-08-21  1:21     ` Miles Bader
2002-08-21  1:38       ` Miles Bader
2002-08-21  1:32     ` JD Smith
2002-08-21 15:23       ` Stefan Monnier
2002-08-22  1:21         ` Miles Bader
2002-08-22  7:57         ` Eli Zaretskii
2002-08-24  2:32           ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1029893073.20783.290.camel@turtle.as.arizona.edu \
    --to=jdsmith@as.arizona.edu \
    --cc=emacs-devel@gnu.org \
    --cc=miles@lsi.nec.co.jp \
    --cc=monnier+gnu/emacs@rum.cs.yale.edu \
    --cc=rms@gnu.org \
    --cc=simon.marshall@misys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).