From: Eli Zaretskii <eliz@gnu.org>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: 'struct window' cleanup #4
Date: Mon, 02 Jul 2012 20:33:49 +0300 [thread overview]
Message-ID: <83ehou5apu.fsf@gnu.org> (raw)
In-Reply-To: <4FF17BAE.7090200@yandex.ru>
> Date: Mon, 02 Jul 2012 14:45:02 +0400
> From: Dmitry Antipov <dmantipov@yandex.ru>
>
> --- src/dispnew.c 2012-06-28 07:50:50 +0000
> +++ src/dispnew.c 2012-07-02 10:11:48 +0000
> @@ -643,9 +643,8 @@
>
> /* Window end is invalid, if inside of the rows that
> are invalidated below. */
> - if (INTEGERP (w->window_end_vpos)
> - && XFASTINT (w->window_end_vpos) >= i)
> - w->window_end_valid = Qnil;
> + if (w->window_end_vpos >= i)
> + w->window_end_valid = 0;
Shouldn't we test w->window_end_valid for being non-zero, before we
trust the value of w->window_end_vpos? Zero for a vertical position
is perfectly valid, so if i is zero, you can err here. The comment
says:
/* Glyph matrix row of the last glyph in the current matrix of W.
Should be nonnegative, and valid only if window_end_valid is not zero. */
ptrdiff_t window_end_vpos;
So I think we should put our money where our mouth is, and do as we
say ;-)
> @@ -2989,10 +2989,10 @@
> XSETINT (BVAR (b, display_count), XINT (BVAR (b, display_count)) + 1);
> BVAR (b, display_time) = Fcurrent_time ();
>
> - XSETFASTINT (w->window_end_pos, 0);
> - XSETFASTINT (w->window_end_vpos, 0);
> + w->window_end_pos = 0;
> + w->window_end_vpos = 0;
> memset (&w->last_cursor, 0, sizeof w->last_cursor);
> - w->window_end_valid = Qnil;
> + w->window_end_valid = 0;
> if (!(keep_margins_p && samebuf))
> { /* If we're not actually changing the buffer, don't reset hscroll and
> vscroll. This case happens for example when called from
> @@ -3287,8 +3287,6 @@
> w->start = Fmake_marker ();
> w->pointm = Fmake_marker ();
> w->vertical_scroll_bar_type = Qt;
> - XSETFASTINT (w->window_end_pos, 0);
> - XSETFASTINT (w->window_end_vpos, 0);
>
> /* Initialize non-Lisp data. Note that allocate_window zeroes out all
> non-Lisp data, so do it only for slots which should not be zero. */
> @@ -3296,6 +3294,8 @@
> w->phys_cursor_type = -1;
> w->phys_cursor_width = -1;
> w->sequence_number = ++sequence_number;
> + w->window_end_pos = -1;
> + w->window_end_vpos = -1;
If the "invalid" value is going to be -1, then why did you initialize
with zero above?
> + /* Z - the buffer position of the last glyph in the current matrix of W.
> + Should be nonnegative, and valid only if window_end_valid is not zero. */
> + ptrdiff_t window_end_pos;
But since you initialize with -1, the "nonnegative" part is only true
when window_end_valid is non-zero, right?
> + /* Glyph matrix row of the last glyph in the current matrix of W.
> + Should be nonnegative, and valid only if window_end_valid is not zero. */
> + ptrdiff_t window_end_vpos;
Same here.
> @@ -27410,7 +27419,7 @@
> And verify the buffer's text has not changed. */
> b = XBUFFER (w->buffer);
> if (part == ON_TEXT
> - && EQ (w->window_end_valid, w->buffer)
> + && w->window_end_valid
Bother: doesn't the comparison with w->buffer test for a specific
buffer, rather than just non-nil value? The corresponding assignment,
viz.:
> if (accurate_p)
> {
> - w->window_end_valid = w->buffer;
> + w->window_end_valid = 1;
> w->update_mode_line = 0;
> }
seems to handle the case when the display is "accurate". Perhaps use
a different value, like 2, for this situation?
Other than that, looks okay, thanks.
next prev parent reply other threads:[~2012-07-02 17:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-02 10:45 'struct window' cleanup #4 Dmitry Antipov
2012-07-02 14:48 ` Stefan Monnier
2012-07-02 17:07 ` Eli Zaretskii
2012-07-02 17:33 ` Eli Zaretskii [this message]
2012-07-03 5:54 ` 'struct window' cleanup #5 [Re: 'struct window' cleanup #4] Dmitry Antipov
2012-07-03 15:58 ` Eli Zaretskii
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=83ehou5apu.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=dmantipov@yandex.ru \
--cc=emacs-devel@gnu.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.
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.