aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/c-mode.el35
1 files changed, 18 insertions, 17 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el
index a9aab352c7b..ec4b2c646ab 100644
--- a/lisp/progmodes/c-mode.el
+++ b/lisp/progmodes/c-mode.el
@@ -1271,24 +1271,25 @@ When going forwards, `#elif' is ignored."
1271 ;; the regexp matcher. 1271 ;; the regexp matcher.
1272 (funcall search-function 1272 (funcall search-function
1273 "#[ \t]*\\(if\\|elif\\|endif\\)" 1273 "#[ \t]*\\(if\\|elif\\|endif\\)"
1274 nil t) 1274 nil t))
1275 (progn
1276 (beginning-of-line)
1277 (looking-at "^[ \t]*#[ \t]*\\(if\\|elif\\|endif\\)")))
1278 ;; Update depth according to what we found.
1279 (beginning-of-line) 1275 (beginning-of-line)
1280 (cond ((looking-at "[ \t]*#[ \t]*endif") 1276 ;; Now verify it is really a preproc line.
1281 (setq depth (+ depth increment))) 1277 (if (looking-at "^[ \t]*#[ \t]*\\(if\\|elif\\|endif\\)")
1282 ((looking-at "[ \t]*#[ \t]*elif") 1278 (progn
1283 (if (and forward (= depth 0)) 1279 ;; Update depth according to what we found.
1284 (setq found (point)))) 1280 (beginning-of-line)
1285 (t (setq depth (- depth increment)))) 1281 (cond ((looking-at "[ \t]*#[ \t]*endif")
1286 ;; If this line exits a level of conditional, exit inner loop. 1282 (setq depth (+ depth increment)))
1287 (if (< depth 0) 1283 ((looking-at "[ \t]*#[ \t]*elif")
1288 (setq found (point))) 1284 (if (and forward (= depth 0))
1289 ;; When searching forward, start from end of line 1285 (setq found (point))))
1290 ;; so that we don't find the same line again. 1286 (t (setq depth (- depth increment))))
1291 (if forward (end-of-line)))) 1287 ;; If this line exits a level of conditional, exit inner loop.
1288 (if (< depth 0)
1289 (setq found (point)))
1290 ;; When searching forward, start from end of line
1291 ;; so that we don't find the same line again.
1292 (if forward (end-of-line))))))
1292 (or found 1293 (or found
1293 (error "No containing preprocessor conditional")) 1294 (error "No containing preprocessor conditional"))
1294 (goto-char (setq new found))) 1295 (goto-char (setq new found)))