From 2b8f7667316af4530103cf84dba17e2a45c5a6d3 Mon Sep 17 00:00:00 2001 From: John Doty Date: Thu, 28 Aug 2014 17:32:31 -0700 Subject: [PATCH] Some hooks for C++ and PS --- .emacs.d/core.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.emacs.d/core.el b/.emacs.d/core.el index de8a5a3..1252a89 100644 --- a/.emacs.d/core.el +++ b/.emacs.d/core.el @@ -384,7 +384,7 @@ (brace-list-intro . +) (substatement . +) (arglist-intro . +) - (arglist-close . 0) + (arglist-close . +) (statement-case-open . +) )))) @@ -393,6 +393,21 @@ (add-hook 'idl-mode-hook 'my-idl-mode-hook) +;; http://stackoverflow.com/questions/23553881/emacs-indenting-of-c11-lambda-functions-cc-mode/23553882#23553882 +;; For such a wonderfully small function, it works REALLY REALLY well. +(defadvice c-lineup-arglist (around my activate) + "Improve indentation of continued C++11 lambda function opened as argument." + (setq ad-return-value + (if (and (equal 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 ".*[(,][ \t]*\\[[^]]*\\][ \t]*[({][^}]*$")))) + 0 ; no additional indent + ad-do-it))) ; default behavior + ;; ================================================================= ;; C#-Mode configuration. ;; ================================================================= @@ -515,6 +530,12 @@ (add-to-list 'auto-mode-alist '("\\.ps1\\'" . powershell-mode)) (add-to-list 'auto-mode-alist '("\\.psm1\\'" . powershell-mode)) +(defun my-powershell-hook() + (set (make-local-variable 'powershell-indent) 2) + (set (make-local-variable 'powershell-continuation-indent) 2)) + +(add-hook 'powershell-mode-hook 'my-powershell-hook) + ;; ================================================================= ;; LUA Mode ;; =================================================================