Skip to content

Commit

Permalink
indent-cpp-directive でマクロがインデントしていた場合に対応. #194
Browse files Browse the repository at this point in the history
  • Loading branch information
x022235 committed Apr 7, 2012
1 parent 700dc0e commit 59432c4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lisp/c-mode.l
Expand Up @@ -132,29 +132,28 @@
(defun indent-cpp-directive ()
(interactive)
(save-excursion
(let ((column 1))
(let ((nest 0))
(goto-char (point-min))
(while (scan-buffer "^#" :regexp t)
(forward-char 1)
(while (scan-buffer "^[ \t]*#" :regexp t :tail t)
(cond ((looking-at "[ \t]*if")
(cpp-indent-to column)
(setq column (1+ column)))
(cpp-indent-to (+ (current-column) nest))
(incf nest))
((looking-at "[ \t]*el\\(se\\|if\\)")
(cpp-indent-to (1- column)))
(cpp-indent-to (+ (current-column) (1- nest))))
((looking-at "[ \t]*endif")
(setq column (1- column))
(when (zerop column)
(decf nest)
(when (minusp nest)
(error "Unmatched \"#endif\" at line ~d" (current-line-number)))
(cpp-indent-to column))
(t (cpp-indent-to column)
(cpp-indent-to (+ (current-column) nest)))
(t (cpp-indent-to (+ (current-column) nest))
(if (looking-for "define")
(while (and (progn
(goto-eol)
(forward-char -1)
(looking-for "\\"))
(forward-line 1))
(c-indent-line))))))
(when (/= column 1)
(when (/= nest 0)
(error "Unmatched \"#if\" or \"#ifdef\""))))
t)

Expand Down

0 comments on commit 59432c4

Please sign in to comment.