From: Young Arto <jifengsi@hotmail.com>
To: 68441@debbugs.gnu.org
Subject: bug#68441: Fix the unaligned tab in whitespace mode
Date: Sat, 13 Jan 2024 12:23:27 +0000 [thread overview]
Message-ID: <MEYP282MB1766A6DE70025049E53992A5906E2@MEYP282MB1766.AUSP282.PROD.OUTLOOK.COM> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 110 bytes --]
As described in the commit message, this patch is meant to fix the unaligned tab when tab-mark is turned on.
[-- Attachment #1.2: Type: text/html, Size: 464 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-the-unaligned-tab-with-tab-mark-of-whitespace-mo.patch --]
[-- Type: text/x-patch; name="0001-Fix-the-unaligned-tab-with-tab-mark-of-whitespace-mo.patch", Size: 2416 bytes --]
From 595ff1877c750b35077298f00ad1a9a494927ab1 Mon Sep 17 00:00:00 2001
From: Arto Young <arto.young@outlook.com>
Date: Sat, 13 Jan 2024 19:52:44 +0800
Subject: [PATCH] Fix the unaligned tab with tab-mark of whitespace mode
There is a bug in whitespace mode which used the display table to
replace a tab with a tab-mark vector.
If we has a line like this:
------
123\t5678
------
If tab-width is 4 and tab-mark is [?> ?\t],
The line will be displayed as following:
(we use '^' to represent tab extra spaces)
------
123>^^^^5678
------
However, it should be displayed as:
------
123>5678
------
If the line was:
------
12\t5678
------
It would be displayed as:
------
12>^5678
------
It happens on the boundary of tab, so we should adjust the 'next_tab_x'
in this case.
* src/term.c (produce_glyphs): Correct the next_tab_x
* src/xdisp.c (gui_produce_glyphs): Correct the next_tab_x
---
src/term.c | 7 +++++++
src/xdisp.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/src/term.c b/src/term.c
index d3c858c6bf2..e34b2ed99de 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1642,6 +1642,13 @@ produce_glyphs (struct it *it)
* it->tab_width);
if (!NILP (Vdisplay_line_numbers) && it->line_number_produced_p)
next_tab_x += it->lnum_pixel_width;
+
+ /* For tab-mark display vector like [?> ?\t] for an
+ original char '\t', we should not display ">\t"
+ but only '>' at tab-width boundry, or tab real length
+ will be tab-width+1, so we decrease tab-width here. */
+ if (it->c == '\t' && it->dpvec && it->current.dpvec_index > 0 && absolute_x % it->tab_width == 0)
+ next_tab_x -= it->tab_width;
int nspaces;
/* If part of the TAB has been displayed on the previous line
diff --git a/src/xdisp.c b/src/xdisp.c
index 14cf030ca4e..13fb6e5a308 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -32621,6 +32621,13 @@ gui_produce_glyphs (struct it *it)
next_tab_x -= it->stretch_adjust;
}
+ /* For tab-mark display vector like [?> ?\t] for an
+ original char '\t', we should not display ">\t"
+ but only '>' at tab-width boundry, or tab real length
+ will be tab-width+1, so we decrease tab-width here. */
+ if (it->c == '\t' && it->dpvec && it->current.dpvec_index > 0 && x % tab_width == 0)
+ next_tab_x -= tab_width;
+
it->pixel_width = next_tab_x - x0;
it->nglyphs = 1;
if (FONT_TOO_HIGH (font))
--
2.43.0
next reply other threads:[~2024-01-13 12:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-13 12:23 Young Arto [this message]
2024-01-14 10:14 ` bug#68441: Fix the unaligned tab in whitespace mode Eli Zaretskii
2024-01-28 10:43 ` bug#68441: 回复: " Young Arto
2024-01-28 11:09 ` 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=MEYP282MB1766A6DE70025049E53992A5906E2@MEYP282MB1766.AUSP282.PROD.OUTLOOK.COM \
--to=jifengsi@hotmail.com \
--cc=68441@debbugs.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.