diff options
| author | Richard M. Stallman | 1993-07-21 08:44:36 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-07-21 08:44:36 +0000 |
| commit | 9ce49c8d7741df95faec6bf7c1ecb4d411d79dc1 (patch) | |
| tree | cddd5b5fbcbd13bce16fda9fbfb2c0d2caa240f0 /lisp/progmodes | |
| parent | f767385c90ecd380ac86e29c3fc8f83c6d15bf5a (diff) | |
| download | emacs-9ce49c8d7741df95faec6bf7c1ecb4d411d79dc1.tar.gz emacs-9ce49c8d7741df95faec6bf7c1ecb4d411d79dc1.zip | |
(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')
| -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." | |||
| 969 | (save-excursion (forward-char 1) | 969 | (save-excursion (forward-char 1) |
| 970 | (beginning-of-defun) | 970 | (beginning-of-defun) |
| 971 | (setq funbeg (point))) | 971 | (setq funbeg (point))) |
| 972 | (setq opoint funbeg) | ||
| 972 | ;; Try to find containing open, | 973 | ;; Try to find containing open, |
| 973 | ;; but don't scan past that fcn-start. | 974 | ;; but don't scan past that fcn-start. |
| 974 | (save-restriction | 975 | (save-restriction |
| 975 | (narrow-to-region funbeg (point)) | 976 | (narrow-to-region funbeg (point)) |
| 976 | (condition-case nil | 977 | (condition-case nil |
| 977 | (save-excursion | 978 | (save-excursion |
| 978 | (backward-up-list 1) (point)) | 979 | (backward-up-list 1) |
| 980 | (point)) | ||
| 979 | ;; We gave up: must be between fcns. | 981 | ;; We gave up: must be between fcns. |
| 980 | ;; Set opoint to beg of prev fcn | 982 | ;; Set opoint to beg of prev fcn |
| 981 | ;; since otherwise calculate-c-indent | 983 | ;; since otherwise calculate-c-indent |
| @@ -998,6 +1000,12 @@ ENDPOS is encountered." | |||
| 998 | (and (re-search-forward | 1000 | (and (re-search-forward |
| 999 | comment-start-skip | 1001 | comment-start-skip |
| 1000 | (save-excursion (end-of-line) (point)) t) | 1002 | (save-excursion (end-of-line) (point)) t) |
| 1003 | ;; Make sure this isn't a comment alone on a line | ||
| 1004 | ;; (which should be indented like code instead). | ||
| 1005 | (save-excursion | ||
| 1006 | (goto-char (match-beginning 0)) | ||
| 1007 | (skip-chars-backward " \t") | ||
| 1008 | (not (bolp))) | ||
| 1001 | ;; Make sure the comment starter we found | 1009 | ;; Make sure the comment starter we found |
| 1002 | ;; is not actually in a string or quoted. | 1010 | ;; is not actually in a string or quoted. |
| 1003 | (let ((new-state | 1011 | (let ((new-state |
| @@ -1060,7 +1068,12 @@ ENDPOS is encountered." | |||
| 1060 | (point))))) | 1068 | (point))))) |
| 1061 | (forward-line 1) | 1069 | (forward-line 1) |
| 1062 | (skip-chars-forward " \t") | 1070 | (skip-chars-forward " \t") |
| 1063 | (if (eolp) | 1071 | ;; Don't really reindent if the line is just whitespace, |
| 1072 | ;; or if it is past the endpos. | ||
| 1073 | ;; (The exit test in the outer while | ||
| 1074 | ;; does not exit until we have passed the first line | ||
| 1075 | ;; past the region.) | ||
| 1076 | (if (or (eolp) (and endpos (>= (point) endpos))) | ||
| 1064 | nil | 1077 | nil |
| 1065 | (if (and (car indent-stack) | 1078 | (if (and (car indent-stack) |
| 1066 | (>= (car indent-stack) 0)) | 1079 | (>= (car indent-stack) 0)) |