From: Juanma Barranquero <lekktu@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 37641@debbugs.gnu.org
Subject: bug#37641: major/minor tick faces bleed into empty lines at the end of buffer
Date: Tue, 8 Oct 2019 04:38:18 +0200 [thread overview]
Message-ID: <CAAeL0SRFM5s+3tVxH_ZKe3rUM2s+HoCMPgRJYN+qnye8urD1kw@mail.gmail.com> (raw)
In-Reply-To: <83zhiczg1m.fsf@gnu.org>
[-- Attachment #1.1: Type: text/plain, Size: 2975 bytes --]
On Mon, Oct 7, 2019 at 6:17 PM Eli Zaretskii <eliz@gnu.org> wrote:
> Looks good, but please simplify by having 2-level if, the outer one
> checking when to display a number, the inner which face to use for
> that. There's no need to test beyond_zv more than once, and AFAIR
> beyond_zv and it->what == IT_EOB are equivalent.
beyond_zv and it->what == IT_EOB are similar, but not equivalent. I see the
difference when deleting empty lines at the end of the buffer
(specifically, when deleting from the last line, and not past the last
line).
With the `what' check, the face still bleed info the first post-EOB line.
Checking beyond_zv it works (see attached images).
As for simplifying the check, it is possible to check beyond_zv only once,
with the minor downside of having two paths to set lnum_face (which works
as the default face, and the face post-EOB).
if (check for current line) // checks also it->what != IT_EOB
set face to current_lnum_face;
else if (beyond_zv)
set face to lnum_face; // 1
else if (check for major tick)
set face to major_tick;
else if (check for minor tick)
set face to minor_tick;
else
set face to lnum_face; // 2
BTW, if the "it->what != IT_EOB" comparison in the current line check can
indeed be changed to !beyond_zv (which seems to work, at least on my
tests), then you can go to
if (beyond_zv)
set face to lnum_face; // 1
else if (check for current line) // does not check it->what != IT_EOB
set face to current_lnum_face;
else if (check for major tick)
set face to major_tick;
else if (check for minor tick)
set face to minor_tick;
else
set face to lnum_face; // 2
which is equally clean and saves another comparison.
And the nicest thing is that the patch is very clean (attached also because
Gmail as usual is screwing with it).
diff --git a/src/xdisp.c b/src/xdisp.c
index 29d49d57df..ad73981c1d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22662,13 +22662,14 @@ maybe_produce_line_number (struct it *it)
{
/* For continuation lines and lines after ZV, instead of a line
number, produce a blank prefix of the same width. */
- if (lnum_face_id != current_lnum_face_id
- && (EQ (Vdisplay_line_numbers, Qvisual)
- ? this_line == 0
- : this_line == it->pt_lnum)
- /* Avoid displaying the line-number-current-line face on
- empty lines beyond EOB. */
- && it->what != IT_EOB)
+ if (beyond_zv)
+ /* Avoid displaying any face other than line-number on
+ empty lines beyond EOB. */
+ tem_it.face_id = lnum_face_id;
+ else if (lnum_face_id != current_lnum_face_id
+ && (EQ (Vdisplay_line_numbers, Qvisual)
+ ? this_line == 0
+ : this_line == it->pt_lnum))
tem_it.face_id = current_lnum_face_id;
else if (display_line_numbers_major_tick > 0
&& (lnum_to_display % display_line_numbers_major_tick == 0))
[-- Attachment #1.2: Type: text/html, Size: 3644 bytes --]
[-- Attachment #2: it_eob.png --]
[-- Type: image/png, Size: 4796 bytes --]
[-- Attachment #3: beyond_zv.png --]
[-- Type: image/png, Size: 5327 bytes --]
[-- Attachment #4: beyond.patch --]
[-- Type: application/octet-stream, Size: 1058 bytes --]
diff --git a/src/xdisp.c b/src/xdisp.c
index 29d49d57df..ad73981c1d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22662,13 +22662,14 @@ maybe_produce_line_number (struct it *it)
{
/* For continuation lines and lines after ZV, instead of a line
number, produce a blank prefix of the same width. */
- if (lnum_face_id != current_lnum_face_id
- && (EQ (Vdisplay_line_numbers, Qvisual)
- ? this_line == 0
- : this_line == it->pt_lnum)
- /* Avoid displaying the line-number-current-line face on
- empty lines beyond EOB. */
- && it->what != IT_EOB)
+ if (beyond_zv)
+ /* Avoid displaying any face other than line-number on
+ empty lines beyond EOB. */
+ tem_it.face_id = lnum_face_id;
+ else if (lnum_face_id != current_lnum_face_id
+ && (EQ (Vdisplay_line_numbers, Qvisual)
+ ? this_line == 0
+ : this_line == it->pt_lnum))
tem_it.face_id = current_lnum_face_id;
else if (display_line_numbers_major_tick > 0
&& (lnum_to_display % display_line_numbers_major_tick == 0))
next prev parent reply other threads:[~2019-10-08 2:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-07 1:04 bug#37641: major/minor tick faces bleed into empty lines at the end of buffer Juanma Barranquero
2019-10-07 3:42 ` Juanma Barranquero
2019-10-07 16:17 ` Eli Zaretskii
2019-10-08 2:38 ` Juanma Barranquero [this message]
2019-10-08 4:23 ` Juanma Barranquero
2019-10-08 8:51 ` Eli Zaretskii
2019-10-08 8:49 ` Eli Zaretskii
2019-10-08 9:37 ` Juanma Barranquero
2019-10-08 10:47 ` Juanma Barranquero
2019-10-09 10:22 ` Eli Zaretskii
2019-10-09 10:39 ` Juanma Barranquero
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=CAAeL0SRFM5s+3tVxH_ZKe3rUM2s+HoCMPgRJYN+qnye8urD1kw@mail.gmail.com \
--to=lekktu@gmail.com \
--cc=37641@debbugs.gnu.org \
--cc=eliz@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.