GNU bug report logs - #18548
Emacs whitespace mode

Previous Next

Package: emacs;

Reported by: Kip Coul <kipcoul <at> gmail.com>

Date: Wed, 24 Sep 2014 18:20:02 UTC

Severity: normal

Tags: confirmed

Merged with 18441, 46590

Found in version 27.1.91

To reply to this bug, email your comments to 18548 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Wed, 24 Sep 2014 18:20:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kip Coul <kipcoul <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 24 Sep 2014 18:20:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kip Coul <kipcoul <at> gmail.com>
To: bug-emacs <at> gnu.org
Subject: Emacs whitespace mode
Date: Wed, 24 Sep 2014 14:13:04 +0200
Hi all,

I am a fan of Emacs, and I'd like to bring a minor change but that I
find actually useful.
I'd like to modify the way tabs are displayed in whitespace mode.

Basically what I want to do is the following: display a tab as a
customizable sequence of characters instead of a character followed by
spaces.

So, if a tab takes five spaces, I'd like the user to be able to customize
this, for example to display "<--->" or "---->". You can have a look
here at how they represent tabs, it's very close to what I want to do:
http://www.emacswiki.org/TabsAreEvil#SmartTabs

The user will be able to specify the following characters:
   - char #1, that will be displayed at the beginning
   - char #2, that will be repeated
   - char #3 (optional) that will be put at the end of the tab

So, for a tab to display as "---->", you'd set char #1 = char #2 = '-'
and char #3 = '>', and for a tab to display as "<--->", you'd set char
#1 = '<', char #2 = '-' and char #3 = '>'

So, could you confirm that the file whitespace.el is the one I have to
modify? Could you give me some insight about how to do?

Thanks and regards,
Kip




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Fri, 14 Nov 2014 16:50:01 GMT) Full text and rfc822 format available.

Message #8 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Jack Morrison <JackMorrison1 <at> gmail.com>
To: 18548 <at> debbugs.gnu.org
Subject: bug#18548
Date: Fri, 14 Nov 2014 09:49:09 -0700
[Message part 1 (text/plain, inline)]
Hi Kip,

I think the feature you're looking for can be accomplished quickly by
customizing the `whitespace-display-mappings` customization option in
whitespace.el.

If your tab size is fixed at 4, you can just go ahead and customize it with
`M-x customize-variable whitespace-display-mappings` and change the TAB
character mapping vector to be "---->" or your preferred output. If your
tab size is variable, then perhaps you could add a hook to modify the
"tab-mark" vector list when loading a new file.

Hope that helps.

Cheers,
Jack
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Mon, 30 Sep 2019 02:44:02 GMT) Full text and rfc822 format available.

Message #11 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Jack Morrison <JackMorrison1 <at> gmail.com>, Kip Coul <kipcoul <at> gmail.com>
Cc: 18548 <at> debbugs.gnu.org
Subject: Re: bug#18548: Emacs whitespace mode
Date: Mon, 30 Sep 2019 04:43:33 +0200
Jack Morrison <JackMorrison1 <at> gmail.com> writes:

> Hi Kip,
>
> I think the feature you're looking for can be accomplished quickly by customizing the `whitespace-display-mappings` customization option in whitespace.el.
>
> If your tab size is fixed at 4, you can just go ahead and customize it with `M-x customize-variable whitespace-display-mappings` and change the TAB character mapping vector to be "---->" or your preferred output. If your tab size is variable, then
> perhaps you could add a hook to modify the "tab-mark" vector list when loading a new file.
>
> Hope that helps.
>
> Cheers,
> Jack

Hi Kip,

It seems like the capabilities you were asking for are already there.
Did the above resolve the issue for you?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Thu, 03 Oct 2019 14:36:02 GMT) Full text and rfc822 format available.

Message #14 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Nathaniel Braun <nathaniel.braun <at> gmail.com>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Kip Coul <kipcoul <at> gmail.com>, 18548 <at> debbugs.gnu.org,
 Jack Morrison <JackMorrison1 <at> gmail.com>
