diff options
Diffstat (limited to 'lisp/progmodes/cc-mode.el')
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index bf0439ffe8a..0bf89b9a36a 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -1539,6 +1539,21 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1539 | (setq new-pos capture-opener)) | 1539 | (setq new-pos capture-opener)) |
| 1540 | (and (/= new-pos pos) new-pos))) | 1540 | (and (/= new-pos pos) new-pos))) |
| 1541 | 1541 | ||
| 1542 | (defun c-fl-decl-end (pos) | ||
| 1543 | ;; If POS is inside a declarator, return the end of the token that follows | ||
| 1544 | ;; the declarator, otherwise return nil. | ||
| 1545 | (goto-char pos) | ||
| 1546 | (let ((lit-start (c-literal-start)) | ||
| 1547 | pos1) | ||
| 1548 | (if lit-start (goto-char lit-start)) | ||
| 1549 | (c-backward-syntactic-ws) | ||
| 1550 | (when (setq pos1 (c-on-identifier)) | ||
| 1551 | (goto-char pos1) | ||
| 1552 | (when (and (c-forward-declarator) | ||
| 1553 | (eq (c-forward-token-2) 0)) | ||
| 1554 | (c-backward-syntactic-ws) | ||
| 1555 | (point))))) | ||
| 1556 | |||
| 1542 | (defun c-change-expand-fl-region (_beg _end _old-len) | 1557 | (defun c-change-expand-fl-region (_beg _end _old-len) |
| 1543 | ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock | 1558 | ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock |
| 1544 | ;; region. This will usually be the smallest sequence of whole lines | 1559 | ;; region. This will usually be the smallest sequence of whole lines |
| @@ -1552,18 +1567,16 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1552 | (setq c-new-BEG | 1567 | (setq c-new-BEG |
| 1553 | (or (c-fl-decl-start c-new-BEG) (c-point 'bol c-new-BEG)) | 1568 | (or (c-fl-decl-start c-new-BEG) (c-point 'bol c-new-BEG)) |
| 1554 | c-new-END | 1569 | c-new-END |
| 1555 | (save-excursion | 1570 | (or (c-fl-decl-end c-new-END) |
| 1556 | (goto-char c-new-END) | 1571 | (c-point 'bonl (max (1- c-new-END) (point-min))))))) |
| 1557 | (if (bolp) | ||
| 1558 | (point) | ||
| 1559 | (c-point 'bonl c-new-END)))))) | ||
| 1560 | 1572 | ||
| 1561 | (defun c-context-expand-fl-region (beg end) | 1573 | (defun c-context-expand-fl-region (beg end) |
| 1562 | ;; Return a cons (NEW-BEG . NEW-END), where NEW-BEG is the beginning of a | 1574 | ;; Return a cons (NEW-BEG . NEW-END), where NEW-BEG is the beginning of a |
| 1563 | ;; "local" declaration containing BEG (see `c-fl-decl-start') or BOL BEG is | 1575 | ;; "local" declaration containing BEG (see `c-fl-decl-start') or BOL BEG is |
| 1564 | ;; in. NEW-END is beginning of the line after the one END is in. | 1576 | ;; in. NEW-END is beginning of the line after the one END is in. |
| 1565 | (cons (or (c-fl-decl-start beg) (c-point 'bol beg)) | 1577 | (c-save-buffer-state () |
| 1566 | (c-point 'bonl end))) | 1578 | (cons (or (c-fl-decl-start beg) (c-point 'bol beg)) |
| 1579 | (or (c-fl-decl-end end) (c-point 'bonl (1- end)))))) | ||
| 1567 | 1580 | ||
| 1568 | (defun c-before-context-fl-expand-region (beg end) | 1581 | (defun c-before-context-fl-expand-region (beg end) |
| 1569 | ;; Expand the region (BEG END) as specified by | 1582 | ;; Expand the region (BEG END) as specified by |