Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File to show options that tell GNU indent to format code as we want. #8

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contrib/gnu-indent-options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-l80 -fca -i4 -ts4 -nut
40 changes: 40 additions & 0 deletions contrib/ucx-style.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
;; Usage:
;; add our tweaks to c-mode
;; The basic indentation
;; (add-hook 'c-mode-hook 'ucx-indent-config)
;;
;; Warn when we're getting close to exceeding line length
;; (add-hook 'c-mode-hook 'ucx-mark-80-column-rule)
;;
;; On-the-fly indentation of lines
;; (add-hook 'c-mode-hook 'electric-indent-mode)
;;
;; Indent opened lines immediately rather than TABbing across
;; (add-hook 'c-mode-hook 'ucx-c-nl-indent)
;;

(require 'cc-mode)
(require 'whitespace)

(defun ucx-mark-80-column-rule ()
"Highlight lines that are about to get too long"
(setq whitespace-line-column 78)
(setq whitespace-style '(face empty tabs lines-tail trailing))
(whitespace-mode)
)

(defun ucx-indent-config ()
"Set the required layout"
(setq c-basic-offset 4
tab-width 4
indent-tabs-mode nil)
)

;; add our tweaks to c-mode
(defun ucx-c-nl-indent ()
"Make newline also immediately indent next line"
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
)

;; Other people can now require me
(provide 'ucx-style)