Skip to content

Commit 2c16adb

Browse files
committed
Special case when an argument is called with no args in the line
1 parent 490cdfa commit 2c16adb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.dir-locals.el

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
(beginning-of-line)
3636
(if (re-search-forward "[ ]*);$" endpoint t) t nil))))
3737

38+
(defun my/prev-line-call-with-no-args-p ()
39+
"Return true if the previous line is a function call with no arguments"
40+
(save-excursion
41+
(let ((start (point)))
42+
(forward-line -1)
43+
(if (re-search-forward ".($" start t) t nil))))
44+
3845
(defun my/arglist-cont-nonempty-indentation (arg)
3946
(if (my/inside-java-lambda-p)
4047
'+
@@ -50,6 +57,9 @@
5057

5158
(defun my/arglist-close (arg) (if (my/trailing-paren-p) 0 '--))
5259

60+
(defun my/arglist-intro (arg)
61+
(if (my/prev-line-call-with-no-args-p) '++ 0))
62+
5363
(c-set-offset 'inline-open 0)
5464
(c-set-offset 'topmost-intro-cont '+)
5565
(c-set-offset 'statement-block-intro 'my/statement-block-intro)
@@ -61,7 +71,7 @@
6171
(c-set-offset 'label '+)
6272
(c-set-offset 'statement-case-open '+)
6373
(c-set-offset 'statement-cont '++)
64-
(c-set-offset 'arglist-intro 0)
74+
(c-set-offset 'arglist-intro 'my/arglist-intro)
6575
(c-set-offset 'arglist-cont-nonempty '(my/arglist-cont-nonempty-indentation c-lineup-arglist))
6676
(c-set-offset 'arglist-close 'my/arglist-close)
6777
(c-set-offset 'inexpr-class 0)

0 commit comments

Comments
 (0)