Skip to content

Commit

Permalink
disable brace lists entirely, now everything in braces will be handle…
Browse files Browse the repository at this point in the history
…d as a statement list, fixing most

of the indentation problems
  • Loading branch information
Jim Morris committed Feb 2, 2010
1 parent cbe0ef3 commit 91851ae
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions groovy-mode.el
Expand Up @@ -439,8 +439,7 @@ need for `java-font-lock-extra-types'.")

;; use defadvice to override the syntactic type if we have a
;; statement-cont, see if previous line has a virtual semicolon and if
;; so make it statement. if it is a brace-list, change to statement as
;; we don't have brace-lists in groovy they are usually closures
;; so make it statement.
(defadvice c-guess-basic-syntax (after c-guess-basic-syntax-groovy activate)
(save-excursion
(let* ((ankpos (progn
Expand All @@ -454,24 +453,21 @@ need for `java-font-lock-extra-types'.")
(cond
((eq 'statement-cont curelem)
(when (groovy-at-vsemi-p) ; if there is a virtual semi there then make it a statement
(message "changing from %s to statement" ad-return-value)
(setq ad-return-value `((statement ,ankpos)))))

((eq 'topmost-intro-cont curelem)
(when (groovy-at-vsemi-p) ; if there is a virtual semi there then make it a top-most-intro
(message "changing from %s to topmost-intro" ad-return-value)
(setq ad-return-value `((topmost-intro ,ankpos)))))

((eq 'brace-list-entry curelem)
(save-excursion (goto-char ankpos)
(if (looking-at c-label-kwds-regexp) ; if it is a case or default
(setq ad-return-value `((statement-case-intro ,ankpos)))
(setq ad-return-value `((statement ,ankpos)))))) ; else make statement

;; try to eliminate brace lists
((eq 'brace-list-intro curelem)
(setq ad-return-value `((defun-block-intro ,ankpos))))

))))

;; This disables bracelists, as most of the time in groovy they are closures
(defadvice c-inside-bracelist-p (after c-inside-bracelist-p-groovy activate)
(setq ad-return-value nil))


;; based on java-function-regexp
;; Complicated regexp to match method declarations in interfaces or classes
;; A nasty test case is:
Expand Down

0 comments on commit 91851ae

Please sign in to comment.