* Re: Lobotimze Java mode indentation engine?
2003-07-29 12:05 Lobotimze Java mode indentation engine? Kai Großjohann
@ 2003-07-29 12:26 ` Klaus Berndl
2003-07-29 13:54 ` Kai Großjohann
0 siblings, 1 reply; 5+ messages in thread
From: Klaus Berndl @ 2003-07-29 12:26 UTC (permalink / raw)
On Tue, 29 Jul 2003, Kai Großjohann wrote:
> I think it might be useful, for consistency with others, to frob the
> Java indentation settings such that a line after an open paren is
> indented as + or ++ instead of aligning with the open paren.
>
> Maybe it would be even more useful if this only happened if the open
> paren was the last thing on a line, whereas the existing behavior
> stays if there is stuff after the open paren. This way, I could get:
>
> some_function(first_arg,
> second_arg);
> some_really_long_function_name_with_args_on_next_line(
> first_arg,
> second_arg);
I have written this small code only by hitting return, i.e. autom. indented:
,----
| void
| test_function()
| {
| function_call(arg1,
| arg2,
| arg3);
|
| function_call(
| arg1,
| arg2,
| arg3);
| }
`----
I think, this is what you want, isn't it?
BTW: IMHO this is useful not only for Java, but also for C and C++....
Here are my settings (sorry, maybe there is contained some noise for you, but
i hope there is also what you search for):
(defconst c-indentation 3)
(defvar my-c-style
`((c-basic-offset . ,c-indentation)
;; always indent current line regardless if point within a comment or
;; literal.
(c-tab-always-indent . t)
;; use this instead the setting a line above if you wish to indent
;; current line but additionally a real TAB-char should be inserted if
;; point is within a comment or literal.
;; (c-tab-always-indent . 'other)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open . my-set-begin-block)
(brace-list-open)
(brace-list-close)
(brace-list-intro)
(brace-entry-open)
(block-close . my-c-snug-do-while)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close .
c-lineup-arglist-close-under-paren)
(substatement-open . 0)
(case-label . ,c-indentation)
(block-open . 0)
(inline-open . 0)
(template-args-cont .
c-lineup-template-args)
(inher-cont . c-lineup-multi-inher)
(statement-cont . (c-lineup-math +))
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t)
)
"My C Programming Style")
;; Customizations for all of c-mode, c++-mode, objc-mode and java-mode
(defun my-c-mode-common-hook ()
;; add my personal style and set it for the current buffer
(c-add-style "PERSONAL" my-c-style t)
;; offset customizations not in my-c-style
(c-set-offset 'member-init-intro '++)
;; other customizations
;; set the physical tabwidth to the standard-value of most editors
;; this setting has NOTHING to do with the indentation of lines (look at
;; c-basic-offset)!
(setq tab-width 8)
;; this will make sure spaces are used instead of tabs
(setq indent-tabs-mode nil)
;; comments should be treated as whitespace in paren-matching, jumping
;; etc.
(setq parse-sexp-ignore-comments t)
;; we like auto-newline and hungry-delete
(c-toggle-auto-hungry-state 1)
;; keybindings for C, C++, and Objective-C. We can put these in
;; c-mode-base-map because c++-mode-map and java-mode-map and
;; c-mode-map inherit it.
(define-key c-mode-base-map "\C-m" 'my-cc-mode-return)
;; we must define [M-q] here again
(define-key c-mode-base-map (kbd "M-q") 'my-filling)
;; compile should be at [C-c m]
(define-key c-mode-base-map (kbd "C-c m") 'compile)
;;(setq delete-key-deletes-forward t)
;;(define-key c-mode-base-map [delete] 'c-electric-delete)
;; do automatic expansion of c(++)-template-symbols after hitting SPC
;(define-key c-mode-base-map (kbd "SPC") 'tempo-space)
;; lines of a c-block-comment should begin with a ""
(set-variable 'c-block-comment-prefix "")
;; we want no autofilling within cpp-makros string-literals and normal code
(set-variable 'c-ignore-auto-fill '(string cpp code))
;; turn on adaptive auto-fill-mode for easy writing comments
(auto-fill-mode 1)
(c-setup-filladapt)
(turn-on-filladapt-mode)
;; no automatic newlines after ';' if following line is non blank or
;; inside oneline inline methods
(add-to-list 'c-hanging-semi&comma-criteria
'c-semi&comma-no-newlines-before-nonblanks)
(add-to-list 'c-hanging-semi&comma-criteria
'c-semi&comma-no-newlines-for-oneline-inliners)
;; fillup comments after column 78
(set-variable 'fill-column 78)
;; we want to add a comment behind the closing brace of a block.
;; If you do not want this feature you must only comment out the following
;; line.
(add-hook 'c-special-indent-hook 'comment-block-close)
;; aktivate glasses-mode
;; (glasses-mode t)
;; camelCase
(autoload 'camelCase-mode "camelCase-mode" nil t)
(camelCase-mode 1)
(setq camelCase-modeline-indicator " cC")
(camelCase-install-mode)
(paren-toggle-open-paren-context 1)
(setq semantic-function-argument-separator ", ")
;; (modify-syntax-entry ?\\ " ")
)
Ciao,
Klaus
--
Klaus Berndl mailto: klaus.berndl@sdm.de
sd&m AG http://www.sdm.de
software design & management
Thomas-Dehler-Str. 27, 81737 München, Germany
Tel +49 89 63812-392, Fax -220
^ permalink raw reply [flat|nested] 5+ messages in thread