List:Internals« Previous MessageNext Message »
From:Ingo Strüwing Date:July 2 2009 1:55pm
Subject:Re: [style] [annc] Coding style update
View as plain text  
Hi,

Guilhem Bichot, 02.07.2009 14:18:

> Hello,
> 
> Tor Didriksen a écrit, Le 02.07.2009 08:50:
>> On Mon, 29 Jun 2009 09:53:13 +0200, Konstantin Osipov <kostja@stripped>
>> wrote:
...
>>> 1) Could someone using emacs send me the new formatting options
>>> for emacs to take into account the new switch () style?
>>
>> I'm getting exactly the new formatting style with the current emacs
>> settings, so nothing needs to be done.
> 
> Things work differently for me (recent XEmacs).
...
> I'm using exactly verbatim the .emacs section listed in
>
> http://forge.mysql.com/wiki/MySQL_Internals_Coding_Guidelines#Suggested_mode_in_emacs
...


I seem to have emacs 22.3.1 work. I do not use the emacs settings from
the guidelines, but customized everything manually. I attached my .emacs
file. I can't tell which of the lines you need to copy though. :-( But
all you need should be in the custom-set-variables section. Perhaps it's
just c-basic-offset, c-default-style, and c-offsets-alist.

Disclaimer: I'm not sure if my settings handle all other cases as they
should too. I'm not aware of problems though.

Regards
Ingo
-- 
Ingo Strüwing, Database Group
Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schröder,   Wolfgang Engels,   Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Häring   HRB München 161028

; .emacs

; ediff helper to be used on the command line like: emacs "$2" "$1" -f my-ediff-buffers
(defun my-ediff-buffers ();buffer-A buffer-B &optional startup-hooks job-name)
  "Run Ediff on a pair of buffers, BUFFER-A and BUFFER-B, which are in the 2 windows of
