From b521d36aa89111fc3239973c3411b82cb2f3cc94 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Thu, 28 Apr 2016 13:22:22 +0100 Subject: [PATCH] el/dot-emacs.el: Add an approximate simulacrum of work C style. Organization: Straylight/Edgeware From: Mark Wooding This will get refined later. The most awful thing is having to hack on indentation after `arglist-cont-nonempty'. I'm not sure how this will work in some cases, but it seems to match, more or less, what I find in the existing files. --- el/dot-emacs.el | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 8b24c35..a2989fe 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -1450,6 +1450,22 @@ (defun mdw-c-indent-extern-mumble (langelem) c-basic-offset nil))) +(defun mdw-c-indent-arglist-nested (langelem) + "Indent continued argument lists. +If we've nested more than one argument list, then only introduce a single +indentation anyway." + (let ((context c-syntactic-context) + (pos (c-langelem-2nd-pos c-syntactic-element)) + (should-indent-p t)) + (while (and context + (eq (caar context) 'arglist-cont-nonempty)) + (when (and (= (caddr (pop context)) pos) + context + (memq (caar context) '(arglist-intro + arglist-cont-nonempty))) + (setq should-indent-p nil))) + (if should-indent-p '+ 0))) + (defvar mdw-define-c-styles-hook nil "Hook run when `cc-mode' starts up to define styles.") @@ -1470,6 +1486,32 @@ (defun ,func () (c-add-style ,name-string ',assocs)) (eval-after-load "cc-mode" '(run-hooks 'mdw-define-c-styles-hook)) +(mdw-define-c-style mdw-trustonic-c + (c-basic-offset . 4) + (comment-column . 0) + (c-indent-comment-alist (anchored-comment . (column . 0)) + (end-block . (space . 1)) + (cpp-end-block . (space . 1)) + (other . (space . 1))) + (c-class-key . "class") + (c-backslash-column . 0) + (c-auto-align-backslashes . nil) + (c-label-minimum-indentation . 0) + (c-offsets-alist (substatement-open . (add 0 c-indent-one-line-block)) + (defun-open . (add 0 c-indent-one-line-block)) + (arglist-cont-nonempty . mdw-c-indent-arglist-nested) + (topmost-intro . mdw-c-indent-extern-mumble) + (cpp-define-intro . 0) + (knr-argdecl . 0) + (inextern-lang . [0]) + (label . 0) + (case-label . +) + (access-label . -) + (inclass . +) + (inline-open . ++) + (statement-cont . +) + (statement-case-intro . +))) + (mdw-define-c-style mdw-c (c-basic-offset . 2) (comment-column . 40) -- [mdw]