automake-patches
[Top][All Lists]
Advanced

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

FYI: local variables to set GNU indentation style


From: Alexandre Duret-Lutz
Subject: FYI: local variables to set GNU indentation style
Date: 27 Jun 2002 21:18:28 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

I'm checking in this on HEAD.

This tweak the regex definitions to unfool perl-mode, and most
importantly this adds some Emacs local variables so that both
perl-mode and cperl-mode produce the same indentation (GNU's).
Currently we have two styles (LW and GNU) mixed in the sources.

2002-06-27  Alexandre Duret-Lutz  <address@hidden>

        * aclocal.in: Add local variables so that Emacs setups GNU style
        for perl-mode and cperl-mode.
        * automake.in: Likewise.
        (WHITE_PATTERN, RULE_PATTERN, SUFFIX_RULE_PATTERN, MACRO_PATTERN,
        ASSIGNMENT_PATTERN, IF_PATTERN, ELSE_PATTERN, ENDIF_PATTERN,
        INCLUDE_PATTERN, EXEC_DIR_PATTERN): Write $ as "\$" to please
        perl-mode.

Index: HACKING
===================================================================
RCS file: /cvs/automake/automake/HACKING,v
retrieving revision 1.13
diff -u -r1.13 HACKING
--- HACKING     6 Mar 2002 06:24:50 -0000       1.13
+++ HACKING     27 Jun 2002 18:55:57 -0000
@@ -71,7 +71,10 @@
 ================================================================
 = Editing automake.in and aclocal.in
 
-* Follow existing indentation style.
+* Indent using GNU style.  For historical reasons, the perl code
+  contains portions indented using Larry Wall's style (perl-mode's
+  default), and other portions using the GNU style (cperl-mode's
+  default).  Write new code using GNU style.
 
 * Perl 5 is now OK.
 
Index: aclocal.in
===================================================================
RCS file: /cvs/automake/automake/aclocal.in,v
retrieving revision 1.68
diff -u -r1.68 aclocal.in
--- aclocal.in  19 Apr 2002 20:53:17 -0000      1.68
+++ aclocal.in  27 Jun 2002 18:55:58 -0000
@@ -470,3 +470,20 @@
 
 $output";
 }
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1310
diff -u -r1.1310 automake.in
--- automake.in 26 Jun 2002 19:13:49 -0000      1.1310
+++ automake.in 27 Jun 2002 18:56:21 -0000
@@ -126,8 +126,17 @@
 # Some regular expressions.  One reason to put them here is that it
 # makes indentation work better in Emacs.
 
+# Writting singled-quoted-$-terminated regexes is a pain because
+# perl-mode thinks of $' as the ${'} variable (intead of a $ followed
+# by a closing quote.  Letting perl-mode think the quote is not closed
+# leads to all sort of misindentations.  On the other hand, defining
+# regexes as double-quoted strings is far less readable.  So usually
+# we will write:
+#
+#  $REGEX = '^regex_value' . "\$";
+
 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
-my $WHITE_PATTERN = '^\s*$';
+my $WHITE_PATTERN = '^\s*' . "\$";
 my $COMMENT_PATTERN = '^#';
 my $TARGET_PATTERN='address@hidden(){}/address@hidden';
 # A rule has three parts: a list of targets, a list of dependencies,
@@ -135,25 +144,29 @@
 my $RULE_PATTERN =
   "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
 
-my $SUFFIX_RULE_PATTERN = 
'^(\.[a-zA-Z0-9_()address@hidden)(\.[a-zA-Z0-9_()address@hidden)$';
+my $SUFFIX_RULE_PATTERN =
+    '^(\.[a-zA-Z0-9_()address@hidden)(\.[a-zA-Z0-9_()address@hidden)' . "\$";
 # Only recognize leading spaces, not leading tabs.  If we recognize
 # leading tabs here then we need to make the reader smarter, because
 # otherwise it will think rules like `foo=bar; \' are errors.
-my $MACRO_PATTERN = 'address@hidden';
-my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)$';
+my $MACRO_PATTERN = 'address@hidden' . "\$";
+my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$";
 # This pattern recognizes a Gnits version id and sets $1 if the
 # release is an alpha release.  We also allow a suffix which can be
 # used to extend the version number with a "fork" identifier.
 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
-my $IF_PATTERN =          '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
-my $ELSE_PATTERN =   '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
-my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
-my $PATH_PATTERN='(\w|[/.-])+';
+
+my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$";
+my $ELSE_PATTERN =
+  '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
+my $ENDIF_PATTERN =
+  '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
+my $PATH_PATTERN = '(\w|[/.-])+';
 # This will pass through anything not of the prescribed form.
 my $INCLUDE_PATTERN = ('^include\s+'
                       . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
                       . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
-                      . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
+                      . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
 
 # This handles substitution references like ${foo:.a=.b}.
 my $SUBST_REF_PATTERN = "^([^:]*):([^=]*)=(.*)\$";
@@ -162,7 +175,7 @@
 my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
 # Directories installed during 'install-exec' phase.
 my $EXEC_DIR_PATTERN =
-    '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)$'; #'
+  '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
 
 # Constants to define the "strictness" level.
 use constant FOREIGN => 0;
@@ -8324,6 +8337,7 @@
   -c, --copy             with -a, copy missing files (default is symlink)
   -f, --force-missing    force update of standard files
 EOF
+#' <- unfool perl-mode
 
     my ($last, @lcomm);
     $last = '';
@@ -8392,3 +8406,20 @@
 EOF
   exit 0;
 }
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
-- 
Alexandre Duret-Lutz




reply via email to

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