From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: emacs-pretest-bug@gnu.org, 4851@emacsbugs.donarmstrong.com
Subject: bug#4851: 23.1.50; narrowing, indirect buffers and set-buffer
Date: Tue, 03 Nov 2009 16:34:20 -0500 [thread overview]
Message-ID: <jwv7hu747lo.fsf-monnier+emacsbugreports@gnu.org> (raw)
In-Reply-To: <87hbtd0yny.fsf@escher.local.home> (Stephen Berman's message of "Mon, 02 Nov 2009 15:49:37 +0100")
> 1. emacs -Q
> 2. C-x b bla RET
> 3. M-: (insert "This is a test.")
> 4. M-: (narrow-to-region 5 10)
> => buffer "bla" now displays " is a"
> 5. M-: (make-indirect-buffer (current-buffer) "blip")
> 6. M-: (save-restriction
> (widen)
> (set-buffer (get-buffer-create "bloop")))
> => buffer "bla" now displays "This is a test."
Thanks! I finally tracked this bug down. Sadly, I think this points out
a more general problem, so while the patch below fixes it, we probably
have several other related bugs.
Stefan
--- src/editfns.c 19 Oct 2009 04:27:14 -0000 1.473
+++ src/editfns.c 3 Nov 2009 21:32:41 -0000
@@ -3275,12 +3275,26 @@
save_restriction_restore (data)
Lisp_Object data;
{
+ struct buffer *cur = NULL;
+ struct buffer *buf = (CONSP (data)
+ ? XMARKER (XCAR (data))->buffer
+ : XBUFFER (data));
+
+ if (buf && buf != current_buffer && !NILP (buf->pt_marker))
+ { /* If `buf' uses markers to keep track of PT, BEGV, and ZV (as
+ is the case if it is or has an indirect buffer), then make
+ sure it is current before we update BEGV, so
+ set_buffer_internal takes care of managing those markers. */
+ cur = current_buffer;
+ set_buffer_internal (buf);
+ }
+
if (CONSP (data))
/* A pair of marks bounding a saved restriction. */
{
struct Lisp_Marker *beg = XMARKER (XCAR (data));
struct Lisp_Marker *end = XMARKER (XCDR (data));
- struct buffer *buf = beg->buffer; /* END should have the same buffer. */
+ eassert (buf == end->buffer);
if (buf /* Verify marker still points to a buffer. */
&& (beg->charpos != BUF_BEGV (buf) || end->charpos != BUF_ZV (buf)))
@@ -3305,8 +3319,6 @@
else
/* A buffer, which means that there was no old restriction. */
{
- struct buffer *buf = XBUFFER (data);
-
if (buf /* Verify marker still points to a buffer. */
&& (BUF_BEGV (buf) != BUF_BEG (buf) || BUF_ZV (buf) != BUF_Z (buf)))
/* The buffer has been narrowed, get rid of the narrowing. */
@@ -3318,6 +3330,9 @@
}
}
+ if (cur)
+ set_buffer_internal (cur);
+
return Qnil;
}
prev parent reply other threads:[~2009-11-03 21:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-02 14:49 bug#4851: 23.1.50; narrowing, indirect buffers and set-buffer Stephen Berman
2009-11-03 21:34 ` Stefan Monnier [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv7hu747lo.fsf-monnier+emacsbugreports@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=4851@emacsbugs.donarmstrong.com \
--cc=emacs-pretest-bug@gnu.org \
--cc=stephen.berman@gmx.net \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.