diff --git a/puppet-mode.el b/puppet-mode.el index 1076277..54e3992 100644 --- a/puppet-mode.el +++ b/puppet-mode.el @@ -555,11 +555,32 @@ of the initial include plus puppet-include-indent." ;; refreshonly => true, ;; } (save-excursion - (goto-char array-start) - (forward-char 1) - (re-search-forward "\\S-") - (forward-char -1) - (setq cur-indent (current-column)))) + (if (looking-at "^\\s-*],*") + ;; If a closing bracket is on a line by itself, align it with the + ;; opening bracket. + (progn + (goto-char array-start) + (setq cur-indent (current-indentation))) + + (goto-char array-start) + (forward-char 1) + + ;; If the point is at the end of the line, use normal indentation. + ;; + ;; For example: + ;; exec { 'foo': + ;; creates => [ + ;; 'foo', + ;; 'bar', + ;; ] + ;; } + ;; + (if (eolp) + (setq cur-indent (+ (current-indentation) puppet-indent-level)) + ;; Otherwise, attempt to align as described above. + (re-search-forward "\\S-") + (forward-char -1) + (setq cur-indent (current-column)))))) (include-start (setq cur-indent include-start)) ((and (looking-at "^\\s-*},?\\s-*$") block-indent)