all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Lobotimze Java mode indentation engine?
@ 2003-07-29 12:05 Kai Großjohann
  2003-07-29 12:26 ` Klaus Berndl
  0 siblings, 1 reply; 5+ messages in thread
From: Kai Großjohann @ 2003-07-29 12:05 UTC (permalink / raw)


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);

Ideas?
-- 
~/.signature

^ permalink raw reply	[flat|nested] 5+ messages in thread

* 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

* Re: Lobotimze Java mode indentation engine?
  2003-07-29 12:26 ` Klaus Berndl
@ 2003-07-29 13:54   ` Kai Großjohann
  2003-07-29 14:07     ` Klaus Berndl
  0 siblings, 1 reply; 5+ messages in thread
From: Kai Großjohann @ 2003-07-29 13:54 UTC (permalink / raw)


Klaus Berndl <klaus.berndl@sdm.de> writes:

> 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++....

Yes, indeed, this is what I want.  Now I had another look at the
docs, and found that (c-set-offset 'arglist-intro '+) did the trick.

I found this by doing C-c C-s on the b line, which gave me
arglist-cont-nonempty:

foo(a,
    b);

And then I did C-c C-s on this a line, which gave me arglist-intro:

foo(
    a,
    b);

Nice that this works now.
-- 
~/.signature

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Lobotimze Java mode indentation engine?
  2003-07-29 13:54   ` Kai Großjohann
@ 2003-07-29 14:07     ` Klaus Berndl
  2003-07-29 16:14       ` Kai Großjohann
  0 siblings, 1 reply; 5+ messages in thread
From: Klaus Berndl @ 2003-07-29 14:07 UTC (permalink / raw)


On Tue, 29 Jul 2003, Kai Großjohann wrote:

>  Klaus Berndl <klaus.berndl@sdm.de> writes:
>  
> > 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++....
>  
>  Yes, indeed, this is what I want.  Now I had another look at the
>  docs, and found that (c-set-offset 'arglist-intro '+) did the trick.
>  
>  I found this by doing C-c C-s on the b line, which gave me
>  arglist-cont-nonempty:
>  
>  foo(a,
>      b);
>  
>  And then I did C-c C-s on this a line, which gave me arglist-intro:
>  
>  foo(
>      a,
>      b);

Yes, thats the way i do this too... But what I'm wondering why it has not
worked for you before, because AFAIK arglist-intro is set by default to +?!

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

* Re: Lobotimze Java mode indentation engine?
  2003-07-29 14:07     ` Klaus Berndl
@ 2003-07-29 16:14       ` Kai Großjohann
  0 siblings, 0 replies; 5+ messages in thread
From: Kai Großjohann @ 2003-07-29 16:14 UTC (permalink / raw)


Klaus Berndl <klaus.berndl@sdm.de> writes:

> Yes, thats the way i do this too... But what I'm wondering why it has not
> worked for you before, because AFAIK arglist-intro is set by default to +?!

It was set to c-lineup-mumblefoo.  I have no idea why this was so,
however.  I can't remember having tweaked anything in that area.  (In
fact, my indentation customization until now consisted of setting
c-basic-offset and nothing else.)
-- 
~/.signature

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-07-29 16:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2003-07-29 14:07     ` Klaus Berndl
2003-07-29 16:14       ` Kai Großjohann

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.