the current frame."
  (interactive)
  (if (= (length (window-list)) 2)
      (let* ((W1 (selected-window))
             (W2 (other-window 1))
             (B1 (window-buffer  W1))
             (B2 (window-buffer  W2)))
        (ediff-buffers B1 B2))
    (call-interactively 'ediff-buffers)))

; save all modified buffers
(defun ingo-save-some-buffers ()
  "Save the modified file-visiting buffers. Don't ask."
  (interactive)
  (save-some-buffers t))

; save all modified buffers and exit
(defun ingo-save-buffers-kill-emacs ()
  "Save each buffer. Don't ask. Then kill."
  (interactive)
  (save-buffers-kill-emacs t))

; key assignment
(global-set-key     [C-f2]   'ebuffers)
(global-set-key     [f2]     'ingo-save-some-buffers)
(global-set-key     [f3]     'ingo-save-buffers-kill-emacs)
(global-set-key     [f4]     'save-buffers-kill-emacs)
(global-set-key     [f7]     'goto-line)
(global-set-key     [f9]     'upcase-region)
(global-set-key     [f11]    'backward-word)
(global-set-key     [f12]    'forward-word)
(global-set-key     [M-home] 'previous-window-select)
(global-set-key     [M-end]  'next-window-select)

;;; --- personal preferences
(setq default-major-mode 'fundamental-mode)
(add-hook 'text-mode-hook 'text-mode-hook-identify)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(setq truncate-lines t)
(setq scroll-step 1)
(setq line-number-mode t)
(setq column-number-mode t)
(setq sentence-end "[.?!][]\"')}]*\\($\\|[ \t]\\)[ \t\n]*")
(setq sentence-end-double-space nil)
(set-cursor-color "red")
(set-mouse-color "black")
(transient-mark-mode 1)
(pc-selection-mode)
(condition-case nil (blink-cursor-mode -1) ((void-function) ()))
(show-paren-mode)
(setq visible-bell t)
(setq buffers-menu-max-size 40)

; enable colors in all modes
(global-font-lock-mode t)

;; font description
(set-face-foreground  font-lock-comment-face        "CadetBlue"       )
(set-face-foreground  font-lock-warning-face        "Red"             )
(set-face-foreground  font-lock-constant-face       "Magenta"         )
(set-face-foreground  font-lock-string-face         "MediumSlateBlue" )
(set-face-underline-p font-lock-string-face         t                 )
(set-face-foreground  font-lock-keyword-face        "BlueViolet"      )
(set-face-foreground  font-lock-builtin-face        "Goldenrod"       )
(set-face-foreground  font-lock-function-name-face  "MediumBlue"      )
(set-face-foreground  font-lock-variable-name-face  "Darkgreen"       )
(set-face-foreground  font-lock-type-face           "Maroon"          )
(set-face-foreground  font-lock-reference-face      "Brown"           )
(set-face-background  'region                       "Orange"          )

(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(blink-cursor-mode nil t)
 '(buffers-menu-show-directories t)
 '(c-basic-offset 2)
 '(c-default-style (quote ((c-mode . "whitesmith") (java-mode . "java") (other . "gnu"))))
 '(c-echo-syntactic-information-p t)
 '(c-offsets-alist (quote ((defun-block-intro . 2) (substatement-open . 0)
(statement-block-intro . 2) (class-open . 0) (defun-open . 0) (inclass . 2) (class-close
. 0) (arglist-cont . c-lineup-arglist) (arglist-cont-nonempty . c-lineup-arglist)
(arglist-close . c-lineup-arglist))))
 '(c-tab-always-indent nil)
 '(column-number-mode t)
 '(enable-completion nil)
 '(fill-column 72)
 '(indent-tabs-mode nil)
 '(inhibit-local-menu-bar-menus nil)
 '(inhibit-splash-screen t)
 '(inhibit-startup-buffer-menu t)
 '(mouse-buffer-menu-maxlen 40)
 '(mouse-wheel-follow-mouse t)
 '(mouse-wheel-mode t nil (mwheel))
 '(mouse-wheel-progressive-speed nil)
 '(mouse-yank-at-point nil)
 '(perl-continued-brace-offset -2)
 '(perl-indent-level 2)
 '(perl-tab-always-indent nil)
 '(recentf-max-menu-items 40)
 '(recentf-max-saved-items 40)
 '(scroll-bar-mode (quote right))
 '(scroll-conservatively 6)
 '(scroll-margin 1)
 '(scroll-step 1)
 '(sh-indent-after-do 4)
 '(sh-indent-comment t)
 '(sh-indent-for-do 0)
 '(sh-indent-for-then 0)
 '(show-paren-mode t nil (paren))
 '(tool-bar-mode nil nil (tool-bar))
 '(transient-mark-mode t)
 '(use-file-dialog nil)
 '(vc-consult-headers nil)
 '(vc-handled-backends (quote (RCS CVS)))
 '(version-control (quote never))
 '(x-gtk-whole-detached-tool-bar t))

(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(diff-added ((t (:inherit diff-changed :foreground "blue"))))
 '(diff-added-face ((t (:inherit diff-changed-face :foreground "blue"))))
 '(diff-changed ((nil (:foreground "green"))))
 '(diff-function ((t (:inherit diff-header :background "yellow"))))
 '(diff-removed ((t (:inherit diff-changed :foreground "red"))))
 '(diff-removed-face ((t (:inherit diff-changed-face :foreground "red"))))
 '(font-lock-doc-face ((t (:inherit font-lock-comment-face))))
 '(trailing-whitespace ((((class color) (background light)) (:background "alice blue")))))
; alternatives: azure , alice blue , light blue

(put 'upcase-region 'disabled nil)

(put 'downcase-region 'disabled nil)

;;;;;;;;;;;;;;;;;;;;
; Highlight trailing whitespace
; This requires the face trailing-whitespace to be configured with a color.
(mapc (lambda (hook)
        (add-hook hook (lambda () (setq show-trailing-whitespace t))))
      '(text-mode-hook
        diff-mode-hook
        c-mode-hook
        c++-mode-hook
        java-mode-hook
        perl-mode-hook
        python-mode-hook
        emacs-lisp-mode-hook
        shell-script-mode-hook))

;;;;;;;;;;;;;;;;;;;;
; Highlight tabs
(defface  tabs-face         '((t (:background "honeydew"))) "Used for tabs.")
; alternatives: honeydew , pale green
(defvar   tabskywds         '(("\t" . 'tabs-face)))
(add-hook 'text-mode-hook   (lambda () (font-lock-add-keywords nil tabskywds)))
(add-hook 'diff-mode-hook   (lambda () (font-lock-add-keywords nil tabskywds)))
(add-hook 'c-mode-hook      (lambda () (font-lock-add-keywords nil tabskywds)))
(add-hook 'c++-mode-hook    (lambda () (font-lock-add-keywords nil tabskywds)))
(add-hook 'java-mode-hook   (lambda () (font-lock-add-keywords nil tabskywds)))
(add-hook 'perl-mode-hook   (lambda () (font-lock-add-keywords nil tabskywds)))
(add-hook 'python-mode-hook (lambda () (font-lock-add-keywords nil tabskywds)))
(add-hook 'emacs-lisp-mode-hook (lambda ()
                                  (font-lock-add-keywords nil tabskywds)))
(add-hook 'shell-script-mode-hook (lambda ()
                                    (font-lock-add-keywords nil tabskywds)))

;; Falcon style
(defun falcon-c-mode ()
  "MySQL C mode with adjustments for Falcon"
  (c-mode)
  ;;(c-set-style "MY")
  (setq c-basic-offset 4)
  (setq tab-width 4)
  (c-set-offset 'defun-open 0)
  (c-set-offset 'substatement-open '+)
  (c-set-offset 'statement-block-intro 0)
)
(setq auto-mode-alist (cons '("/storage/falcon/" . falcon-c-mode)
                            auto-mode-alist))

;UTF-8
(define-coding-system-alias 'UTF-8 'mule-utf-8)
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)


Thread
[style] [annc] Coding style updateKonstantin Osipov29 Jun
  • re: [style] [annc] Coding style updateMichael Widenius30 Jun
    • Re: [style] [annc] Coding style updateKonstantin Osipov30 Jun
      • Re: [style] [annc] Coding style updateMichael Widenius30 Jun
        • Re: [style] [annc] Coding style updateAlex Esterkin1 Jul
    • Re: [style] [annc] Coding style updateIngo Strüwing1 Jul
  • Re: [style] [annc] Coding style updateTor Didriksen2 Jul
    • Re: [style] [annc] Coding style updateGuilhem Bichot2 Jul
      • Re: [style] [annc] Coding style updateTor Didriksen2 Jul
        • Re: [style] [annc] Coding style updateTor Didriksen2 Jul
          • Re: [style] [annc] Coding style updateGuilhem Bichot2 Jul
      • Re: [style] [annc] Coding style updateIngo Strüwing2 Jul
  • Re: [style] [annc] Coding style updateTor Didriksen3 Jul