all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Indenting problem
@ 2003-04-23 22:30 M Wasilewski
  2003-04-24  8:07 ` Alan Mackenzie
  2003-04-24 16:42 ` Kai Großjohann
  0 siblings, 2 replies; 3+ messages in thread
From: M Wasilewski @ 2003-04-23 22:30 UTC (permalink / raw)


I seem to be having a problem with emacs indenting. Under solaris and 
linux my indenting looks like so:

Vector3 cross( const Vector3 &v ) const
{
 return Vector3( y * v.z - z * v.y,
                 z * v.x - x * v.z,
                 x * v.y - y * v.x );
}

No problems. But running emacs under Windows XP with the same .emacs file 
gives me this:

Vector3 cross( const Vector3 &v ) const
{
 return Vector3( y * v.z - z * v.y,
               z * v.x - x * v.z,
               x * v.y - y * v.x );
}

The z and the x are lined up with the bracket rather than the y. Does 
anyone know why this is? Or more importantly how to fix it?
Thanks.

---------------
Mike Wasilewski

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

* Re: Indenting problem
  2003-04-23 22:30 Indenting problem M Wasilewski
@ 2003-04-24  8:07 ` Alan Mackenzie
  2003-04-24 16:42 ` Kai Großjohann
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2003-04-24  8:07 UTC (permalink / raw)


M Wasilewski <mmw@srv.ualberta.ca> wrote on 23 Apr 2003 22:30:58 GMT:
> I seem to be having a problem with emacs indenting. Under solaris and 
> linux my indenting looks like so:

> Vector3 cross( const Vector3 &v ) const
> {
>  return Vector3( y * v.z - z * v.y,
>                  z * v.x - x * v.z,        <==============
>                  x * v.y - y * v.x );
> }

> No problems. But running emacs under Windows XP with the same .emacs file 
> gives me this:

> Vector3 cross( const Vector3 &v ) const
> {
>  return Vector3( y * v.z - z * v.y,
>                z * v.x - x * v.z,          <==============
>                x * v.y - y * v.x );
> }

> The z and the x are lined up with the bracket rather than the y. Does 
> anyone know why this is? Or more importantly how to fix it?
> Thanks.

You don't explicitly say so, so I'm assuming you're programming in C, or
some other language handled by cc-mode.

You need to use an "indentation function", in particular
c-lineup-arglist, rather than just straightforward indentation.

To understand this, put the cursor on the line I've marked "<====".  Type
C-c C-s.  This will tell you something like "((arglist-cont-nonempty 1268
1282))", cc-mode's syntactic analysis of the line.  (The numbers are
buffer positions of important reference points.)

To try out the new function, type C-c C-o on this line and accept the
suggested default, "arglist-cont-nonempty", with <CR>.  In place of the
suggested default, type "c-lineup-arglist"<CR>.  Now use the <tab> key in
your buffer to check that the two continuation lines do indeed indent
properly.

You'll want to put this into your .emacs to make it permanent.  You can
either attach this to "c-mode-common-hook" (when it will apply to all
cc-mode languages), or to "c-mode-hook" (if you just want it to be for
C).  The entry will look something like this:

(defun my-c-mode-common-hook ()
  (c-set-offset 'arglist-cont-nonempty 'c-lineup-arglist)
;; other customization here.
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

This is all described in the CC-Mode info pages under "Customizing
indentaion".

All the best!

> Mike Wasilewski

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

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

* Re: Indenting problem
  2003-04-23 22:30 Indenting problem M Wasilewski
  2003-04-24  8:07 ` Alan Mackenzie
@ 2003-04-24 16:42 ` Kai Großjohann
  1 sibling, 0 replies; 3+ messages in thread
From: Kai Großjohann @ 2003-04-24 16:42 UTC (permalink / raw)


M Wasilewski <mmw@srv.ualberta.ca> writes:

> The z and the x are lined up with the bracket rather than the y. Does 
> anyone know why this is? Or more importantly how to fix it?

Do you use the same version of Emacs on all systems?  M-x version RET
tells you the version.
-- 
file-error; Data: (Opening input file no such file or directory ~/.signature)

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

end of thread, other threads:[~2003-04-24 16:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-23 22:30 Indenting problem M Wasilewski
2003-04-24  8:07 ` Alan Mackenzie
2003-04-24 16:42 ` 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.