Subject: bug#77465: 29.4; VC annotate does not display tabs properly

From: Eli Zaretskii <[email-masked]>
Date: Thu, 03 Apr 2025 10:47:17 +0300

> Date: Wed, 02 Apr 2025 10:30:57 -0600
> From:  Tom Tromey via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> 
> Some projects I work on use tab characters for indentation.

Emacs uses TABs mixed with SPCes as a matter of policy.

> I used 'C-x v =' to annotate a file from one of these projects.
> 
> In this case, because the VC-provided margin text is not a multiple of 8
> characters, the tabs are rendered improperly, making the program text
> look strange.
> 
> As an example, open emacs/src/alloc.c and C-x v =
> 
> Then search for the tab character in code (with comments the weirdness
> isn't as pronounced).
> 
> Here's an example from emacs where I've turned the tabs into spaces so
> you can see the effect:
> 
> b88e9cded7ae (Paul Eggert             2016-01-26  226)   else
> b88e9cded7ae (Paul Eggert             2016-01-26  227)     {
> b88e9cded7ae (Paul Eggert             2016-01-26  228)       if (!malloc_using_checking)
> b88e9cded7ae (Paul Eggert             2016-01-26  229)  {
> b88e9cded7ae (Paul Eggert             2016-01-26  230)    /* Work around a bug in glibc's malloc.  MALLOC_CHECK_ must be

AFAICT, "git annotate" produces the same effect when invoked from the
shell prompt.  I'm not sure we should try to be "holier than the Pope"
here.

> One simple fix would be to ensure that the margin text is always a
> multiple of 8.

I don't think this is practical, since Git doesn't guarantee the
prefix of a line to be of a fixed width.  Here's a typical example:

47099d6f7       (Richard M. Stallman    1993-06-06 21:16:51 +0000       27)
4588ec205       (Jim Blandy     1991-07-03 12:10:07 +0000       28)
a08795204       (Richard M. Stallman    1995-11-12 05:20:12 +0000       29)
fd2e066a8       (Geoff Voelker  1995-11-07 07:14:59 +0000       30)
fd2e066a8       (Geoff Voelker  1995-11-07 07:14:59 +0000       31)
e5560ff7d       (Andreas Schwab 2012-06-16 14:24:15 +0200       32)
d43721a22       (Andrew Innes   2000-08-22 22:14:00 +0000       33)
502b9b644       (Jim Blandy     1992-07-13 19:54:34 +0000       34)
428a555ec       (Károly Lőrentey        2004-01-05 05:54:35 +0000       35)
4588ec205       (Jim Blandy     1991-07-03 12:10:07 +0000       36)
4588ec205       (Jim Blandy     1991-07-03 12:10:07 +0000       37)
4588ec205       (Jim Blandy     1991-07-03 12:10:07 +0000       38)
97cf50e75       (Richard M. Stallman    1996-04-23 20:32:58 +0000       39)
58b2bb63f       (Richard M. Stallman    1995-08-21 21:56:40 +0000       40)

> However, a more sophisticated approach may be possible as well.

The only idea I have is to replace each tab with a suitable number of
spaces, but that would probably make this command much slower, since
the buffer created by "C-x v =" is typically very large.

Any other ideas?