Commit e5247721 authored by Akarsh Simha's avatar Akarsh Simha
Browse files

When a brace is inserted for a C++ lambda, insert ; after close-brace

The emacs lisp function insert-curly-brace in kde-emacs changes the
behavior of inserting a '{' in C-mode to also insert a matching
'}'. This works well when definitng methods, writing if and for
statements etc. However, with C++1x lambdas, there needs to be a ;
following the definition of the lambda. This patch incorporates that
behavior by matching lambda syntax.

REQUIRES more TESTING.
parent 8fec1e36
......@@ -594,8 +594,8 @@ This function does not do any hidden buffer changes."
(defun insert-curly-brace (arg) (interactive "*P")
(if (not (c-in-literal))
(let ((n nil) (o nil)
(spacep nil) (c nil)
(oneliner nil))
(spacep nil) (c nil)
(oneliner nil) (cxxlambda nil))
(save-excursion
(save-excursion
(if (re-search-forward "[a-zA-Z]" (point-at-eol) t)
......@@ -621,20 +621,23 @@ This function does not do any hidden buffer changes."
)
)
)
(setq cxxlambda (looking-back "\\[.*\\]\\s-*(.*)\\(\\s-*->.*\\)?\\s-*"))
(cond
(n (progn
((or n cxxlambda) (progn
(if (not spacep) (insert " "))
(self-insert-command (prefix-numeric-value arg))
(if (not c) (newline-and-indent))
(if oneliner (end-of-line))
(save-excursion
(if c
(progn
(next-line 1)
(end-of-line)
))
(newline-and-indent)
(insert "}")(c-indent-line))
(if c
(progn
(next-line 1)
(end-of-line)
))
(newline-and-indent)
(insert "}")
(if cxxlambda (insert ";"))
(c-indent-line))
(c-indent-line)
))
(o (progn
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment