bug-grep
[Top][All Lists]
Advanced

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

eliminate TABs in indentation


From: Jim Meyering
Subject: eliminate TABs in indentation
Date: Thu, 08 Apr 2010 20:18:13 +0200

I've been promising/threatening this change for a while.

This makes it so the code is now consistent with HACKING's
"Use SPACE-only indentation in all[*] files" section.

  http://git.savannah.gnu.org/cgit/grep.git/tree/HACKING#n236

In case you have large pending patches and fear massive merge conflicts,
don't worry.

I've just proved that it's easy to migrate big changes past the
indentation change by rebasing 25 or 30 csets (albeit all small) across
the divide.  I used the same tool/procedure as described here:

  http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/19811/focus=19909


>From 699bcc4bd8166abb6ee26a37d9e1189817741277 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 8 Apr 2010 18:39:24 +0200
Subject: [PATCH 1/2] convert all TABs to equivalent spaces in indentation

Using this file,

cat > leading-blank.exempt <<\EOF
(?:^|\/)ChangeLog[^/]*$
(?:^|\/)(?:GNU)?[Mm]akefile[^/]*$
\.(?:am|mk)$
EOF

run this command to convert all non-conforming leading white
space to be all spaces:

git ls-files \
  | pcregrep -vf leading-blank.exempt \
  | xargs pcregrep -l '^ *\t' \
  | xargs perl -MText::Tabs -ni -le \
    '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
...

>From 430bdb38eb27600a211c968adb1d3c8c86d867cf Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 8 Apr 2010 18:45:16 +0200
Subject: [PATCH 2/2] maint: add syntax-check rule to enforce the new 
no-leading-TABs policy

* cfg.mk (sc_prohibit_tab_based_indentation): New rule, from coreutils.
(sc_prohibit_emacs__indent_tabs_mode__setting): Likewise.
(old_NEWS_hash): Update.
* .x-sc_prohibit_tab_based_indentation: List exempt files.
---
 .x-sc_prohibit_tab_based_indentation |    3 +++
 cfg.mk                               |   14 +++++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)
 create mode 100644 .x-sc_prohibit_tab_based_indentation

diff --git a/.x-sc_prohibit_tab_based_indentation 
b/.x-sc_prohibit_tab_based_indentation
new file mode 100644
index 0000000..6500293
--- /dev/null
+++ b/.x-sc_prohibit_tab_based_indentation
@@ -0,0 +1,3 @@
+(^|/)ChangeLog[^/]*$
+(^|/)(GNU)?[Mm]akefile[^/]*$
+\.(am|mk)$
diff --git a/cfg.mk b/cfg.mk
index 0e0e162..cbd3c0d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -30,7 +30,7 @@ bootstrap-tools = autoconf,automake,gnulib
 # Now that we have better tests, make this the default.
 export VERBOSE = yes

-old_NEWS_hash = 6b4d3b539bb872fcfef458ceb3d3461b
+old_NEWS_hash = 62f7c4d1bdc4f161dcec5ad9c314cf4a

 # Many m4 macros names once began with `jm_'.
 # Make sure that none are inadvertently reintroduced.
@@ -45,6 +45,18 @@ sc_prohibit_echo_minus_en:
        halt='do not use echo ''-e or echo ''-n; use printf instead'    \
          $(_sc_search_regexp)

+# Indent only with spaces.
+sc_prohibit_tab_based_indentation:
+       @prohibit='^ *  '                                               \
+       halt='TAB in indentation; use only spaces'                      \
+         $(_sc_search_regexp)
+
+# Don't use "indent-tabs-mode: nil" anymore.  No longer needed.
+sc_prohibit_emacs__indent_tabs_mode__setting:
+       @prohibit='^( *[*#] *)?indent-tabs-mode:'                       \
+       halt='use of emacs indent-tabs-mode: setting'                   \
+         $(_sc_search_regexp)
+
 update-copyright-env = \
   UPDATE_COPYRIGHT_USE_INTERVALS=1 \
   UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
--
1.7.1.rc0.239.g8b27e




reply via email to

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