[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20322: 25.0.50; indent-tabs-mode should default to nil

From: Dmitry Gutov
Subject: bug#20322: 25.0.50; indent-tabs-mode should default to nil
Date: Tue, 21 Apr 2015 01:09:28 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Thunderbird/36.0

On 04/20/2015 10:26 PM, Stefan Monnier wrote:

Ah, so the units are lines?  Indeed, then this can be strongly biased if
people use smaller tab-width than 8.

It seems it would make more sense to count files (or projects), where
each file gets to be counted either as SPC or as TAB depending on
whether it has more lines that use TAB than lines that use either spaces.

That sounds better, but still would discount the JavaScript files with less than 4 levels of nesting (unless we only count each project once; but I think the project size is important, too). And in our case, any hunks which didn't include this level of nesting (see the caveat at the bottom).

Here's updated counts (in number of files), produced by parsing the log (one you can download here: http://dropcanvas.com/3mwn1):

C:     tabs => 17422, spaces =>  6509
C++:   tabs =>  7366, spaces => 17155
JS:    tabs => 30100, spaces => 73370
Java:  tabs => 66922, spaces => 38243
Elisp: tabs =>   515, spaces =>  1465

(The ratio for C became even more tab-favored, but others seem to have moved towards spaces).


File.open("print.log", "r") do |file|
results = Hash[%w(c cpp js java el).map { |ext| [ext, {tabs: 0, spaces: 0}]}] file_re = /\.(#{results.keys.join("|")}): spaces ([0-9]+), tabs ([0-9]+)$/

  file.each_line do |line|
    if line =~ file_re
      ext    = $~[1]
      spaces = $~[2].to_i
      tabs   = $~[3].to_i

      ext_results = results[ext]
      if spaces > tabs
        ext_results[:spaces] += 1
      elsif spaces < tabs
        ext_results[:tabs] += 1

  puts results

This way, the bias only affects a file at a time, which should be
insignificant if we assume that those files should use a consistent
style (i.e. either 99% TABs or 99% SPC).

CAVEAT: The above was still only the result of the diffs analysis, and didn't examine the files in their entirety (the original run took more than 8 hours here, and downloading the actual files is bound to take an order of magnitude more, just for January 1st).

But to get a feeling for the margin of error, here's the result of running a modified script, which sorted all "spaces 0, tabs 0" files into the "spaces" bucket:

C:     tabs => 17422,  spaces =>  16683
C++:   tabs =>  7366,  spaces =>  44641
JS:    tabs => 30100,  spaces => 143709
Java:  tabs => 66922,  spaces =>  98886
Elisp: tabs =>   515,  spaces =>   2423

So yeah, it seems C programmers favored tabs either way that day. The Java programmers, however, are undecided.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]