diff options
author | Richard M. Stallman <rms@gnu.org> | 1993-07-21 08:44:36 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1993-07-21 08:44:36 +0000 |
commit | 027816778c5a55cd8ba27a42331962abde5a6b9a (patch) | |
tree | fe9f219a82fcc9d20b69745bbc7df5f2282821da /lisp/progmodes/c-mode.el | |
parent | 72d57950059e0bd99782598285ad3f636c4c385b (diff) | |
download | emacs-027816778c5a55cd8ba27a42331962abde5a6b9a.tar.gz |
(indent-c-exp): If ENDPOS, always set OPOINT
to the function start. And don'tindet a line which is past ENDPOS.
Don't indent a comment on the first line if it's the only
thing on that line.
Diffstat (limited to 'lisp/progmodes/c-mode.el')
-rw-r--r-- | lisp/progmodes/c-mode.el | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el index b52f9fa68de..667f1d174e9 100644 --- a/lisp/progmodes/c-mode.el +++ b/lisp/progmodes/c-mode.el @@ -969,13 +969,15 @@ ENDPOS is encountered." (save-excursion (forward-char 1) (beginning-of-defun) (setq funbeg (point))) + (setq opoint funbeg) ;; Try to find containing open, ;; but don't scan past that fcn-start. (save-restriction (narrow-to-region funbeg (point)) (condition-case nil (save-excursion - (backward-up-list 1) (point)) + (backward-up-list 1) + (point)) ;; We gave up: must be between fcns. ;; Set opoint to beg of prev fcn ;; since otherwise calculate-c-indent @@ -998,6 +1000,12 @@ ENDPOS is encountered." (and (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t) + ;; Make sure this isn't a comment alone on a line + ;; (which should be indented like code instead). + (save-excursion + (goto-char (match-beginning 0)) + (skip-chars-backward " \t") + (not (bolp))) ;; Make sure the comment starter we found ;; is not actually in a string or quoted. (let ((new-state @@ -1060,7 +1068,12 @@ ENDPOS is encountered." (point))))) (forward-line 1) (skip-chars-forward " \t") - (if (eolp) + ;; Don't really reindent if the line is just whitespace, + ;; or if it is past the endpos. + ;; (The exit test in the outer while + ;; does not exit until we have passed the first line + ;; past the region.) + (if (or (eolp) (and endpos (>= (point) endpos))) nil (if (and (car indent-stack) (>= (car indent-stack) 0)) |