all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Eli Zaretskii <eliz@gnu.org>
Cc: ahyatt@gmail.com, 5718@debbugs.gnu.org, gavenkoa@gmail.com
Subject: bug#5718: scroll-margin in buffer with small line count.
Date: Sun, 22 Jan 2017 12:21:20 -0500	[thread overview]
Message-ID: <87inp7ui27.fsf@users.sourceforge.net> (raw)
In-Reply-To: <83d1fg5iku.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 21 Jan 2017 21:17:05 +0200")

npostavs@users.sourceforge.net writes:
>
> I came up with this; it works

Actually, that doesn't work, I must have not compiled before testing.

Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> I'm not entirely clear why there is a branch in that code.
>
> Because of line-spacing, perhaps?  Did you test your code when
> line-spacing is at non-default value?  In general, it is safer to go
> to the next screen line than reason about where it will start.
>
>> +int
>> +partial_line_height (const struct it *it_origin)
>> +{
>> +  struct it it = *it_origin;
>
> When you copy the iterator structure and modify the copy, you need to
> save and restore the bidi cache, using SAVE_IT and RESTORE_IT macros.
> Otherwise, the code which calls this function will work incorrectly if
> it uses the original iterator after the call, because the bidi cache
> is not restored to its state before the call.

I came up with this modified version of partial_line_height, which does
actually work.  Having to do RESTORE_IT (&it, &it, it_data) is a bit
unintuitive though.  I don't understand what the typical use case of
this macro is, if it's going to copy back the new state into the
original `it', then why use a separate `it' in the first place?

By the way, while testing I noticed that `set-window-text-height'
doesn't take `line-spacing' into account, should it?


int
partial_line_height (struct it *it_origin)
{
  int partial_height;
  void *it_data = NULL;
  struct it it;
  SAVE_IT (it, *it_origin, it_data);
  move_it_to (&it, ZV, -1, it.last_visible_y, -1,
              MOVE_TO_POS | MOVE_TO_Y);
  if (it.what == IT_EOB)
    {
      int vis_height = it.last_visible_y - it.current_y;
      int height = it.ascent + it.descent;
      partial_height = (vis_height < height) ? vis_height : 0;
    }
  else
    {
      int last_line_y = it.current_y;
      move_it_by_lines (&it, 1);
      partial_height = (it.current_y > it.last_visible_y)
        ? it.last_visible_y - last_line_y : 0;
    }
  RESTORE_IT (&it, &it, it_data);
  return partial_height;
}





  reply	other threads:[~2017-01-22 17:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-14 17:26 bug#5718: scroll-margin in buffer with small line count Oleksandr Gavenko
2016-08-11  4:11 ` Andrew Hyatt
2016-08-11 12:03   ` npostavs
2016-08-11 13:05     ` Oleksandr Gavenko
2016-08-11 13:24       ` Noam Postavsky
2016-08-12  7:54         ` Oleksandr Gavenko
2016-08-11 15:28     ` Eli Zaretskii
2016-08-13 22:01       ` npostavs
2016-08-14  2:36         ` Eli Zaretskii
2016-09-11 20:58           ` npostavs
2016-09-12  6:19             ` martin rudalics
2016-09-14  2:23               ` npostavs
2016-09-14  5:30                 ` martin rudalics
2016-09-12 17:36             ` Eli Zaretskii
2016-09-14  2:40               ` npostavs
2016-09-14 17:26                 ` Eli Zaretskii
2017-01-03  0:48                   ` npostavs
2017-01-07  8:17                     ` Eli Zaretskii
2017-01-14  4:18                       ` npostavs
2017-01-14  7:58                         ` Eli Zaretskii
2017-01-15 21:43                           ` npostavs
2017-01-16 17:08                             ` Eli Zaretskii
2017-01-21 18:46                               ` npostavs
2017-01-21 19:17                                 ` Eli Zaretskii
2017-01-22 17:21                                   ` npostavs [this message]
2017-01-22 17:58                                     ` Eli Zaretskii
2017-01-29  0:57                                       ` npostavs
2017-01-30 15:29                                         ` Eli Zaretskii
2017-01-31  4:52                                           ` npostavs
2017-01-31 15:33                                             ` Eli Zaretskii
2017-02-03  2:40                                               ` npostavs

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=87inp7ui27.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=5718@debbugs.gnu.org \
    --cc=ahyatt@gmail.com \
    --cc=eliz@gnu.org \
    --cc=gavenkoa@gmail.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 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.