Emacs: Set solid indentation rules for C

master
Pierre Neidhardt 2014-10-26 18:04:11 +01:00
parent b47ab3d15b
commit 35efc11fe9
3 changed files with 28 additions and 21 deletions

View File

@ -115,15 +115,16 @@
))
(define-key my-keys-minor-mode-map (kbd "C-<f7>") 'whitespace-mode)
;; WARNING: this can break some configuration files needing whitespaces at the
;; end.
; (add-hook 'before-save-hook 'delete-trailing-whitespace)
(setq whitespace-style (quote (face trailing tab-mark)))
(setq whitespace-style (quote (face trailing tab-mark space-after-tab space-before-tab indentation::space)))
;; TODO: whitespace report-on-bogus and cleanup do not seem to work properly.
;; Empty lines seems to be always true. Report is shown even when style is not
;; matching the errors.
; (setq whitespace-action '(report-on-bogus))
;; WARNING: this can break some configuration files needing whitespaces at the
;; end.
; (add-hook 'before-save-hook 'sanitize)
;; Remove whitespaces on region, or whole file.
(define-key my-keys-minor-mode-map (kbd "C-\\") 'delete-trailing-whitespace)

View File

@ -56,24 +56,24 @@ restored."
;; C-mode
;;==============================================================================
;; WARNING: this style is a work-in-progress.
(c-add-style
"peter"
'((c-comment-only-line-offset . 0)
(c-hanging-braces-alist
(brace-list-open)
(brace-entry-open)
(substatement-open after)
(block-close . c-snug-do-while)
(arglist-cont-nonempty))
(c-cleanup-list brace-else-brace)
(c-offsets-alist
(statement-block-intro . +)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(case-label . +)
(statement-cont . +))))
`((c-comment-only-line-offset . 0)
(c-auto-align-backslashes . nil)
(c-basic-offset . ,tab-width)
(c-offsets-alist
(arglist-cont-nonempty . +)
(arglist-intro . +)
(c . 0)
(case-label . +)
(knr-argdecl-intro . 0)
(label . 0)
(statement-block-intro . +)
(statement-cont . +)
(substatement-label . 0)
(substatement-open . 0)
)))
;; Note that in Emacs 24, cc-mode calls its hooks manually in each mode init
;; function. Since cc modes belong to prog-mode, each hook is called another
@ -84,7 +84,7 @@ restored."
(add-hook-and-eval
mode-hook
(lambda ()
(c-set-style "peter" t)
(c-set-style "peter") ;; We override existing values.
(add-hook 'compilation-before-hook 'cc-set-compiler nil t)
(local-set-key (kbd "<f9>") 'cc-clean)
(local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline)

View File

@ -44,6 +44,12 @@
(set-face-background 'shadow "black" )
(set-face-background 'shadow "#1c1c1c" ))
;; Whitespace mode
(add-hook
'whitespace-load-hook
(lambda ()
(set-face-background 'whitespace-indentation "#696969" )))
;; Programming
(set-face-foreground 'font-lock-builtin-face "#d2691e" )
(set-face-bold-p 'font-lock-builtin-face t )