From 490cdfac5c441effaa2148a7325404f24d56d3d1 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Thu, 22 Oct 2015 10:54:01 -0600 Subject: [PATCH] Fix indentation for trailing parentheses (people shouldn't write trailing parentheses anyway!) --- .dir-locals.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index c7461942041..9b0d487fb62 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -27,6 +27,14 @@ (forward-line -1) (if (search-forward " -> {" start t) t nil)))) + (defun my/trailing-paren-p () + "Returns true if point is a training paren and semicolon" + (save-excursion + (end-of-line) + (let ((endpoint (point))) + (beginning-of-line) + (if (re-search-forward "[ ]*);$" endpoint t) t nil)))) + (defun my/arglist-cont-nonempty-indentation (arg) (if (my/inside-java-lambda-p) '+ @@ -40,6 +48,8 @@ (defun my/block-close (arg) (if (my/inside-java-lambda-p) '- 0)) + (defun my/arglist-close (arg) (if (my/trailing-paren-p) 0 '--)) + (c-set-offset 'inline-open 0) (c-set-offset 'topmost-intro-cont '+) (c-set-offset 'statement-block-intro 'my/statement-block-intro) @@ -53,7 +63,7 @@ (c-set-offset 'statement-cont '++) (c-set-offset 'arglist-intro 0) (c-set-offset 'arglist-cont-nonempty '(my/arglist-cont-nonempty-indentation c-lineup-arglist)) - (c-set-offset 'arglist-close '--) + (c-set-offset 'arglist-close 'my/arglist-close) (c-set-offset 'inexpr-class 0) (c-set-offset 'access-label 0) (c-set-offset 'inher-intro '++)