summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-09-13 02:24:21 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-09-13 02:24:21 (GMT)
commit165859782144e453159c06909d5ddf8491ec79ff (patch)
tree23d462eb68920e1e1d3412278e88ae8e58786b69
parente5247721d73dc1c43bbccafa1a33bb42aaa334c7 (diff)
Insert a close-brace when an open brace is inserted after 'else'
-rw-r--r--kde-emacs/kde-emacs-utils.el10
1 files changed, 6 insertions, 4 deletions
diff --git a/kde-emacs/kde-emacs-utils.el b/kde-emacs/kde-emacs-utils.el
index 1cf0e81..3135dfa 100644
--- a/kde-emacs/kde-emacs-utils.el
+++ b/kde-emacs/kde-emacs-utils.el
@@ -595,7 +595,7 @@ This function does not do any hidden buffer changes."
(if (not (c-in-literal))
(let ((n nil) (o nil)
(spacep nil) (c nil)
- (oneliner nil) (cxxlambda nil))
+ (oneliner nil) (cxxlambda nil) (elsekeyword nil))
(save-excursion
(save-excursion
(if (re-search-forward "[a-zA-Z]" (point-at-eol) t)
@@ -608,7 +608,7 @@ This function does not do any hidden buffer changes."
(setq o (looking-at "()"))
(forward-char 1)
(setq n (looking-at ")"))
- (if (and
+ (save-excursion (if (and
(not oneliner)
(not (eq
(count-lines (point-min) (point))
@@ -619,11 +619,13 @@ This function does not do any hidden buffer changes."
(if (re-search-forward "[a-zA-Z]" (point-at-eol) t)
(setq c (eq (car (car (c-guess-basic-syntax))) 'substatement)))
)
- )
+ ))
+ (forward-char -3)
+ (setq elsekeyword (looking-at "else"))
)
(setq cxxlambda (looking-back "\\[.*\\]\\s-*(.*)\\(\\s-*->.*\\)?\\s-*"))
(cond
- ((or n cxxlambda) (progn
+ ((or (or n elsekeyword) cxxlambda) (progn
(if (not spacep) (insert " "))
(self-insert-command (prefix-numeric-value arg))
(if (not c) (newline-and-indent))