[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f493a9b: CC Mode: fix c-where-wrt-brace-construct to cope with cl
From: |
Alan Mackenzie |
Subject: |
master f493a9b: CC Mode: fix c-where-wrt-brace-construct to cope with class declarations |
Date: |
Fri, 9 Apr 2021 16:55:11 -0400 (EDT) |
branch: master
commit f493a9bef46dc48f7282e296996186d6d8f77684
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>
CC Mode: fix c-where-wrt-brace-construct to cope with class declarations
Make the function correctly recognize a brace block preceded by an
introductory line without a parameter list.
* lisp/progmodes/cc-cmds.el (c-where-wrt-brace-contruct): Reintroduce the
use
of c-beginning-of-decl-1, which was removed some weeks ago, in place of a
c-syntactic-skip-backward. Reformulate the code generally.
---
lisp/progmodes/cc-cmds.el | 47 ++++++++++++++++++++++++++++++++---------------
1 file changed, 32 insertions(+), 15 deletions(-)
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 1754436..c894944 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -1639,7 +1639,8 @@ No indentation or other \"electric\" behavior is
performed."
;;
;; This function might do hidden buffer changes.
(save-excursion
- (let* (knr-start knr-res
+ (let* (kluge-start
+ knr-start knr-res
decl-result brace-decl-p
(start (point))
(paren-state (c-parse-state))
@@ -1670,12 +1671,20 @@ No indentation or other \"electric\" behavior is
performed."
(not (looking-at c-defun-type-name-decl-key))))))
'at-function-end)
(t
+ ;; Kluge so that c-beginning-of-decl-1 won't go back if we're already
+ ;; at a declaration.
+ (if (or (and (eolp) (not (eobp))) ; EOL is matched by "\\s>"
+ (not (c-looking-at-non-alphnumspace)))
+ (forward-char))
+ (setq kluge-start (point))
+
(if (and least-enclosing
(eq (char-after least-enclosing) ?\())
(c-go-list-forward least-enclosing))
(c-forward-syntactic-ws)
(setq knr-start (point))
- (if (c-syntactic-re-search-forward "{" nil t t)
+ (if (and (c-syntactic-re-search-forward "[;{]" nil t t)
+ (eq (char-before) ?\{))
(progn
(backward-char)
(cond
@@ -1689,19 +1698,27 @@ No indentation or other \"electric\" behavior is
performed."
((and knr-res
(goto-char knr-res)
(c-backward-syntactic-ws))) ; Always returns nil.
- ((and (eq (char-before) ?\))
- (c-go-list-backward))
- (c-syntactic-skip-backward "^;" start t)
- (if (eq (point) start)
- (if (progn (c-backward-syntactic-ws)
- (memq (char-before) '(?\; ?} nil)))
- (if (progn (c-forward-syntactic-ws)
- (eq (point) start))
- 'at-header
- 'outwith-function)
- 'in-header)
- 'outwith-function))
- (t 'outwith-function)))
+ (t
+ (when (eq (char-before) ?\))
+ ;; The `c-go-list-backward' is a precaution against
+ ;; `c-beginning-of-decl-1' spuriously finding a C++ lambda
+ ;; function inside the parentheses.
+ (c-go-list-backward))
+ (setq decl-result
+ (car (c-beginning-of-decl-1
+ (and least-enclosing
+ (c-safe-position
+ least-enclosing paren-state)))))
+ (cond
+ ((> (point) start)
+ 'outwith-function)
+ ((eq decl-result 'same)
+ (if (eq (point) start)
+ 'at-header
+ 'in-header))
+ (t (error
+ "c-where-wrt-brace-construct: c-beginning-of-decl-1
returned %s"
+ decl-result))))))
'outwith-function))))))
(defun c-backward-to-nth-BOF-{ (n where)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f493a9b: CC Mode: fix c-where-wrt-brace-construct to cope with class declarations,
Alan Mackenzie <=