unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Trouble with cc-mode style
@ 2004-03-02 22:14 exits funnel
  0 siblings, 0 replies; 4+ messages in thread
From: exits funnel @ 2004-03-02 22:14 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 3109 bytes --]

Hello,

I've recently bugun using Emacs to edit C++.  A couple
of weeks ago, I added the following to my .emacs:

;; BEGIN OLD STUFF
 (defun ef-cish-setup ( )
   (message "exit: In ef-cish-setup( )")
   (setq c-basic-offset 2)
   (setq c-default-style "bsd"))

 (add-hook 'c-mode-hook 'ef-cish-setup)
 (add-hook 'c++-mode-hook 'ef-cish-setup)
 (add-hook 'java-mode-hook 'ef-cish-setup)


 (require 'cc-mode)
 (c-set-offset 'substatement-open 0)
 (c-set-offset 'block-open 0)
 (c-set-offset 'statement-cont 0)
 (c-set-offset 'access-label '*)
 (c-set-offset 'inclass '+)
 (c-set-offset 'topmost-intro '+)
 (c-set-offset 'inline-open '+)
;; END OLD STUFF

It worked pretty well but now I've decided I'd like to
create an explicit style because, well, why not. 
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.   I've read most or all of the cc-mode
info but I still have a number of questions.

1) What's wrong with my style that causes the
wrong-type-argument error?
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
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?
4) This is completely off-topic to the rest of the
mail but what the heck: what can add to my .emacs file
to force emacs to maximize immediatly after it's
started?  I googled a bit and oddly found several
references to how to do it on w32 but came up empty
with respect to Linux.  

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

-exits


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

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

* Re: Trouble with cc-mode style
       [not found] <mailman.1007.1078303437.340.help-gnu-emacs@gnu.org>
@ 2004-03-03 19:44 ` Alan Mackenzie
  2004-03-13 16:42   ` exits funnel
  2004-03-03 20:35 ` Alan Mackenzie
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2004-03-03 19:44 UTC (permalink / raw)


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

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

* Re: Trouble with cc-mode style
       [not found] <mailman.1007.1078303437.340.help-gnu-emacs@gnu.org>
  2004-03-03 19:44 ` Alan Mackenzie
@ 2004-03-03 20:35 ` Alan Mackenzie
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Mackenzie @ 2004-03-03 20:35 UTC (permalink / raw)


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

Hi, please only pay a moderate amount of attention to my previous post.
Your problem is caused by the following:

> ;;C++ Hook
> (defun ef-c++-setup ( )
>   (message "exit: In ef-c++-setup( )")
>   (c-set-style exits-c++-style)      ; <=========================
> )

The call to `c-set-style' takes a string, as follows:
(c-set-style "exits-c++-style")

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

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

* Re: Trouble with cc-mode style
  2004-03-03 19:44 ` Alan Mackenzie
@ 2004-03-13 16:42   ` exits funnel
  0 siblings, 0 replies; 4+ messages in thread
From: exits funnel @ 2004-03-13 16:42 UTC (permalink / raw)


Alan, thanks for taking the time to reply it's greatly
appreciated.

> 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?

I think this improvement would suffice.  


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

This is a big help; I think I have everything working
now.  Thanks again.

-exits



__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com

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

end of thread, other threads:[~2004-03-13 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-02 22:14 Trouble with cc-mode style exits funnel
     [not found] <mailman.1007.1078303437.340.help-gnu-emacs@gnu.org>
2004-03-03 19:44 ` Alan Mackenzie
2004-03-13 16:42   ` exits funnel
2004-03-03 20:35 ` Alan Mackenzie

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