aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-05-29 18:14:34 +0000
committerRichard M. Stallman1993-05-29 18:14:34 +0000
commit1e2d7ccea08bd60e5e9ac8eb36d2c2fdc650a306 (patch)
tree9fbbd8bcc62ff718ed4fa59331fad6a5da745fd6
parent47d319aaa867623804d35934ce33596afdeb151d (diff)
downloademacs-1e2d7ccea08bd60e5e9ac8eb36d2c2fdc650a306.tar.gz
emacs-1e2d7ccea08bd60e5e9ac8eb36d2c2fdc650a306.zip
(c-up-conditional): Handle commented-out #-cmds properly.
-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)))