unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Ian Zimmerman <itz@speakeasy.org>
Subject: Re: strange behavior with multi-buffer Lisp code
Date: 18 Nov 2002 10:31:15 -0800	[thread overview]
Message-ID: <86k7jaenm4.fsf@kronstadt.homeunix.net> (raw)
In-Reply-To: 5lheeezwcb.fsf@rum.cs.yale.edu


itz> This command is intended to be executed when the language buffer
itz> is in the selected window.  simple-ml-eval-marker is set earlier
itz> by the code that sends the chunk over to the interpreter.  What
itz> happens is that this _always jumps to the same error_, because
itz> even after the point is moved by the re-search-forward in the
itz> comint buffer, it is restored for some unfathomable (to me - not
itz> to you, I hope) reason when the command returns.

Stefan> The notion of `point' is not unique for a buffer.  Each buffer
Stefan> can have several `point's, one per window.  What happens is
Stefan> that whenever you leave and re-enter the *Simple ML* buffer,
Stefan> the point is re-initialized from the point corresponding to
Stefan> the cursor in the window where *Simple ML* is displayed (or
Stefan> something like that: it's not completely clear how and when
Stefan> those things happen).

Well, I guess that was my question: how and when _do_ these things
happen? :-)  Is there anyone here who knows?  Certainly reading the
Emacs Lisp manual, the section about "excursions", gave me reason to
believe what I did should have worked.  It says the save-excursion
form exists, among other things, to preserve the value of point in the
current buffer -- implying that it is _not_ preserved unless
save-excursion is in effect.

Stefan> I.e. you'll want to explicitly maintain a marker indicating
Stefan> up-to-where you've processed the output.

Stefan> Now as to what you're doing I'd recommend you simply use the
Stefan> mechanism used for `next-error': put the *Simple ML* buffer in
Stefan> some kind of compilation-minor-mode and set the
Stefan> compilation-error-regexp-alist and friends.  Then C-x ` will
Stefan> magically work.

Stefan> Check sml-mode to see how I've done it.

Several objections:

1/ There's no "up-to-where".  I don't want to process all the errors
in linear fashion like next-error does.  The docstring in my posted
chunk of code explains the functionality I desire.

2/ I _want_ the point to change in the comint buffer, as part of the
user feedback.  The error message not only identifies the location but
also contains explanatory text about the error.  The user should
immediately see that text if she switches to the comint window.

3/ I don't want to subsume this command under next-error, both because
it works differently and because normal make-driven compilation _also_
makes sense with this tool.  If I were to do that users would have to
laboriously juggle the normal compilation buffer and the interpreter
comint buffer to switch between the two ways of working.


The more general question, abstracted from my particular situation:

How does one programatically, peristently, and reliably (independently
of variables such as window configuration) change the value of point
in a non-current buffer?

-- 
Ian Zimmerman, Oakland, California, U.S.A. I did not vote for Emperor Bush.
GPG: 433BA087  9C0F 194F 203A 63F7 B1B8  6E5A 8CA3 27DB 433B A087

  reply	other threads:[~2002-11-18 18:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-18  2:40 strange behavior with multi-buffer Lisp code Ian Zimmerman
2002-11-18 16:17 ` Stefan Monnier <foo@acm.com>
2002-11-18 18:31   ` Ian Zimmerman [this message]
2002-11-18 22:36     ` Stefan Monnier <foo@acm.com>
2002-11-19  0:38       ` Ian Zimmerman
2002-11-19  6:04         ` Ian Zimmerman

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=86k7jaenm4.fsf@kronstadt.homeunix.net \
    --to=itz@speakeasy.org \
    /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.
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).