From 974a23f6a4e971a5145c2feb4c410cf77b0b7240 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Tue, 28 Oct 2014 17:28:48 -0500 Subject: [PATCH 1/2] Initial drop of UCX indentation setup for GNU Emacs --- contrib/emacs/ucx-style.el | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 contrib/emacs/ucx-style.el diff --git a/contrib/emacs/ucx-style.el b/contrib/emacs/ucx-style.el new file mode 100644 index 000000000000..65b84726b014 --- /dev/null +++ b/contrib/emacs/ucx-style.el @@ -0,0 +1,45 @@ +;; +;; License goes here +;; + +;; +;; Usage: +;; add our tweaks to c-mode +;; The basic indentation +;; (add-hook 'c-mode-hook 'tc-indent-config) +;; +;; Warn when we're getting close to exceeding line length +;; (add-hook 'c-mode-hook 'tc-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 'tc-c-nl-indent) +;; + +(require 'cc-mode) +(require 'whitespace) + +(defun tc-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 tc-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 tc-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) From 80076046914ee3304078b99d7a1936ebc92d22fe Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Wed, 29 Oct 2014 15:30:14 -0500 Subject: [PATCH 2/2] Move elisp code up to top-level contrib directory (to match vim setup). Remove license stub. --- contrib/{emacs => }/ucx-style.el | 5 ----- 1 file changed, 5 deletions(-) rename contrib/{emacs => }/ucx-style.el (97%) diff --git a/contrib/emacs/ucx-style.el b/contrib/ucx-style.el similarity index 97% rename from contrib/emacs/ucx-style.el rename to contrib/ucx-style.el index 65b84726b014..9d4e7ddb45ba 100644 --- a/contrib/emacs/ucx-style.el +++ b/contrib/ucx-style.el @@ -1,8 +1,3 @@ -;; -;; License goes here -;; - -;; ;; Usage: ;; add our tweaks to c-mode ;; The basic indentation