Subject: Re: bug#18548: Emacs whitespace mode
Date: Thu, 3 Oct 2019 12:34:15 +0300
Hello,

Thanks for your e-mail. However, no, it does not fix my problem.
Please see https://www.emacswiki.org/emacs/WhiteSpace#toc9

There you can read the following:

            ;; 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   [?\xBB ?\t] [?\\ ?\t]) ; tab

This is exactly my issue! When a tab is one character, I need it to
occupy one character, not one character plus a tab.

Thanks!

On Mon, Sep 30, 2019 at 5:43 AM Stefan Kangas <stefan <at> marxist.se> wrote:
>
> Jack Morrison <JackMorrison1 <at> gmail.com> writes:
>
> > Hi Kip,
> >
> > I think the feature you're looking for can be accomplished quickly by customizing the `whitespace-display-mappings` customization option in whitespace.el.
> >
> > If your tab size is fixed at 4, you can just go ahead and customize it with `M-x customize-variable whitespace-display-mappings` and change the TAB character mapping vector to be "---->" or your preferred output. If your tab size is variable, then
> > perhaps you could add a hook to modify the "tab-mark" vector list when loading a new file.
> >
> > Hope that helps.
> >
> > Cheers,
> > Jack
>
> Hi Kip,
>
> It seems like the capabilities you were asking for are already there.
> Did the above resolve the issue for you?
>
> Best regards,
> Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Wed, 30 Oct 2019 20:44:02 GMT) Full text and rfc822 format available.

Message #17 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Nathaniel Braun <nathaniel.braun <at> gmail.com>
Cc: Kip Coul <kipcoul <at> gmail.com>, Jack Morrison <JackMorrison1 <at> gmail.com>,
 18548 <at> debbugs.gnu.org
Subject: Re: bug#18548: Emacs whitespace mode
Date: Wed, 30 Oct 2019 21:43:02 +0100
Hi Nathaniel,

Nathaniel Braun <nathaniel.braun <at> gmail.com> writes:

> Thanks for your e-mail. However, no, it does not fix my problem.
> Please see https://www.emacswiki.org/emacs/WhiteSpace#toc9
>
> There you can read the following:
>
>             ;; 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   [?\xBB ?\t] [?\\ ?\t]) ; tab
>
> This is exactly my issue! When a tab is one character, I need it to
> occupy one character, not one character plus a tab.

Did any of the workarounds described on the linked page work for you?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Thu, 31 Oct 2019 14:35:04 GMT) Full text and rfc822 format available.

Message #20 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Nathaniel Braun <nathaniel.braun <at> gmail.com>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Kip Coul <kipcoul <at> gmail.com>, Jack Morrison <JackMorrison1 <at> gmail.com>,
 18548 <at> debbugs.gnu.org
Subject: Re: bug#18548: Emacs whitespace mode
Date: Thu, 31 Oct 2019 11:24:37 +0200
Thank you.

The workaround mentioned here simply deletes the tab visualization, it
does not actually fix the issue.

How can I help fix this?

Thank you

On Wed, Oct 30, 2019 at 10:43 PM Stefan Kangas <stefan <at> marxist.se> wrote:
>
> Hi Nathaniel,
>
> Nathaniel Braun <nathaniel.braun <at> gmail.com> writes:
>
> > Thanks for your e-mail. However, no, it does not fix my problem.
> > Please see https://www.emacswiki.org/emacs/WhiteSpace#toc9
> >
> > There you can read the following:
> >
> >             ;; 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   [?\xBB ?\t] [?\\ ?\t]) ; tab
> >
> > This is exactly my issue! When a tab is one character, I need it to
> > occupy one character, not one character plus a tab.
>
> Did any of the workarounds described on the linked page work for you?
>
> Best regards,
> Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Thu, 31 Oct 2019 16:16:02 GMT) Full text and rfc822 format available.

