git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH RFC 2/2] diff: teach diff to expand tabs in output

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2017, 20:46 UTC
Message-ID
<xmqqbmslcep0.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170328203814.36aiocj53wtfcjz5@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> That also means an option to something like "expand" is tough, because
> "first character" really means "first non-ANSI-code character".

That is true, but once you commit to the mindset that you are extending "expand", then that becomes a mere part of what must be done, i.e. if you want your "expand" to be able to handle coloured input, you'd need to know how wide each segment of the input is. For that matter, you would also want your "expand" to pay attention to the differences between display- vs byte-widths of a string, perhaps reusing utf8_strwidth() or something.

Also "the first character is special" does not have to be a "diff specific hack". Your extended "expand" can take a list of tab-widths and the special case for highlighting diff output happens to take 9,8 as the "list of tab-widths" parameter (whose semantics is that each number in the list tells how wide the tab is, and the last number repeats forever, so 9,8 really means 9,8,8,8,8,...).

Previous: Jeff King
Message 6 of 6 in “strbuf: move strbuf_add_tabexpand into strbuf.c”
  1. 1/2 strbuf: move strbuf_add_tabexpand into strbuf.cJacob Keller, Mar 28, 2017
  2. 2/2 diff: teach diff to expand tabs in outputJacob Keller, Mar 28, 2017
  3. Junio C HamanoMar 28, 2017
  4. Jacob KellerMar 28, 2017
  5. Jeff KingMar 28, 2017
  6. Junio C HamanoMar 28, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.