Subject: bug#18548: Emacs whitespace mode

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 23 Feb 2022 14:18:46 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> So switching on whitespace-mode messes up the display if there's only
> room for a single character in the TAB?  This seems like such a general
> problem that it's odd that this hasn't been fixed yet.  But I think I
> remember somebody doing work in this area...  does anybody else
> remember?

Ah, right -- I was probably misremembering, and I was just thinking of
this:

    ;; WARNING: the mapping below has a problem.
    ;; When a TAB occupies exactly one column, it will display the
    ;; character ?\xBB at that column followed by a TAB which goes to
    ;; the next TAB column.
    ;; If this is a problem for you, please, comment the line below.
    (tab-mark     ?\t    [?» ?\t] [?\\ ?\t])	; tab - right guillemet

This is used to set up a display table that maps tabs into [?» ?\t]:

	    (aset buffer-display-table (cadr entry) vec)))))))

And that does indeed lead to the messed up display described in this bug
report.

And the reason that this is rarely a problem in practice is that
normally you only have TAB characters at the start of a line (in the
modes where you typically use whitespace-mode), I think?

So I don't know whether anything can or should be done in this case.  I
think that (perhaps) a reasonable default would be to remove that
mapping -- whitespace-mode (by default) marks TAB characters anyway with
a face, so having a » in addition is somewhat superfluous.  On the other
hand, it's been like this forever, so perhaps we should just document
the quirk instead.  Or add a defcustom to allow for easier toggling, and
the defcustom would then also act as documentation for this.

Any opinions?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no