all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Alter a built-in style (C++, want to change where "access labels" are placed)
@ 2006-11-25 21:45 Eric Lilja
  2006-11-25 22:31 ` Eric Lilja
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Lilja @ 2006-11-25 21:45 UTC (permalink / raw)


Hi!
Sorry for starting a new thread, hope this isn't bad netiquette.

My question: In my C++ mode hook I set the style to "ellemtel" with
(c-set-style "ellemtel")

I like how it indents except for where it place access labels (public,
private and protected in classes).
I want to change this behaviour but keep the rest. According to CC Mode
manual this seems very possible:
"If none of the built-in styles is appropriate, you'll probably want to
create a new style definition, possibly based on an existing style. To
do this, put the new style's settings into a list with the following
format - the list can then be passed as an argument to the function
c-add-style."

I look at the provide sample .emacs file but I can't even make this
defconst compile and I don't know  what I should do when it does.

(defconst my-c++-style
  '(
    (c-offsets-alist . ((access-label . -)))) "My C++ Programming
style")

Compiling file c:/cygwin/home/hivemind/.emacs at Sat Nov 25 22:38:59
2006
.emacs:137:1:Error: End of file during parsing

And how do I "inherit" all settings from ellementel and override the
one as constructed in the defconst?

/ E

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

* Re: Alter a built-in style (C++, want to change where "access labels" are placed)
  2006-11-25 21:45 Alter a built-in style (C++, want to change where "access labels" are placed) Eric Lilja
@ 2006-11-25 22:31 ` Eric Lilja
  2006-11-25 23:22   ` Eric Lilja
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Lilja @ 2006-11-25 22:31 UTC (permalink / raw)



Eric Lilja skrev:

> Hi!
> Sorry for starting a new thread, hope this isn't bad netiquette.
>
> My question: In my C++ mode hook I set the style to "ellemtel" with
> (c-set-style "ellemtel")
>
> I like how it indents except for where it place access labels (public,
> private and protected in classes).
> I want to change this behaviour but keep the rest. According to CC Mode
> manual this seems very possible:
> "If none of the built-in styles is appropriate, you'll probably want to
> create a new style definition, possibly based on an existing style. To
> do this, put the new style's settings into a list with the following
> format - the list can then be passed as an argument to the function
> c-add-style."
>
> I look at the provide sample .emacs file but I can't even make this
> defconst compile and I don't know  what I should do when it does.
>
> (defconst my-c++-style
>   '(
>     (c-offsets-alist . ((access-label . -)))) "My C++ Programming
> style")
>
> Compiling file c:/cygwin/home/hivemind/.emacs at Sat Nov 25 22:38:59
> 2006
> .emacs:137:1:Error: End of file during parsing
>
> And how do I "inherit" all settings from ellementel and override the
> one as constructed in the defconst?
>
> / E

Tried this:
(defconst my-c++-style
  "ellemtel"
  '(
    (c-offsets-alist . ((access-label . -)))
  )
)
;(c-add-style "PERSONAL" my-c++-style)

(defun my-c-mode-common-hook ()
  ;; my customizations for all of c-mode and related modes
  (setq c-basic-offset 3)
  (setq-default indent-tabs-mode nil) ; Use spaces, not tabs, for
indentation.
  (delete-selection-mode 1) ; Maybe on by default on windows and off by
default on solaris?
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

(defun my-cpp-mode-hook ()
  (c-set-style "ellemtel")
)
(add-hook 'c++-mode-hook 'my-cpp-mode-hook)

However, it doesn't like c-add-style:
c-add-style: Wrong type argument: listp, "ellemtel"
and thus I cannot test it in c-set-style

Any ideas?

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

* Re: Alter a built-in style (C++, want to change where "access labels" are placed)
  2006-11-25 22:31 ` Eric Lilja
@ 2006-11-25 23:22   ` Eric Lilja
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Lilja @ 2006-11-25 23:22 UTC (permalink / raw)



Eric Lilja skrev:

> Eric Lilja skrev:
>
> > Hi!
> > Sorry for starting a new thread, hope this isn't bad netiquette.
> >
> > My question: In my C++ mode hook I set the style to "ellemtel" with
> > (c-set-style "ellemtel")
> >
> > I like how it indents except for where it place access labels (public,
> > private and protected in classes).
> > I want to change this behaviour but keep the rest. According to CC Mode
> > manual this seems very possible:
> > "If none of the built-in styles is appropriate, you'll probably want to
> > create a new style definition, possibly based on an existing style. To
> > do this, put the new style's settings into a list with the following
> > format - the list can then be passed as an argument to the function
> > c-add-style."
> >
> > I look at the provide sample .emacs file but I can't even make this
> > defconst compile and I don't know  what I should do when it does.
> >
> > (defconst my-c++-style
> >   '(
> >     (c-offsets-alist . ((access-label . -)))) "My C++ Programming
> > style")
> >
> > Compiling file c:/cygwin/home/hivemind/.emacs at Sat Nov 25 22:38:59
> > 2006
> > .emacs:137:1:Error: End of file during parsing
> >
> > And how do I "inherit" all settings from ellementel and override the
> > one as constructed in the defconst?
> >
> > / E
>
> Tried this:
> (defconst my-c++-style
>   "ellemtel"
>   '(
>     (c-offsets-alist . ((access-label . -)))
>   )
> )
> ;(c-add-style "PERSONAL" my-c++-style)
>
> (defun my-c-mode-common-hook ()
>   ;; my customizations for all of c-mode and related modes
>   (setq c-basic-offset 3)
>   (setq-default indent-tabs-mode nil) ; Use spaces, not tabs, for
> indentation.
>   (delete-selection-mode 1) ; Maybe on by default on windows and off by
> default on solaris?
>   )
> (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
>
> (defun my-cpp-mode-hook ()
>   (c-set-style "ellemtel")
> )
> (add-hook 'c++-mode-hook 'my-cpp-mode-hook)
>
> However, it doesn't like c-add-style:
> c-add-style: Wrong type argument: listp, "ellemtel"
> and thus I cannot test it in c-set-style
>
> Any ideas?

This seems to work!
(defun my-c-mode-common-hook ()
  ;; my customizations for all of c-mode and related modes
  (setq c-basic-offset 3)
  (setq-default indent-tabs-mode nil) ; Use spaces, not tabs, for
indentation.
  (delete-selection-mode 1) ; Maybe on by default on windows and off by
default on solaris?
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

(defun my-cpp-mode-hook ()
  (c-set-style "ellemtel")
  (c-set-offset 'access-label '--)
  (c-set-offset 'topmost-intro '-)
  (c-set-offset 'inline-open '-)
)
(add-hook 'c++-mode-hook 'my-cpp-mode-hook)

/ E

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

end of thread, other threads:[~2006-11-25 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-25 21:45 Alter a built-in style (C++, want to change where "access labels" are placed) Eric Lilja
2006-11-25 22:31 ` Eric Lilja
2006-11-25 23:22   ` Eric Lilja

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.