[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. 0ddc107582fccee33b93c64f16f9e98af13ca732

Micah Anderson micah at riseup.net
Sat May 10 17:42:06 UTC 2008


The following commit has been merged in the master branch:
commit 0ddc107582fccee33b93c64f16f9e98af13ca732
Author: Russ Allbery <rra at debian.org>
Date:   Fri May 9 15:09:47 2008 -0700

    Fix Emacs mode indentation of multiple nested blocks
    
    Indentation of multiple nested blocks was broken; the closing braces
    of all the outer blocks were put into column 0 because finding the
    block indentation failed.  Do normal indentation if finding a block
    indentation fails, but more importantly, be smarter about searching
    backwards to find the beginning of the current block, taking balanced
    braces into account.
    
    There is probably some less-ugly and more Emacs-native way of doing
    this.

diff --git a/ext/emacs/puppet-mode.el b/ext/emacs/puppet-mode.el
index f767c6c..65a6b68 100644
--- a/ext/emacs/puppet-mode.el
+++ b/ext/emacs/puppet-mode.el
@@ -84,7 +84,14 @@ of the closing brace of a block."
         (when apoint
           ;; This is a bit of a hack and doesn't allow for strings.  We really
           ;; want to parse by sexps at some point.
-          (if (= (puppet-count-matches "}" apoint opoint) 0)
+          (let ((close-braces (puppet-count-matches "}" apoint opoint))
+                (open-braces 0))
+            (while (and apoint (> close-braces open-braces))
+              (setq apoint (search-backward "{" nil t))
+              (when apoint
+                (setq close-braces (puppet-count-matches "}" apoint opoint))
+                (setq open-braces (1+ open-braces)))))
+          (if apoint
               (current-indentation)
             nil))))))
 
@@ -172,12 +179,11 @@ of the initial include plus puppet-include-indent."
           (setq cur-indent (current-column))))
        (include-start
         (setq cur-indent include-start))
-       ((looking-at "^\\s-*}\\s-*$")
-        ;; This line contains only a closing brace, so we should indent it
-        ;; matching the indentation of the opening brace of the block.
-        (if block-indent
-            (setq cur-indent block-indent)
-          (setq cur-indent 0)))
+       ((and (looking-at "^\\s-*}\\s-*$") block-indent)
+        ;; This line contains only a closing brace and we're at the inner
+        ;; block, so we should indent it matching the indentation of the
+        ;; opening brace of the block.
+        (setq cur-indent block-indent))
        (t
         ;; Otherwise, we did not start on a block-ending-only line.
         (save-excursion

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list