From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Klaus Berndl Newsgroups: gmane.emacs.help Subject: Re: Lobotimze Java mode indentation engine? Date: 29 Jul 2003 14:26:13 +0200 Organization: sd&m AG, Muenchen, Germany Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <84ptjto7vz.fsf@slowfox.is.informatik.uni-duisburg.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1059482098 18444 80.91.224.249 (29 Jul 2003 12:34:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 29 Jul 2003 12:34:58 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 29 14:34:57 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19hTgC-0004j3-00 for ; Tue, 29 Jul 2003 14:34:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19hTdZ-0002iO-DP for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Jul 2003 08:31:29 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!transit.news.xs4all.nl!newsfeed.wxs.nl!borium.box.nl!newsfeed.kabelfoon.nl!195.129.110.21.MISMATCH!bnewsfeed00.bru.ops.eu.uu.net!bnewsinpeer00.bru.ops.eu.uu.net!emea.uu.net!news.sdm.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 155 Original-NNTP-Posting-Host: sachrang.muc.sdm.de Original-X-Trace: solti3.muc.sdm.de 1059481573 29285 193.102.181.185 (29 Jul 2003 12:26:13 GMT) Original-X-Complaints-To: usenet@news.sdm.de Original-NNTP-Posting-Date: 29 Jul 2003 12:26:13 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Original-Xref: shelby.stanford.edu gnu.emacs.help:115519 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:11437 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:11437 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