diff options
author | Richard M. Stallman <rms@gnu.org> | 1994-08-06 21:22:51 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1994-08-06 21:22:51 +0000 |
commit | 62057cefc1ae55ad555bbeadea006ca951bf5b1b (patch) | |
tree | 2d60a446b3618a5ab53305861de9336dbd91a477 /lisp/progmodes/c-mode.el | |
parent | cb88b56ea9ea0a8c2e6ee5a2d61094d432ab93af (diff) | |
download | emacs-62057cefc1ae55ad555bbeadea006ca951bf5b1b.tar.gz |
(indent-c-exp): Preserve point when handling comments.
Diffstat (limited to 'lisp/progmodes/c-mode.el')
-rw-r--r-- | lisp/progmodes/c-mode.el | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el index a2478b6edfa..f3dadc81e81 100644 --- a/lisp/progmodes/c-mode.el +++ b/lisp/progmodes/c-mode.el @@ -1249,17 +1249,18 @@ If within a string or comment, move by sentences instead of statements." (indent-to this-indent))) ;; Indent any comment following the text. (or (looking-at comment-start-skip) - (let ((beg (point))) - (and (re-search-forward - comment-start-skip - (save-excursion (end-of-line) (point)) t) - ;; Make sure the comment starter we found - ;; is not actually in a string or quoted. - (let ((new-state - (parse-partial-sexp beg (point) - nil nil state))) - (and (not (nth 3 new-state)) (not (nth 5 new-state)))) - (progn (indent-for-comment) (beginning-of-line))))))))))) + (save-excursion + (let ((beg (point))) + (and (re-search-forward + comment-start-skip + (save-excursion (end-of-line) (point)) t) + ;; Make sure the comment starter we found + ;; is not actually in a string or quoted. + (let ((new-state + (parse-partial-sexp beg (point) + nil nil state))) + (and (not (nth 3 new-state)) (not (nth 5 new-state)))) + (indent-for-comment))))))))))) ;; Look at all comment-start strings in the current line after point. ;; Return t if one of them starts a real comment. |