Просмотр исходного кода

Fix indentation for trailing parentheses

(people shouldn't write trailing parentheses anyway!)
Lee Hinman 10 лет назад
Родитель
Сommit
490cdfac5c
1 измененных файлов с 11 добавлено и 1 удалено
  1. 11 1
      .dir-locals.el

+ 11 - 1
.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           '++)