monit-dev
[Top][All Lists]
Advanced

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

The inevitable: programming style :-)


From: Jan-Henrik Haukeland
Subject: The inevitable: programming style :-)
Date: Wed, 16 Jul 2003 04:35:47 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Civil Service, linux)

Hacking around in the monit code lately I see that we use different
indentions. Could we please try to use the same style :-)

Use two spaces for indention (and using TAB for indention is strictly
verboten) and no line should be longer than 80 chars (split if it is,
the reason is that it should be possible to read the code in a
standard configured xterm 25x80). If you use two spaces for indention
the standard banana code pattern you get with lots of if/for/while
statements does not drop so easily out of the right margin.

Here is my setup in .emacs. If you use emacs simply put this into your
.emacs file and you get style :-)

--------8<--------------------------------------------------------------
(defconst allman-c-style
  '((c-tab-always-indent           . t)
    (set-fill-column 79)
    (c-hanging-braces-alist        . ((substatement-open before after)
                                      (brace-list-open)))
    (c-hanging-colons-alist        . ((member-init-intro before)
                                      (inher-intro)
                                      (case-label after)
                                      (label after)
                                      (access-label after)))
    (c-cleanup-list                . (scope-operator))
    (c-offsets-alist         . ((arglist-close         . c-lineup-arglist)
                                (defun-block-intro     . 2)
                                (substatement-open     . 0)
                                (statement-block-intro . 2)
                                (topmost-intro         . -2)
                                (block-open            . 0)
                                (inline-open           . -2)
                                (access-label          . -2)
                                (knr-argdecl-intro     . -)))

    ;(c-echo-syntactic-information-p . t)
    )
  "Allman Programming Style")

;; Customizations for all of c-mode, c++-mode, and objc-mode
(defun allman-c-mode-common-hook ()
  ;; add my personal style and set it for the current buffer
  (c-add-style "ALLMAN" allman-c-style t)
  ;; offset customizations not in allman-c-style
  (c-set-offset 'member-init-intro '++)
  ;; other customizations
  ;; keybindings for C, C++, and Objective-C.  We can put these in
  ;; c-mode-map because c++-mode-map and objc-mode-map inherit it
  (define-key c-mode-map "\C-m" 'newline-and-indent)
  )
(add-hook 'c-mode-common-hook 'allman-c-mode-common-hook)
--------8<--------------------------------------------------------------

-- 
Jan-Henrik Haukeland




reply via email to

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