summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-cmds.el
diff options
context:
space:
mode:
authorMartin Stjernholm <mast@lysator.liu.se>2003-08-26 11:50:03 +0000
committerMartin Stjernholm <mast@lysator.liu.se>2003-08-26 11:50:03 +0000
commit0b966e89b353095562e29a4af5dff49e70c3a822 (patch)
tree185d78588a49b71aef8cf770eea3e39bdb53016f /lisp/progmodes/cc-cmds.el
parent4036ed8363b5a03b47d8a5dfd8243cdc41f154a8 (diff)
downloademacs-0b966e89b353095562e29a4af5dff49e70c3a822.tar.gz
(c-electric-brace): Work around for a misfeature in `expand-abbrev'
which caused electric keywords like "else" to disappear if an open brace was typed directly afterwards.
Diffstat (limited to 'lisp/progmodes/cc-cmds.el')
-rw-r--r--lisp/progmodes/cc-cmds.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index f254cf6b061..66da8b1e47e 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -498,10 +498,19 @@ This function does various newline cleanups based on the value of
(when (save-excursion
(skip-chars-backward " \t")
(not (bolp)))
- (setq delete-temp-newline
- (list (point-marker)))
(c-newline-and-indent)
- (setcdr delete-temp-newline (point-marker)))
+ ;; Set markers around the newline and indention inserted
+ ;; above. We insert the start marker here and not before
+ ;; the call to kludge around a misfeature in expand-abbrev:
+ ;; If the line contains e.g. "else" then expand-abbrev will
+ ;; be called when c-newline-and-indent inserts the newline.
+ ;; That function first removes the abbrev "else" and then
+ ;; inserts the expansion, which is an identical "else" in
+ ;; this case. So the marker that we put after "else" would
+ ;; end up before it.
+ (setq delete-temp-newline
+ (cons (copy-marker (c-point 'eopl) t)
+ (point-marker))))
(unwind-protect
(progn
(if (eq last-command-char ?{)