help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with cc-mode style


From: Alan Mackenzie
Subject: Re: Trouble with cc-mode style
Date: Wed, 3 Mar 2004 19:44:18 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

exits funnel <exitsfunnel@yahoo.com> wrote on Tue, 2 Mar 2004 14:14:41
-0800 (PST):
> Hello,

[ .... ]

> Here's what my .emacs looks like now:

> ;; BEGIN NEW STUFF
> (require 'cc-mode)     
> (defconst exits-c++-style
>  '(
>     (c-offsets-alist . (
>                          (substatement-open . 0)
>                          (block-open        . 0)
>                          (statement-cont    . 0)
>                          (access-label      . '*)
>                          (inclass           . '+)
>                          (topmost-intro     . '+)
>                          (inline-open       . '+)
>                        )
>     )
>     (c-echo-syntactic-information-p . t)
>   )
>   "exit's C++ Programming Style Comment"
> )

> (defun exits-c-mode-common-hook ()
>   (message "In exits-c-mode-common-hook")
>   (c-add-style "exits-c++-style" exits-c++-style t)
>   (global-set-key "\C-ci" 'c-indent-line-or-region)  
> )
>     
> (add-hook 'c-mode-common-hook
> 'exits-c-mode-common-hook)

> ;;C++ Hook
> (defun ef-c++-setup ( )
>   (message "exit: In ef-c++-setup( )")
>   (c-set-style exits-c++-style)
> )
> (add-hook 'c++-mode-hook 'ef-c++-setup)
> ;; END NEW STUFF

> I've been playing with this stuff all day but I can't seem to get it
> working.

> When I start emacs and visit a C++ file I get an error in the mini
> buffer which complains about: 'wrong-type-argument char-or-string-p'
> I'd paste the whole message but I can't figure out how to get the stuff
> out of the mini-buffer.

Go to the *Messages* buffer, where all the messages accumulate.  Even
better, set the flag debug-on-error (with M-: (setq debug-on-error t)),
then post the backtrace you'll get out of it (or include it in a bug
report to <bug-cc-mode@gnu.org> (see below)).

> I've read most or all of the cc-mode info but I still have a number of
> questions.

Your code works fine for me with GNU Emacs 21.1 and CC Mode 5.30.9.
First two questions:  Which version of Emacs (M-x emacs-version) and
which version of CC Mode (M-x c-version)?  It's "not impossible" that
the problem would vanish with the latest CC Mode, if you're not using it
already.  It's available at <http://www.sourceforge.net/release.php>.

> 1) What's wrong with my style that causes the wrong-type-argument
> error?

Nothing that I can see.  Unless it's something obvious that's gone wrong,
it would be appreciated if you could send an (even more detailed) bug
report to <bug-cc-mode@gnu.org>, using M-x c-submit-bug-report.  This
automatically includes the values of all CC Mode's configuration
variables.

> 2) Is there any further documentation anywhere on creating styles?  The
> cc-mode info stuff documents how styles interact with cc-mode and gives
> an example style but doesn't seem to really cover creating a style
> explicitly

It could be better, couldn't it?  No, there isn't any more documentation
that I know of, unless it's on the Emacs wiki site, or somewhere like
that.

However, there's no reason not to improve this documentation.  I've just
tried skimming through the Style section, and I end up on the page
"Adding styles", which describes the command `c-add-style'.  It contains
the passage:  "then a new style according to DESCRIPTION is added,", but
doesn't give any hint as to what DESCRIPTION looks like, other than
directing one to the sample .emacs file.  This is a documentation bug.
I'll fix it.

Would you be happy with the documentation if c-add-style's DESCRIPTION
parameter was documented here, or are there other problems too?

> 3) How can I make my style 'inherit' from the 'bsd' style.  I seem to
> recall reading that one could do this but I can't figure out how to do
> it?

Have a look at the documentation string for c-style-alist.  (C-h v
c-style-alist).  From this you can infer that "bsd" is to be added as
follows.  Naturally, it ought to be explicitly documented in the manual.

(defconst exits-c++-style
  "bsd"                           ; <===========================
 '(
....
....    
  )
  "exit's C++ Programming Style Comment"
)

> Thanks in advance for any replies and I apologize for being so
> long-windeed.

Not at all!  It's a damn sight better than a post whose entire content is
"I'm having trouble with C++ styles.  Can you help me please?".  Thanks
for producing such a detailed report.

> -exits

-- 
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").



reply via email to

[Prev in Thread] Current Thread [Next in Thread]