Bug #4853 Emacs in internals.texi is incomplete
Submitted: 2 Aug 2004 15:12 Modified: 2 Aug 2004 19:28
Reporter: Dennis Haney Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:bk OS:
Assigned to: Alexander Keremidarski CPU Architecture:Any

[2 Aug 2004 15:12] Dennis Haney
Description:
From internals.texi:
QUOTE:
Suggested mode in emacs:

(load "cc-mode")
(setq c-mode-common-hook '(lambda ()
                            (turn-on-font-lock)
                            (setq comment-column 48)))
(setq c-style-alist
      (cons
       '("MY"
         (c-basic-offset . 2)
         (c-comment-only-line-offset . 0)
         (c-offsets-alist . ((statement-block-intro . +)
                             (knr-argdecl-intro . 0)
                             (substatement-open . 0)
                             (label . -)
                             (statement-cont . +)
                             (arglist-intro . c-lineup-arglist-intro-after-paren)
                             (arglist-close . c-lineup-arglist)
                             ))
         )
       c-style-alist))
(c-set-style "MY")
(setq c-default-style "MY")
END QUOTE

How to repeat:
it is in the documentation...

Suggested fix:
The more correct way to make a new C-style is using the function c-add-style:
(require 'font-lock)
(require 'cc-mode)
(global-font-lock-mode t) ;;colors in all buffers that support it
(setq font-lock-maximum-decoration t) ;;maximum color
(c-add-style "MY"
 '("k&r"
   '("MY"
     (c-basic-offset . 2)
     (c-comment-only-line-offset . 0)
     (c-offsets-alist . ((statement-block-intro . +)
                         (knr-argdecl-intro . 0)
                         (substatement-open . 0)
                         (label . -)
                         (statement-cont . +)
                         (arglist-intro . c-lineup-arglist-intro-after-paren)
                         (arglist-close . c-lineup-arglist)
                         ))
     )))

(setq c-mode-common-hook '(lambda ()
                            (c-set-style "MY")
                            (setq tab-width 8)
                            (setq indent-tabs-mode t)
                            (setq comment-column 48)))

It could also include an example to only add the MY-style to files in a mysql dir:

(setq c-mode-common-hook '(lambda ()
                            (if (string-match "/mysql-5.0/" (buffer-file-name))
                                (progn
                                  (c-set-style "MY")
                                  (setq tab-width 8)
                                  (setq indent-tabs-mode t)
                                  (setq comment-column 48)))
                            ))
[2 Aug 2004 18:28] MySQL Verification Team
Thank you so much for the correct Elisp code.
[2 Aug 2004 19:28] Paul DuBois
Thank you for your bug report. This issue has been addressed in the
documentation. The updated documentation will appear on our website
shortly, and will be included in the next release of the relevant
product(s).

Additional info:

I added the replacement code to internals.texi after
Sinisa made some revisions.