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

Re: [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 22, 2006, 20:36 UTC
Message-ID
<200610222236.45414.jnareb@gmail.com>
In-Reply-To
<7v3b9g5cde.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 8 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> Code should be aligned the same way, regardless of tab size.
>> Use tabs for indent, but spaces for align.
> 
> I do not necessarily agree with that policy; the result of
> applying this patch is still inconsistent in some places, and I
> think that is primarily because the policy itself is flawed.
To be true I do those "whitespace cleanup" patches when I notice
that something is mis-aligned for _my_ tab width (2 spaces).
I use Emacs with show-whitespace-mode to not introduce errors
which would be aligned for 2 columsn wide tabs but be misaligned
for more common 5 or 8 characters wide tabs.
 
Show 23 quoted lines
> For example, a part of sub format_paging_nav looks like this:
> 
>         sub format_paging_nav {
>         >>>>>>>>my ($action, $hash, $head, $page, $nrevs) = @_;
>         ...
>         >>>>>>>>if ($page > 0) {
>         >>>>>>>>>>>>>>>>$paging_nav .= " &sdot; " .
>         >>>>>>>>>>>>>>>>>>>>>>>>$cgi->a({-href => href(action=>$a
>         >>>>>>>>>>>>>>>>>>>>>>>>         -accesskey => "p", -titl
>         >>>>>>>>} else {
>         ...
> 
> If your policy is to indent continuation lines (which is why you
> have a TAB before "$cgi->a"), not having a TAB before the
> continued parameter list for the $cgi->a() call look inconsistent.
> 
> If on the other hand your policy is to align parameters to an
> operator that are spread over multiple lines, " &sdot; " and
> "$cgi-a(..." are left and right parameters to the string
> concatenation operator "." in between them, so "$cgi->a" should
> be pushed back with a run of SP starting at the column that
> begins $paging_nav and aligned with the DQ at the beginning of
> the " &sdot; " string.

That is preferred, and usually used policy, although I sometimes use former to avoid too long lines.

I never claimed to be perfect...

Nevertheless this patch for example correct situation where the line which should be aligned is aligned using mixture of tabs and spaces differing from line to line in the "same alignment" block.

-- 
Jakub Narebski
Poland
Previous: Junio C HamanoNext: Linus Torvalds
Message 4 of 11 in “gitweb: Improving tree view (plus some cleanups)”
  1. 0/4 gitweb: Improving tree view (plus some cleanups)Jakub Narebski, Oct 21, 2006
  2. 1/4 gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)Jakub Narebski, Oct 21, 2006
  3. Junio C HamanoOct 22, 2006
  4. Jakub NarebskiOct 22, 2006
  5. Linus TorvaldsOct 22, 2006
  6. Jakub NarebskiOct 22, 2006
  7. Junio C HamanoOct 22, 2006
  8. Luben TuikovOct 22, 2006
  9. 2/4 gitweb: Do not esc_html $basedir argument to git_print_tree_entryJakub Narebski, Oct 21, 2006
  10. 3/4 gitweb: Improve git_print_page_pathJakub Narebski, Oct 21, 2006
  11. 4/4 gitweb: Add '..' (up directory) to tree view if applicableJakub Narebski, Oct 21, 2006

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.