Message #23 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Nathaniel Braun <nathaniel.braun <at> gmail.com>
Cc: Kip Coul <kipcoul <at> gmail.com>, Jack Morrison <JackMorrison1 <at> gmail.com>,
 18548 <at> debbugs.gnu.org
Subject: Re: bug#18548: Emacs whitespace mode
Date: Thu, 31 Oct 2019 17:15:15 +0100
Nathaniel Braun <nathaniel.braun <at> gmail.com> writes:
> How can I help fix this?

If you know Emacs Lisp, you could dig into the code in
lisp/whitespace.el to try to find a fix.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Tue, 25 Jan 2022 14:22:02 GMT) Full text and rfc822 format available.

Message #26 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Nathaniel Braun <nathaniel.braun <at> gmail.com>
Cc: Kip Coul <kipcoul <at> gmail.com>, Stefan Kangas <stefan <at> marxist.se>,
 Jack Morrison <JackMorrison1 <at> gmail.com>, 18548 <at> debbugs.gnu.org
Subject: Re: bug#18548: Emacs whitespace mode
Date: Tue, 25 Jan 2022 15:21:39 +0100
[Message part 1 (text/plain, inline)]
Nathaniel Braun <nathaniel.braun <at> gmail.com> writes:

> This is exactly my issue! When a tab is one character, I need it to
> occupy one character, not one character plus a tab.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

This problem is still present in Emacs 29.  Here's a text mode buffer
with tabs before Foo and Bar:

