Indentation of groovy style method parameters in emacs -
i using emacs groovy electric mode (installed outlined here). relevant parts (i think) of .emacs file given @ end of question.
the current behaviour getting indenting, type, is:
def someobject = new something( param1
everything how @ point, type ':' character, becomes:
def someobject = new something( param1:
i want param/value pairs (and follow) remain indented 1 level, before, e.g.:
def someobject = new something( param1: val1, param2: val2 )
.emacs
excerpt:
(electric-indent-mode t) (setq-default tab-width 4) (setq-default indent-tabs-mode nil) (setq indent-line-function 'insert-tab) (setq tabify nil) (setq-default c-basic-offset 4) (delete-selection-mode 1) (set-default-font "-apple-bitstream_vera_sans_mono-medium-normal-normal-*-*-*-*-*-m-0-iso10646-1") (setq load-path (cons "~/.emacs.d/" load-path)) (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") (setq whitespace-action '(auto-cleanup)) ;; automatically clean bad whitespace (setq whitespace-style '(trailing space-before-tab indentation empty space-after-tab)) ;; show bad whitespace ;;; delete trailing whitespace (add-hook 'before-save-hook 'delete-trailing-whitespace) ;;; turn on syntax highlighting (global-font-lock-mode 1) ;;; use groovy-mode when file ends in .groovy or has #!/bin/groovy @ start (autoload 'groovy-mode "groovy-mode" "major mode editing groovy code." t) (add-to-list 'auto-mode-alist '("\\.groovy\\'" . groovy-mode)) (add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode)) ;;; make groovy mode electric default. (add-hook 'groovy-mode-hook (lambda () (require 'groovy-electric) (groovy-electric-mode)))
edit: regarding @ataylor 's suggestion below, have tried both:
(add-hook 'groovy-mode-hook '(lambda () (require 'groovy-electric) (groovy-electric-mode))) (add-hook 'groovy-mode-hook '(c-set-offset 'label 4))
and
(add-hook 'groovy-mode-hook '(lambda () (require 'groovy-electric) (groovy-electric-mode) (c-set-offset 'label 4)))
neither of work want. correct spot?
groovy mode treating these types of parameters labels, case statement labels , used feature inherited java allows break
statements specify target.
you can override indentation adding hook:
(add-hook 'groovy-mode-hook (lambda () (c-set-offset 'label 4)))
Comments
Post a Comment