unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: J Richardson <jrivers77@yahoo.com>
Subject: Re: Java mode indention
Date: 06 Aug 2003 16:05:54 -0400	[thread overview]
Message-ID: <uvftasg9p.fsf@yahoo.com> (raw)
In-Reply-To: uvftahcjp.fsf@yahoo.com

J Richardson <jrivers77@yahoo.com> writes:

> 
>   arglist-intro:
>   a_method(another_method(
>                foo, bar));
> 
> 
>   arglist-cont-nonempty:
>   a_method(another_method(foo,
>                bar));
> 
> > Also, which version of CC Mode are you using?  (Do M-x c-version).
> 
> CC Mode version 5.28
> 
> > 
> > > when I'd prefer this:
> > 
> > >   a_method(another_method(foo,
> > >       bar));
> > 
> > >   ^ I want it to add it from here
> > 
> > In the most recent CC Mode (5.30) it looks like the "bar" would get
> > indented 8 columns from begining-of-line (4 columns (c-basic-offset) for
> > each level of parentheses).  This isn't very good either.  It may well be
> > that the best quick fix would be to write you a special indentation
> > function (see the page "Indentation Functions" in the CC Mode manual).
> 
> I'll check out 5.30. Indenting from the beginning of the line is the
> issue I wasn't sure how to work around.
> 
> I looked at indentation functions a while ago. Rechecking now, they
> take a syntactic component cons cell which contains the "buffer
> relative position" and return the offset to add to that position. I'm
> by no means an elisp guru, so I may be missing something, but since
> it's the buffer relative position that I don't like I'm not sure how
> to get that to work. It sounds like CC Mode 5.30 may help there
> though.
> 
> > 
> > The most helpful place to report this sort of problem is on the CC Mode
> > mailing list at bug-cc-mode@gnu.org.
> > 

Ooh, I have it now. Archives from bug-cc-mode@gnu.org helped. I didn't
know about the back-to-indentation function.

(defun jc-indent-method-args (langelem)
  (save-excursion
    (goto-char (cdr langelem))
    (back-to-indentation)
    (vector (+ (current-column) c-basic-offset))))

(c-set-offset 'arglist-intro 'jc-indent-method-args)
(c-set-offset 'arglist-cont 'jc-indent-method-args)
(c-set-offset 'arglist-cont-nonempty 'jc-indent-method-args)

It seems to work so far.

Thanks!

  reply	other threads:[~2003-08-06 20:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.789.1059668280.8231.help-gnu-emacs@gnu.org>
2003-07-31 17:06 ` Java mode indention Kai Großjohann
2003-07-31 19:43   ` J Richardson
     [not found]   ` <mailman.806.1059680707.8231.help-gnu-emacs@gnu.org>
2003-08-01 20:38     ` Kai Großjohann
2003-08-01 21:24     ` Alan Mackenzie
2003-08-06 18:21       ` J Richardson
2003-08-06 20:05         ` J Richardson [this message]
2003-08-10 17:35 ` Stefan Monnier
2003-08-12 17:03   ` J Richardson
2003-07-31 16:02 J Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uvftasg9p.fsf@yahoo.com \
    --to=jrivers77@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).