[Message part 2 (image/png, inline)]
[Message part 3 (text/plain, inline)]
`M-x whitespace-mode':

[Message part 4 (image/png, inline)]
[Message part 5 (text/plain, inline)]
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?

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

Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 25 Jan 2022 14:23:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Wed, 23 Feb 2022 13:20:01 GMT) Full text and rfc822 format available.

Message #31 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Nathaniel Braun <nathaniel.braun <at> gmail.com>
Cc: 18548 <at> debbugs.gnu.org, Kip Coul <kipcoul <at> gmail.com>,
 Stefan Kangas <stefan <at> marxist.se>, Jack Morrison <JackMorrison1 <at> gmail.com>
Subject: Re: bug#18548: Emacs whitespace mode
Date: Wed, 23 Feb 2022 14:18:46 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Wed, 23 Feb 2022 14:00:03 GMT) Full text and rfc822 format available.

Message #34 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: nathaniel.braun <at> gmail.com, 18548 <at> debbugs.gnu.org, kipcoul <at> gmail.com,
 stefan <at> marxist.se, JackMorrison1 <at> gmail.com
Subject: Re: bug#18548: Emacs whitespace mode
Date: Wed, 23 Feb 2022 15:58:33 +0200
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Wed, 23 Feb 2022 14:18:46 +0100
> Cc: Kip Coul <kipcoul <at> gmail.com>, Stefan Kangas <stefan <at> marxist.se>,
>  Jack Morrison <JackMorrison1 <at> gmail.com>, 18548 <at> debbugs.gnu.org
> 
> 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?

I think the only way to fix this (and I agree that it's a marginal use
case) is to introduce some special syntax into display-table notation,
and then teach the display engine to ignore the TAB when whatever is
before it in the display-table entry already ends at a tab stop, and
the display-table entry has that special syntax.

Not sure if it's worth the hassle.

In any case, most of the implementation should be in the display
engine, because that's where the TAB display is implemented in Emacs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Wed, 23 Feb 2022 17:03:01 GMT) Full text and rfc822 format available.

Message #37 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nathaniel Braun <nathaniel.braun <at> gmail.com>
Cc: larsi <at> gnus.org, 18548 <at> debbugs.gnu.org, stefan <at> marxist.se,
 JackMorrison1 <at> gmail.com
Subject: Re: bug#18548: Emacs whitespace mode
Date: Wed, 23 Feb 2022 19:01:59 +0200
> From: Nathaniel Braun <nathaniel.braun <at> gmail.com>
> Date: Wed, 23 Feb 2022 18:28:11 +0200
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, Stefan Kangas <stefan <at> marxist.se>, 
> 	Jack Morrison <JackMorrison1 <at> gmail.com>, 18548 <at> debbugs.gnu.org
> 
> Where is the display engine code?

src/xdisp.c




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Wed, 23 Feb 2022 19:27:01 GMT) Full text and rfc822 format available.

Message #40 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Nathaniel Braun <nathaniel.braun <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 18548 <at> debbugs.gnu.org,
 Stefan Kangas <stefan <at> marxist.se>, Jack Morrison <JackMorrison1 <at> gmail.com>
Subject: Re: bug#18548: Emacs whitespace mode
Date: Wed, 23 Feb 2022 18:28:11 +0200
[Message part 1 (text/plain, inline)]
Where is the display engine code?

On Wed, Feb 23, 2022 at 3:58 PM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Lars Ingebrigtsen <larsi <at> gnus.org>
> > Date: Wed, 23 Feb 2022 14:18:46 +0100
> > Cc: Kip Coul <kipcoul <at> gmail.com>, Stefan Kangas <stefan <at> marxist.se>,
> >  Jack Morrison <JackMorrison1 <at> gmail.com>, 18548 <at> debbugs.gnu.org
> >
> > 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?
>
> I think the only way to fix this (and I agree that it's a marginal use
> case) is to introduce some special syntax into display-table notation,
> and then teach the display engine to ignore the TAB when whatever is
> before it in the display-table entry already ends at a tab stop, and
> the display-table entry has that special syntax.
>
> Not sure if it's worth the hassle.
>
> In any case, most of the implementation should be in the display
> engine, because that's where the TAB display is implemented in Emacs.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Wed, 23 Feb 2022 19:27:02 GMT) Full text and rfc822 format available.

Message #43 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Nathaniel Braun <nathaniel.braun <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 18548 <at> debbugs.gnu.org,
 Stefan Kangas <stefan <at> marxist.se>, Jack Morrison <JackMorrison1 <at> gmail.com>
Subject: Re: bug#18548: Emacs whitespace mode
Date: Wed, 23 Feb 2022 19:10:34 +0200
[Message part 1 (text/plain, inline)]
Thanks! I'll have a look

On Wed, Feb 23, 2022 at 7:01 PM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Nathaniel Braun <nathaniel.braun <at> gmail.com>
> > Date: Wed, 23 Feb 2022 18:28:11 +0200
> > Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, Stefan Kangas <stefan <at> marxist.se>,
>
> >       Jack Morrison <JackMorrison1 <at> gmail.com>, 18548 <at> debbugs.gnu.org
> >
> > Where is the display engine code?
>
> src/xdisp.c
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18548; Package emacs. (Thu, 24 Feb 2022 09:07:02 GMT) Full text and rfc822 format available.

Message #46 received at 18548 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: nathaniel.braun <at> gmail.com, 18548 <at> debbugs.gnu.org, kipcoul <at> gmail.com,
 stefan <at> marxist.se, JackMorrison1 <at> gmail.com
Subject: Re: bug#18548: Emacs whitespace mode
Date: Thu, 24 Feb 2022 10:05:45 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> I think the only way to fix this (and I agree that it's a marginal use
> case) is to introduce some special syntax into display-table notation,
> and then teach the display engine to ignore the TAB when whatever is
> before it in the display-table entry already ends at a tab stop, and
> the display-table entry has that special syntax.

Yes, that would be nice.

> Not sure if it's worth the hassle.

No, me neither.

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




Removed tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 26 Mar 2022 16:40:01 GMT) Full text and rfc822 format available.

Forcibly Merged 18441 18548. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 02 May 2022 09:49:02 GMT) Full text and rfc822 format available.

Forcibly Merged 18441 18548 46590. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 17 Jun 2022 15:38:02 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 360 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.