Function: semantic-c-skip-conditional-section
semantic-c-skip-conditional-section is a byte-compiled function
defined in c.el.gz.
Signature
(semantic-c-skip-conditional-section)
Documentation
Skip one section of a conditional.
Moves forward to a matching #elif, #else, or #endif. Moves completely over balanced #if blocks.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/bovine/c.el.gz
(defun semantic-c-skip-conditional-section ()
"Skip one section of a conditional.
Moves forward to a matching #elif, #else, or #endif.
Moves completely over balanced #if blocks."
(require 'cc-cmds)
(let ((done nil))
;; (if (looking-at "^\\s-*#if")
;; (semantic-lex-spp-push-if (point))
(end-of-line)
(while (and semantic-c-obey-conditional-section-parsing-flag
(and (not done)
(re-search-forward
"^\\s-*#\\s-*\\(if\\(n?def\\)?\\|el\\(if\\|se\\)\\|endif\\)\\>"
nil t)))
(goto-char (match-beginning 0))
(cond
((looking-at "^\\s-*#\\s-*if")
;; We found a nested if. Skip it.
(if (fboundp 'c-scan-conditionals)
(goto-char (c-scan-conditionals 1))
;; For older Emacsen, but this will set the mark.
(c-forward-conditional 1)))
((looking-at "^\\s-*#\\s-*elif")
;; We need to let the preprocessor analyze this one.
(beginning-of-line)
(setq done t)
)
((looking-at "^\\s-*#\\s-*\\(endif\\|else\\)\\>")
;; We are at the end. Pop our state.
;; (semantic-lex-spp-pop-if)
;; Note: We include ELSE and ENDIF the same. If skip some previous
;; section, then we should do the else by default, making it much
;; like the endif.
(end-of-line)
(forward-char 1)
(setq done t))
(t
;; We found an elif. Stop here.
(setq done t))))))