unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: David Kastrup <David.Kastrup@t-online.de>
Subject: Re: save-excursion doesn't always work
Date: 15 Dec 2002 11:37:28 +0100	[thread overview]
Message-ID: <x5adj7in4n.fsf@lola.goethe.zz> (raw)
In-Reply-To: 1a52e3d.0212142138.2f5aed8@posting.google.com

ittay@qlusters.com (Ittay Freiman) writes:

> i found this behavior while using auctex. to recreate, create a new
> buffer for a tex document, with auctex as the mode
> (LaTeX-mode). type in the first line 'this is a test'.
> 
> go down one line. '(point)' should return 16. now evaluate
> '(save-excursion (LaTeX-fill-region-as-paragraph 1 16 t))'. nothing
> actually changes in the buffer,

Wrong.  A lot changes in the buffer.  Place some text property on the
space in question: it will be gone afterwards.  AUCTeX in the process
of filling deletes sequences of spaces completely, then reinserts a
single one.  Whether you were before or in or after such a deleted
space before the operation. you'll end up on the same side of the
reinserted space afterwards.

> but the cursor jumps to point 15. you can repeat this with the same
> results.
> 
> can someone please tell me what is going on? also, if i write a
> function that uses LaTeX-fill-region-as-paragraph, how can i return
> the cursor to its original place (i'm currently using markers,
> however, putting the cursor inside the filled region creates weird
> behaviors)

You can't, for the above reason.  AUCTeX's filling modes would have to
be rewritten so that instead of deleting all spaces and reinserting
one space, AUCTeX would delete all spaces except one.

I think Emacs' default filling by now does something like that.  If
you volunteer in trying to port the relevant portions, I will check
them into the AUCTeX code base: the current behavior is a nuisance
for other reasons as well.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  reply	other threads:[~2002-12-15 10:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-15  5:38 save-excursion doesn't always work Ittay Freiman
2002-12-15 10:37 ` David Kastrup [this message]
2002-12-16 16:02   ` Stefan Monnier <foo@acm.com>
2002-12-16 16:21     ` David Kastrup
2002-12-16 17:00       ` Stefan Monnier <foo@acm.com>
2002-12-16 17:43         ` David Kastrup
2002-12-16 18:28           ` Stefan Monnier <foo@acm.com>
2002-12-16 18:46             ` David Kastrup

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=x5adj7in4n.fsf@lola.goethe.zz \
    --to=david.kastrup@t-online.de \
    /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).