diff options
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 122 |
1 files changed, 63 insertions, 59 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index dbcd071da16..e22b98dbc4d 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -2313,30 +2313,32 @@ comment at the start of cc-engine.el for more info." | |||
| 2313 | ;; newer Emacsen only, the syntax of a position after a potential first char | 2313 | ;; newer Emacsen only, the syntax of a position after a potential first char |
| 2314 | ;; of a two char construct) of STATE are valid. | 2314 | ;; of a two char construct) of STATE are valid. |
| 2315 | (save-excursion | 2315 | (save-excursion |
| 2316 | (save-match-data | 2316 | (save-restriction |
| 2317 | (let* ((base-and-state (c-parse-ps-state-below here)) | 2317 | (widen) |
| 2318 | (base (car base-and-state)) | 2318 | (save-match-data |
| 2319 | (s (cdr base-and-state)) | 2319 | (let* ((base-and-state (c-parse-ps-state-below here)) |
| 2320 | (s (parse-partial-sexp base here nil nil s)) | 2320 | (base (car base-and-state)) |
| 2321 | ty) | 2321 | (s (cdr base-and-state)) |
| 2322 | (cond | 2322 | (s (parse-partial-sexp base here nil nil s)) |
| 2323 | ((or (nth 3 s) (nth 4 s)) ; in a string or comment | 2323 | ty) |
| 2324 | (setq ty (cond | 2324 | (cond |
| 2325 | ((nth 3 s) 'string) | 2325 | ((or (nth 3 s) (nth 4 s)) ; in a string or comment |
| 2326 | ((nth 7 s) 'c++) | 2326 | (setq ty (cond |
| 2327 | (t 'c))) | 2327 | ((nth 3 s) 'string) |
| 2328 | (list s ty (nth 8 s))) | 2328 | ((nth 7 s) 'c++) |
| 2329 | 2329 | (t 'c))) | |
| 2330 | ((and (not not-in-delimiter) ; inside a comment starter | 2330 | (list s ty (nth 8 s))) |
| 2331 | (not (bobp)) | 2331 | |
| 2332 | (progn (backward-char) | 2332 | ((and (not not-in-delimiter) ; inside a comment starter |
| 2333 | (and (not (and (memq 'category-properties c-emacs-features) | 2333 | (not (bobp)) |
| 2334 | (looking-at "\\s!"))) | 2334 | (progn (backward-char) |
| 2335 | (looking-at c-comment-start-regexp)))) | 2335 | (and (not (and (memq 'category-properties c-emacs-features) |
| 2336 | (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)) | 2336 | (looking-at "\\s!"))) |
| 2337 | (list s ty (point))) | 2337 | (looking-at c-comment-start-regexp)))) |
| 2338 | 2338 | (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)) | |
| 2339 | (t (list s))))))) | 2339 | (list s ty (point))) |
| 2340 | |||
| 2341 | (t (list s)))))))) | ||
| 2340 | 2342 | ||
| 2341 | (defun c-state-full-pp-to-literal (here &optional not-in-delimiter) | 2343 | (defun c-state-full-pp-to-literal (here &optional not-in-delimiter) |
| 2342 | ;; This function will supersede c-state-pp-to-literal. | 2344 | ;; This function will supersede c-state-pp-to-literal. |
| @@ -2357,38 +2359,40 @@ comment at the start of cc-engine.el for more info." | |||
| 2357 | ;; newer Emacsen only, the syntax of a position after a potential first char | 2359 | ;; newer Emacsen only, the syntax of a position after a potential first char |
| 2358 | ;; of a two char construct) of STATE are valid. | 2360 | ;; of a two char construct) of STATE are valid. |
| 2359 | (save-excursion | 2361 | (save-excursion |
| 2360 | (save-match-data | 2362 | (save-restriction |
| 2361 | (let* ((base-and-state (c-parse-ps-state-below here)) | 2363 | (widen) |
| 2362 | (base (car base-and-state)) | 2364 | (save-match-data |
| 2363 | (s (cdr base-and-state)) | 2365 | (let* ((base-and-state (c-parse-ps-state-below here)) |
| 2364 | (s (parse-partial-sexp base here nil nil s)) | 2366 | (base (car base-and-state)) |
| 2365 | ty start) | 2367 | (s (cdr base-and-state)) |
| 2366 | (cond | 2368 | (s (parse-partial-sexp base here nil nil s)) |
| 2367 | ((or (nth 3 s) (nth 4 s)) ; in a string or comment | 2369 | ty start) |
| 2368 | (setq ty (cond | 2370 | (cond |
| 2369 | ((nth 3 s) 'string) | 2371 | ((or (nth 3 s) (nth 4 s)) ; in a string or comment |
| 2370 | ((nth 7 s) 'c++) | 2372 | (setq ty (cond |
| 2371 | (t 'c))) | 2373 | ((nth 3 s) 'string) |
| 2372 | (setq start (nth 8 s)) | 2374 | ((nth 7 s) 'c++) |
| 2373 | (parse-partial-sexp here (point-max) | 2375 | (t 'c))) |
| 2374 | nil ; TARGETDEPTH | 2376 | (setq start (nth 8 s)) |
| 2375 | nil ; STOPBEFORE | 2377 | (parse-partial-sexp here (point-max) |
| 2376 | s ; OLDSTATE | 2378 | nil ; TARGETDEPTH |
| 2377 | 'syntax-table) ; stop at end of literal | 2379 | nil ; STOPBEFORE |
| 2378 | (list s ty (cons start (point)))) | 2380 | s ; OLDSTATE |
| 2379 | 2381 | 'syntax-table) ; stop at end of literal | |
| 2380 | ((and (not not-in-delimiter) ; inside a comment starter | 2382 | (list s ty (cons start (point)))) |
| 2381 | (not (bobp)) | 2383 | |
| 2382 | (progn (backward-char) | 2384 | ((and (not not-in-delimiter) ; inside a comment starter |
| 2383 | (and (not (and (memq 'category-properties c-emacs-features) | 2385 | (not (bobp)) |
| 2384 | (looking-at "\\s!"))) | 2386 | (progn (backward-char) |
| 2385 | (looking-at c-comment-start-regexp)))) | 2387 | (and (not (and (memq 'category-properties c-emacs-features) |
| 2386 | (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++) | 2388 | (looking-at "\\s!"))) |
| 2387 | start (point)) | 2389 | (looking-at c-comment-start-regexp)))) |
| 2388 | (forward-comment 1) | 2390 | (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++) |
| 2389 | (list s ty (cons start (point)))) | 2391 | start (point)) |
| 2390 | 2392 | (forward-comment 1) | |
| 2391 | (t (list s))))))) | 2393 | (list s ty (cons start (point)))) |
| 2394 | |||
| 2395 | (t (list s)))))))) | ||
| 2392 | 2396 | ||
| 2393 | (defsubst c-state-pp-to-literal (from to &optional not-in-delimiter) | 2397 | (defsubst c-state-pp-to-literal (from to &optional not-in-delimiter) |
| 2394 | ;; Do a parse-partial-sexp from FROM to TO, returning either | 2398 | ;; Do a parse-partial-sexp from FROM to TO, returning either |
| @@ -2492,9 +2496,9 @@ comment at the start of cc-engine.el for more info." | |||
| 2492 | ;; STATE are those concerning comments and strings; STATE is the state of a | 2496 | ;; STATE are those concerning comments and strings; STATE is the state of a |
| 2493 | ;; null `parse-partial-sexp' scan when CACHE-POS is not in a comment or | 2497 | ;; null `parse-partial-sexp' scan when CACHE-POS is not in a comment or |
| 2494 | ;; string. | 2498 | ;; string. |
| 2495 | (save-restriction | 2499 | (save-excursion |
| 2496 | (widen) | 2500 | (save-restriction |
| 2497 | (save-excursion | 2501 | (widen) |
| 2498 | (let ((c c-state-semi-nonlit-pos-cache) | 2502 | (let ((c c-state-semi-nonlit-pos-cache) |
| 2499 | elt state pos npos high-elt) | 2503 | elt state pos npos high-elt) |
| 2500 | ;; Trim the cache to take account of buffer changes. | 2504 | ;; Trim the cache to take account of buffer changes. |