mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-22 12:57:34 +00:00
(c-indent-region): Keep looping till reach endmark.
Treat #-lines specially.
This commit is contained in:
parent
94bd657324
commit
d52fd67cd1
1 changed files with 31 additions and 29 deletions
|
|
@ -1220,41 +1220,43 @@ If within a string or comment, move by sentences instead of statements."
|
|||
(beginning-of-line)
|
||||
(let ((endmark (copy-marker end))
|
||||
(c-tab-always-indent t))
|
||||
(while (and (bolp) (not (eolp)))
|
||||
(while (and (bolp) (not (eobp)) (< (point) endmark))
|
||||
;; Indent one line as with TAB.
|
||||
(let ((shift-amt (c-indent-line))
|
||||
nextline sexpbeg sexpend)
|
||||
(save-excursion
|
||||
;; Find beginning of following line.
|
||||
(if (save-excursion (beginning-of-line) (looking-at "[ \t]*#"))
|
||||
(forward-line 1)
|
||||
(save-excursion
|
||||
(forward-line 1) (setq nextline (point)))
|
||||
;; Find first beginning-of-sexp for sexp extending past this line.
|
||||
(beginning-of-line)
|
||||
(while (< (point) nextline)
|
||||
(condition-case nil
|
||||
;; Find beginning of following line.
|
||||
(save-excursion
|
||||
(forward-line 1) (setq nextline (point)))
|
||||
;; Find first beginning-of-sexp for sexp extending past this line.
|
||||
(beginning-of-line)
|
||||
(while (< (point) nextline)
|
||||
(condition-case nil
|
||||
(progn
|
||||
(forward-sexp 1)
|
||||
(setq sexpend (point-marker)))
|
||||
(error (setq sexpend nil)
|
||||
(goto-char nextline)))
|
||||
(skip-chars-forward " \t\n"))
|
||||
(if sexpend
|
||||
(progn
|
||||
(forward-sexp 1)
|
||||
(setq sexpend (point-marker)))
|
||||
(error (setq sexpend nil)
|
||||
(goto-char nextline)))
|
||||
(skip-chars-forward " \t\n"))
|
||||
(if sexpend
|
||||
;; Make sure the sexp we found really starts on the
|
||||
;; current line and extends past it.
|
||||
(goto-char sexpend)
|
||||
(backward-sexp 1)
|
||||
(setq sexpbeg (point)))))
|
||||
;; If that sexp ends within the region,
|
||||
;; indent it all at once, fast.
|
||||
(if (and sexpend (> sexpend nextline) (<= sexpend endmark)
|
||||
(< sexpbeg nextline))
|
||||
(progn
|
||||
;; Make sure the sexp we found really starts on the
|
||||
;; current line and extends past it.
|
||||
(goto-char sexpend)
|
||||
(backward-sexp 1)
|
||||
(setq sexpbeg (point)))))
|
||||
;; If that sexp ends within the region,
|
||||
;; indent it all at once, fast.
|
||||
(if (and sexpend (> sexpend nextline) (<= sexpend endmark)
|
||||
(< sexpbeg nextline))
|
||||
(progn
|
||||
(indent-c-exp)
|
||||
(goto-char sexpend)))
|
||||
;; Move to following line and try again.
|
||||
(and sexpend (set-marker sexpend nil))
|
||||
(forward-line 1)))
|
||||
(indent-c-exp)
|
||||
(goto-char sexpend)))
|
||||
;; Move to following line and try again.
|
||||
(and sexpend (set-marker sexpend nil))
|
||||
(forward-line 1))))
|
||||
(set-marker endmark nil))))
|
||||
|
||||
(defun set-c-style (style &optional global)
|
||||
|
|
|
|||
Loading…
Reference in a new issue