]> git.eshelyaron.com Git - emacs.git/commitdiff
(c-electric-brace): Work around for a misfeature in `expand-abbrev'
authorMartin Stjernholm <mast@lysator.liu.se>
Tue, 26 Aug 2003 11:50:03 +0000 (11:50 +0000)
committerMartin Stjernholm <mast@lysator.liu.se>
Tue, 26 Aug 2003 11:50:03 +0000 (11:50 +0000)
which caused electric keywords like "else" to disappear if an open
brace was typed directly afterwards.

lisp/progmodes/cc-cmds.el

index f254cf6b061586f02c7f8f4b32c0fc1109fec9df..66da8b1e47eee6af6c396a6a01ac39492d354d69 100644 (file)
@@ -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 ?{)