diff --git a/modules/lang/cc/autoload.el b/modules/lang/cc/autoload.el index 4b45f8a78..a6fd1c5ec 100644 --- a/modules/lang/cc/autoload.el +++ b/modules/lang/cc/autoload.el @@ -1,5 +1,18 @@ ;;; lang/cc/autoload.el -*- lexical-binding: t; -*- +;;;###autoload +(defun +cc*lineup-arglist (orig-fun &rest args) + "Improve indentation of continued C++11 lambda function opened as argument." + (if (and (eq major-mode 'c++-mode) + (ignore-errors + (save-excursion + (goto-char (c-langelem-pos langelem)) + ;; Detect "[...](" or "[...]{". preceded by "," or "(", + ;; and with unclosed brace. + (looking-at-p ".*[(,][ \t]*\\[[^]]*\\][ \t]*[({][^}]*$")))) + 0 ; no additional indent + (apply orig-fun args))) + ;;;###autoload (defun +cc/autoclose->-maybe () "For some reason smartparens won't autoskip >'s, this hack does." diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el index 100993217..01a466a68 100644 --- a/modules/lang/cc/config.el +++ b/modules/lang/cc/config.el @@ -49,7 +49,7 @@ (sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC")))) ;; Improve indentation of inline lambdas in C++11 - (advice-add #'c-lineup-arglist :around #'+c-lineup-arglist) + (advice-add #'c-lineup-arglist :around #'+cc*lineup-arglist) ;; C/C++ style settings (c-toggle-electric-state -1)