emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el [lexbind]
Date: Thu, 20 Nov 2003 19:36:40 -0500

Index: emacs/lisp/progmodes/cc-engine.el
diff -c emacs/lisp/progmodes/cc-engine.el:1.24.2.2 
emacs/lisp/progmodes/cc-engine.el:1.24.2.3
*** emacs/lisp/progmodes/cc-engine.el:1.24.2.2  Tue Oct 14 19:30:15 2003
--- emacs/lisp/progmodes/cc-engine.el   Thu Nov 20 19:35:50 2003
***************
*** 197,202 ****
--- 197,271 ----
  (make-variable-buffer-local 'c-type-decl-end-used)
  
  
+ ;; Basic handling of preprocessor directives.
+ 
+ ;; This is a dynamically bound cache used together with
+ ;; `c-query-macro-start' and `c-query-and-set-macro-start'.  It only
+ ;; works as long as point doesn't cross a macro boundary.
+ (defvar c-macro-start 'unknown)
+ 
+ (defsubst c-query-and-set-macro-start ()
+   ;; This function does not do any hidden buffer changes.
+   (if (symbolp c-macro-start)
+       (setq c-macro-start (save-excursion
+                           (and (c-beginning-of-macro)
+                                (point))))
+     c-macro-start))
+ 
+ (defsubst c-query-macro-start ()
+   ;; This function does not do any hidden buffer changes.
+   (if (symbolp c-macro-start)
+       (save-excursion
+       (and (c-beginning-of-macro)
+            (point)))
+     c-macro-start))
+ 
+ (defun c-beginning-of-macro (&optional lim)
+   "Go to the beginning of a preprocessor directive.
+ Leave point at the beginning of the directive and return t if in one,
+ otherwise return nil and leave point unchanged.
+ 
+ This function does not do any hidden buffer changes."
+   (when c-opt-cpp-prefix
+     (let ((here (point)))
+       (save-restriction
+       (if lim (narrow-to-region lim (point-max)))
+       (beginning-of-line)
+       (while (eq (char-before (1- (point))) ?\\)
+         (forward-line -1))
+       (back-to-indentation)
+       (if (and (<= (point) here)
+                (looking-at c-opt-cpp-start))
+           t
+         (goto-char here)
+         nil)))))
+ 
+ (defun c-end-of-macro ()
+   "Go to the end of a preprocessor directive.
+ More accurately, move point to the end of the closest following line
+ that doesn't end with a line continuation backslash.
+ 
+ This function does not do any hidden buffer changes."
+   (while (progn
+          (end-of-line)
+          (when (and (eq (char-before) ?\\)
+                     (not (eobp)))
+            (forward-char)
+            t))))
+ 
+ (defun c-forward-to-cpp-define-body ()
+   ;; Assuming point is at the "#" that introduces a preprocessor
+   ;; directive, it's moved forward to the start of the definition body
+   ;; if it's a "#define".  Non-nil is returned in this case, in all
+   ;; other cases nil is returned and point isn't moved.
+   (when (and (looking-at
+             (concat "#[ \t]*"
+                     "define[ \t]+\\(\\sw\\|_\\)+\\(\([^\)]*\)\\)?"
+                     "\\([ \t]\\|\\\\\n\\)*"))
+            (not (= (match-end 0) (c-point 'eol))))
+     (goto-char (match-end 0))))
+ 
+ 
  ;;; Basic utility functions.
  
  (defun c-syntactic-content (from to)
***************
*** 268,273 ****
--- 337,373 ----
  (defvar c-literal-faces
    '(font-lock-comment-face font-lock-string-face))
  
+ (defun c-shift-line-indentation (shift-amt)
+   ;; This function does not do any hidden buffer changes.
+   (let ((pos (- (point-max) (point)))
+       (c-macro-start c-macro-start)
+       tmp-char-inserted)
+     (if (zerop shift-amt)
+       nil
+       (when (and (c-query-and-set-macro-start)
+                (looking-at "[ \t]*\\\\$")
+                (save-excursion
+                  (skip-chars-backward " \t")
+                  (bolp)))
+       (insert ?x)
+       (backward-char)
+       (setq tmp-char-inserted t))
+       (unwind-protect
+         (let ((col (current-indentation)))
+           (delete-region (c-point 'bol) (c-point 'boi))
+           (beginning-of-line)
+           (indent-to (+ col shift-amt)))
+       (when tmp-char-inserted
+         (delete-char 1))))
+     ;; If initial point was within line's indentation and we're not on
+     ;; a line with a line continuation in a macro, position after the
+     ;; indentation.  Else stay at same point in text.
+     (if (and (< (point) (c-point 'boi))
+            (not tmp-char-inserted))
+       (back-to-indentation)
+       (if (> (- (point-max) pos) (point))
+         (goto-char (- (point-max) pos))))))
+ 
  
  ;; Some debug tools to visualize various special positions.  This
  ;; debug code isn't as portable as the rest of CC Mode.
***************
*** 592,598 ****
  
                ;; The PDA state handling.
                  ;;
!                 ;; Refer to the description of the PDA in the openining
                  ;; comments.  In the following OR form, the first leaf
                  ;; attempts to handles one of the specific actions detailed
                  ;; (e.g., finding token "if" whilst in state `else-boundary').
--- 692,698 ----
  
                ;; The PDA state handling.
                  ;;
!                 ;; Refer to the description of the PDA in the opening
                  ;; comments.  In the following OR form, the first leaf
                  ;; attempts to handles one of the specific actions detailed
                  ;; (e.g., finding token "if" whilst in state `else-boundary').
***************
*** 769,775 ****
                        sym 'boundary)
                  (throw 'loop t))) ; like a C "continue".  Analyze the next 
sexp.
  
!             (when (and (numberp c-maybe-labelp) (not ignore-labels))
                ;; c-crosses-statement-barrier-p has found a colon, so
                ;; we might be in a label now.
                (if (not after-labels-pos)
--- 869,877 ----
                        sym 'boundary)
                  (throw 'loop t))) ; like a C "continue".  Analyze the next 
sexp.
  
!             (when (and (numberp c-maybe-labelp)
!                        (not ignore-labels)
!                        (not (looking-at "\\s\(")))
                ;; c-crosses-statement-barrier-p has found a colon, so
                ;; we might be in a label now.
                (if (not after-labels-pos)
***************
*** 1012,1086 ****
                t))))))
  
  
- ;; Basic handling of preprocessor directives.
- 
- ;; This is a dynamically bound cache used together with
- ;; `c-query-macro-start' and `c-query-and-set-macro-start'.  It only
- ;; works as long as point doesn't cross a macro boundary.
- (defvar c-macro-start 'unknown)
- 
- (defsubst c-query-and-set-macro-start ()
-   ;; This function does not do any hidden buffer changes.
-   (if (symbolp c-macro-start)
-       (setq c-macro-start (save-excursion
-                           (and (c-beginning-of-macro)
-                                (point))))
-     c-macro-start))
- 
- (defsubst c-query-macro-start ()
-   ;; This function does not do any hidden buffer changes.
-   (if (symbolp c-macro-start)
-       (save-excursion
-       (and (c-beginning-of-macro)
-            (point)))
-     c-macro-start))
- 
- (defun c-beginning-of-macro (&optional lim)
-   "Go to the beginning of a preprocessor directive.
- Leave point at the beginning of the directive and return t if in one,
- otherwise return nil and leave point unchanged.
- 
- This function does not do any hidden buffer changes."
-   (when c-opt-cpp-prefix
-     (let ((here (point)))
-       (save-restriction
-       (if lim (narrow-to-region lim (point-max)))
-       (beginning-of-line)
-       (while (eq (char-before (1- (point))) ?\\)
-         (forward-line -1))
-       (back-to-indentation)
-       (if (and (<= (point) here)
-                (looking-at c-opt-cpp-start))
-           t
-         (goto-char here)
-         nil)))))
- 
- (defun c-end-of-macro ()
-   "Go to the end of a preprocessor directive.
- More accurately, move point to the end of the closest following line
- that doesn't end with a line continuation backslash.
- 
- This function does not do any hidden buffer changes."
-   (while (progn
-          (end-of-line)
-          (when (and (eq (char-before) ?\\)
-                     (not (eobp)))
-            (forward-char)
-            t))))
- 
- (defun c-forward-to-cpp-define-body ()
-   ;; Assuming point is at the "#" that introduces a preprocessor
-   ;; directive, it's moved forward to the start of the definition body
-   ;; if it's a "#define".  Non-nil is returned in this case, in all
-   ;; other cases nil is returned and point isn't moved.
-   (when (and (looking-at
-             (concat "#[ \t]*"
-                     "define[ \t]+\\(\\sw\\|_\\)+\\(\([^\)]*\)\\)?"
-                     "\\([ \t]\\|\\\\\n\\)*"))
-            (not (= (match-end 0) (c-point 'eol))))
-     (goto-char (match-end 0))))
- 
- 
  ;; Tools for skipping over syntactic whitespace.
  
  ;; The following functions use text properties to cache searches over
--- 1114,1119 ----
***************
*** 2451,2457 ****
                          (< check-pos
                             (save-excursion
                               (goto-char check-pos)
!                              (c-end-of-current-token last-token-end-pos)
                               (setq last-token-end-pos (point))))))
                 ;; Match inside a token.
                 (cond ((<= (point) bound)
--- 2484,2491 ----
                          (< check-pos
                             (save-excursion
                               (goto-char check-pos)
!                              (save-match-data
!                                (c-end-of-current-token last-token-end-pos))
                               (setq last-token-end-pos (point))))))
                 ;; Match inside a token.
                 (cond ((<= (point) bound)
***************
*** 2516,2524 ****
  i.e. don't stop at positions inside syntactic whitespace or string
  literals.  Preprocessor directives are also ignored, with the exception
  of the one that the point starts within, if any.  If LIMIT is given,
! it's assumed to be at a syntactically relevant position.
! 
! This function does not do any hidden buffer changes."
  
    (let ((start (point))
        ;; A list of syntactically relevant positions in descending
--- 2550,2556 ----
  i.e. don't stop at positions inside syntactic whitespace or string
  literals.  Preprocessor directives are also ignored, with the exception
  of the one that the point starts within, if any.  If LIMIT is given,
! it's assumed to be at a syntactically relevant position."
  
    (let ((start (point))
        ;; A list of syntactically relevant positions in descending
***************
*** 3351,3359 ****
  (defvar c-promote-possible-types nil)
  
  ;; Dynamically bound variable that instructs `c-forward-<>-arglist' to
! ;; not accept arglists that contain more than one argument.  It's used
! ;; to handle ambiguous cases like "foo (a < b, c > d)" better.
! (defvar c-disallow-comma-in-<>-arglists nil)
  
  ;; Dynamically bound variables that instructs `c-forward-name',
  ;; `c-forward-type' and `c-forward-<>-arglist' to record the ranges of
--- 3383,3402 ----
  (defvar c-promote-possible-types nil)
  
  ;; Dynamically bound variable that instructs `c-forward-<>-arglist' to
! ;; not accept arglists that contain binary operators.
! ;;
! ;; This is primarily used to handle C++ template arglists.  C++
! ;; disambiguates them by checking whether the preceding name is a
! ;; template or not.  We can't do that, so we assume it is a template
! ;; if it can be parsed as one.  That usually works well since
! ;; comparison expressions on the forms "a < b > c" or "a < b, c > d"
! ;; in almost all cases would be pointless.
! ;;
! ;; However, in function arglists, e.g. in "foo (a < b, c > d)", we
! ;; should let the comma separate the function arguments instead.  And
! ;; in a context where the value of the expression is taken, e.g. in
! ;; "if (a < b || c > d)", it's probably not a template.
! (defvar c-restricted-<>-arglists nil)
  
  ;; Dynamically bound variables that instructs `c-forward-name',
  ;; `c-forward-type' and `c-forward-<>-arglist' to record the ranges of
***************
*** 3494,3500 ****
             (eq (char-after) ?<)
             (c-forward-<>-arglist (c-keyword-member kwd-sym 'c-<>-type-kwds)
                                   (or c-record-type-identifiers
!                                      c-disallow-comma-in-<>-arglists)))
        (c-forward-syntactic-ws)
        (setq safe-pos (point)))
  
--- 3537,3543 ----
             (eq (char-after) ?<)
             (c-forward-<>-arglist (c-keyword-member kwd-sym 'c-<>-type-kwds)
                                   (or c-record-type-identifiers
!                                      c-restricted-<>-arglists)))
        (c-forward-syntactic-ws)
        (setq safe-pos (point)))
  
***************
*** 3543,3558 ****
    ;; necessary if the various side effects, e.g. recording of type
    ;; ranges, are important.  Setting REPARSE to t only applies
    ;; recursively to nested angle bracket arglists if
!   ;; `c-disallow-comma-in-<>-arglists' is set.
!   ;;
!   ;; This is primarily used in C++ to mark up template arglists.  C++
!   ;; disambiguates them by checking whether the preceding name is a
!   ;; template or not.  We can't do that, so we assume it is a template
!   ;; if it can be parsed as one.  This usually works well since
!   ;; comparison expressions on the forms "a < b > c" or "a < b, c > d"
!   ;; in almost all cases would be pointless.  Cases like function
!   ;; calls on the form "foo (a < b, c > d)" needs to be handled
!   ;; specially through the `c-disallow-comma-in-<>-arglists' variable.
  
    (let ((start (point))
        ;; If `c-record-type-identifiers' is set then activate
--- 3586,3592 ----
    ;; necessary if the various side effects, e.g. recording of type
    ;; ranges, are important.  Setting REPARSE to t only applies
    ;; recursively to nested angle bracket arglists if
!   ;; `c-restricted-<>-arglists' is set.
  
    (let ((start (point))
        ;; If `c-record-type-identifiers' is set then activate
***************
*** 3683,3693 ****
                        (forward-char)
                        t)
  
!                     ;; Note: This regexp exploits the match order in
!                     ;; \| so that "<>" is matched by "<" rather than
!                     ;; "[^>:-]>".
                      (c-syntactic-re-search-forward
!                      "[<;{},]\\|\\([^>:-]>\\)" nil 'move t t 1)
  
                      ;; If the arglist starter has lost its open paren
                      ;; syntax but not the closer, we won't find the
--- 3717,3734 ----
                        (forward-char)
                        t)
  
!                     ;; Note: These regexps exploit the match order in \| so
!                     ;; that "<>" is matched by "<" rather than "[^>:-]>".
                      (c-syntactic-re-search-forward
!                      (if c-restricted-<>-arglists
!                          ;; Stop on ',', '|', '&', '+' and '-' to catch
!                          ;; common binary operators that could be between
!                          ;; two comparison expressions "a<b" and "c>d".
!                          "[<;{},|&+-]\\|\\([^>:-]>\\)"
!                        ;; Otherwise we still stop on ',' to find the
!                        ;; argument start positions.
!                        "[<;{},]\\|\\([^>:-]>\\)")
!                      nil 'move t t 1)
  
                      ;; If the arglist starter has lost its open paren
                      ;; syntax but not the closer, we won't find the
***************
*** 3776,3782 ****
                                           (c-keyword-sym (match-string 1))
                                           'c-<>-type-kwds))
                                     (and reparse
!                                         c-disallow-comma-in-<>-arglists))))
                            )))
  
                        ;; It was not an angle bracket arglist.
--- 3817,3823 ----
                                           (c-keyword-sym (match-string 1))
                                           'c-<>-type-kwds))
                                     (and reparse
!                                         c-restricted-<>-arglists))))
                            )))
  
                        ;; It was not an angle bracket arglist.
***************
*** 3812,3818 ****
                  t)
  
                 ((and (eq (char-before) ?,)
!                      (not c-disallow-comma-in-<>-arglists))
                  ;; Just another argument.  Record the position.  The
                  ;; type check stuff that made us stop at it is at
                  ;; the top of the loop.
--- 3853,3859 ----
                  t)
  
                 ((and (eq (char-before) ?,)
!                      (not c-restricted-<>-arglists))
                  ;; Just another argument.  Record the position.  The
                  ;; type check stuff that made us stop at it is at
                  ;; the top of the loop.
***************
*** 3959,3965 ****
               (when (let ((c-record-type-identifiers nil)
                           (c-record-found-types nil))
                       (c-forward-<>-arglist
!                       nil c-disallow-comma-in-<>-arglists))
                 (c-forward-syntactic-ws)
                 (setq pos (point))
                 (if (and c-opt-identifier-concat-key
--- 4000,4006 ----
               (when (let ((c-record-type-identifiers nil)
                           (c-record-found-types nil))
                       (c-forward-<>-arglist
!                       nil c-restricted-<>-arglists))
                 (c-forward-syntactic-ws)
                 (setq pos (point))
                 (if (and c-opt-identifier-concat-key
***************
*** 4202,4208 ****
      (c-with-syntax-table c++-template-syntax-table
        (c-backward-token-2 0 t lim)
        (while (and (or (looking-at c-symbol-start)
!                     (looking-at "[<,]"))
                  (zerop (c-backward-token-2 1 t lim))))
        (skip-chars-forward "^:"))))
  
--- 4243,4249 ----
      (c-with-syntax-table c++-template-syntax-table
        (c-backward-token-2 0 t lim)
        (while (and (or (looking-at c-symbol-start)
!                     (looking-at "[<,]\\|::"))
                  (zerop (c-backward-token-2 1 t lim))))
        (skip-chars-forward "^:"))))
  
***************
*** 4326,4333 ****
    ;; position that bounds the backward search for the argument list.
    ;;
    ;; Note: A declaration level context is assumed; the test can return
!   ;; false positives for statements.  This test is even more easily
!   ;; fooled than `c-just-after-func-arglist-p'.
  
    (save-excursion
      (save-restriction
--- 4367,4373 ----
    ;; position that bounds the backward search for the argument list.
    ;;
    ;; Note: A declaration level context is assumed; the test can return
!   ;; false positives for statements.
  
    (save-excursion
      (save-restriction
***************
*** 4337,4349 ****
        ;; check that it's followed by some symbol before the next ';'
        ;; or '{'.  If it does, it's the header of the K&R argdecl we're
        ;; in.
!       (if lim (narrow-to-region lim (point)))
        (let ((outside-macro (not (c-query-macro-start)))
            paren-end)
  
        (catch 'done
!         (while (if (and (c-safe (setq paren-end
!                                       (c-down-list-backward (point))))
                          (eq (char-after paren-end) ?\)))
                     (progn
                       (goto-char (1+ paren-end))
--- 4377,4388 ----
        ;; check that it's followed by some symbol before the next ';'
        ;; or '{'.  If it does, it's the header of the K&R argdecl we're
        ;; in.
!       (if lim (narrow-to-region lim (c-point 'eol)))
        (let ((outside-macro (not (c-query-macro-start)))
            paren-end)
  
        (catch 'done
!         (while (if (and (setq paren-end (c-down-list-backward (point)))
                          (eq (char-after paren-end) ?\)))
                     (progn
                       (goto-char (1+ paren-end))
***************
*** 4354,4360 ****
        (and (progn
               (c-forward-syntactic-ws)
               (looking-at "\\w\\|\\s_"))
!            (c-safe (c-up-list-backward paren-end))
  
             (save-excursion
               ;; If it's a K&R declaration then we're now at the
--- 4393,4418 ----
        (and (progn
               (c-forward-syntactic-ws)
               (looking-at "\\w\\|\\s_"))
! 
!            (save-excursion
!              ;; The function header in a K&R declaration should only
!              ;; contain identifiers separated by comma.  It should
!              ;; also contain at least one identifier since there
!              ;; wouldn't be anything to declare in the K&R region
!              ;; otherwise.
!              (when (c-go-up-list-backward paren-end)
!                (forward-char)
!                (catch 'knr-ok
!                  (while t
!                    (c-forward-syntactic-ws)
!                    (if (or (looking-at c-known-type-key)
!                            (looking-at c-keywords-regexp))
!                        (throw 'knr-ok nil))
!                    (c-forward-token-2)
!                    (if (eq (char-after) ?,)
!                        (forward-char)
!                      (throw 'knr-ok (and (eq (char-after) ?\))
!                                          (= (point) paren-end))))))))
  
             (save-excursion
               ;; If it's a K&R declaration then we're now at the
***************
*** 4405,4428 ****
        (if start
          (goto-char start)))))
  
! (defun c-backward-to-decl-anchor (&optional lim)
    ;; Assuming point is at a brace that opens the block of a top level
    ;; declaration of some kind, move to the proper anchor point for
    ;; that block.
    (unless (= (point) (c-point 'boi))
!     ;; What we have below is actually an extremely stripped variant of
!     ;; c-beginning-of-statement-1.
!     (let ((pos (point)) c-maybe-labelp)
!       ;; Switch syntax table to avoid stopping at line continuations.
!       (save-restriction
!       (if lim (narrow-to-region lim (point-max)))
!       (while (and (progn
!                     (c-backward-syntactic-ws)
!                     (c-safe (goto-char (scan-sexps (point) -1)) t))
!                   (not (c-crosses-statement-barrier-p (point) pos))
!                   (not c-maybe-labelp))
!         (setq pos (point)))
!       (goto-char pos)))))
  
  (defun c-search-decl-header-end ()
    ;; Search forward for the end of the "header" of the current
--- 4463,4474 ----
        (if start
          (goto-char start)))))
  
! (defsubst c-backward-to-decl-anchor (&optional lim)
    ;; Assuming point is at a brace that opens the block of a top level
    ;; declaration of some kind, move to the proper anchor point for
    ;; that block.
    (unless (= (point) (c-point 'boi))
!     (c-beginning-of-statement-1 lim)))
  
  (defun c-search-decl-header-end ()
    ;; Search forward for the end of the "header" of the current
***************
*** 4619,4625 ****
        nil)))
  
  (defun c-beginning-of-member-init-list (&optional limit)
!   ;; Goes to the beginning of a member init list (i.e. just after the
    ;; ':') if inside one.  Returns t in that case, nil otherwise.
    (or limit
        (setq limit (point-min)))
--- 4665,4671 ----
        nil)))
  
  (defun c-beginning-of-member-init-list (&optional limit)
!   ;; Go to the beginning of a member init list (i.e. just after the
    ;; ':') if inside one.  Returns t in that case, nil otherwise.
    (or limit
        (setq limit (point-min)))
***************
*** 5196,5202 ****
                         (eq step-type 'label)
                         (/= savepos boi))
  
!                    (progn
                       ;; Current position might not be good enough;
                       ;; skip backward another statement.
                       (setq step-type (c-beginning-of-statement-1
--- 5242,5248 ----
                         (eq step-type 'label)
                         (/= savepos boi))
  
!                    (let ((save-step-type step-type))
                       ;; Current position might not be good enough;
                       ;; skip backward another statement.
                       (setq step-type (c-beginning-of-statement-1
***************
*** 5228,5241 ****
                           (c-add-syntax 'substatement nil))
  
                         (setq boi (c-point 'boi))
!                        (/= (point) savepos)))))
  
                (setq savepos (point)
                      at-comment nil))
              (setq at-comment nil)
  
!             (when (and (eq step-type 'same)
!                        containing-sexp)
                (goto-char containing-sexp)
  
                ;; Don't stop in the middle of a special brace list opener
--- 5274,5293 ----
                           (c-add-syntax 'substatement nil))
  
                         (setq boi (c-point 'boi))
!                        (if (= (point) savepos)
!                            (progn
!                              (setq step-type save-step-type)
!                              nil)
!                          t)))))
  
                (setq savepos (point)
                      at-comment nil))
              (setq at-comment nil)
  
!             (when (and containing-sexp
!                        (if (memq step-type '(nil same))
!                            (/= (point) boi)
!                          (eq step-type 'label)))
                (goto-char containing-sexp)
  
                ;; Don't stop in the middle of a special brace list opener
***************
*** 5395,5415 ****
  
         ;; CASE B.3: The body of a function declared inside a normal
         ;; block.  Can occur e.g. in Pike and when using gcc
!        ;; extensions.  Might also trigger it with some macros followed
!        ;; by blocks, and this gives sane indentation then too.
         ;; C.f. cases E, 16F and 17G.
         ((and (not (c-looking-at-bos))
             (eq (c-beginning-of-statement-1 containing-sexp nil nil t)
!                'same))
        (c-add-stmt-syntax 'defun-open nil t nil
                           containing-sexp paren-state))
  
!        ;; CASE B.4: Continued statement with block open.
         (t
!       (goto-char beg-of-same-or-containing-stmt)
!       (c-add-stmt-syntax 'statement-cont nil nil nil
!                          containing-sexp paren-state)
!       (c-add-syntax 'block-open))
         ))
  
       ;; CASE C: iostream insertion or extraction operator
--- 5447,5478 ----
  
         ;; CASE B.3: The body of a function declared inside a normal
         ;; block.  Can occur e.g. in Pike and when using gcc
!        ;; extensions, but watch out for macros followed by blocks.
         ;; C.f. cases E, 16F and 17G.
         ((and (not (c-looking-at-bos))
             (eq (c-beginning-of-statement-1 containing-sexp nil nil t)
!                'same)
!            (save-excursion
!              ;; Look for a type followed by a symbol, i.e. the start of a
!              ;; function declaration.  Doesn't work for declarations like
!              ;; "int *foo() ..."; we'd need to refactor the more competent
!              ;; analysis in `c-font-lock-declarations' for that.
!              (and (c-forward-type)
!                   (progn
!                     (c-forward-syntactic-ws)
!                     (looking-at c-symbol-start)))))
        (c-add-stmt-syntax 'defun-open nil t nil
                           containing-sexp paren-state))
  
!        ;; CASE B.4: Continued statement with block open.  The most
!        ;; accurate analysis is perhaps `statement-cont' together with
!        ;; `block-open' but we play DWIM and use `substatement-open'
!        ;; instead.  The rationaly is that this typically is a macro
!        ;; followed by a block which makes it very similar to a
!        ;; statement with a substatement block.
         (t
!       (c-add-stmt-syntax 'substatement-open nil nil nil
!                          containing-sexp paren-state))
         ))
  
       ;; CASE C: iostream insertion or extraction operator
***************
*** 5428,5435 ****
       ((and (save-excursion
             ;; Check that the next token is a '{'.  This works as
             ;; long as no language that allows nested function
!            ;; definitions doesn't allow stuff like member init
!            ;; lists, K&R declarations or throws clauses there.
             ;;
             ;; Note that we do a forward search for something ahead
             ;; of the indentation line here.  That's not good since
--- 5491,5498 ----
       ((and (save-excursion
             ;; Check that the next token is a '{'.  This works as
             ;; long as no language that allows nested function
!            ;; definitions allows stuff like member init lists, K&R
!            ;; declarations or throws clauses there.
             ;;
             ;; Note that we do a forward search for something ahead
             ;; of the indentation line here.  That's not good since
***************
*** 5440,5446 ****
             (eq (char-after) ?{))
           (not (c-looking-at-bos))
           (eq (c-beginning-of-statement-1 containing-sexp nil nil t)
!              'same))
        (c-add-stmt-syntax 'func-decl-cont nil t nil
                         containing-sexp paren-state))
  
--- 5503,5518 ----
             (eq (char-after) ?{))
           (not (c-looking-at-bos))
           (eq (c-beginning-of-statement-1 containing-sexp nil nil t)
!              'same)
!          (save-excursion
!            ;; Look for a type followed by a symbol, i.e. the start of a
!            ;; function declaration.  Doesn't work for declarations like "int
!            ;; *foo() ..."; we'd need to refactor the more competent analysis
!            ;; in `c-font-lock-declarations' for that.
!            (and (c-forward-type)
!                 (progn
!                   (c-forward-syntactic-ws)
!                   (looking-at c-symbol-start)))))
        (c-add-stmt-syntax 'func-decl-cont nil t nil
                         containing-sexp paren-state))
  
***************
*** 5852,5858 ****
              ;; should be relative to the ctor's indentation
              )
             ;; CASE 5B.2: K&R arg decl intro
!            (c-recognize-knr-p
              (c-beginning-of-statement-1 lim)
              (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
              (if inclass-p
--- 5924,5931 ----
              ;; should be relative to the ctor's indentation
              )
             ;; CASE 5B.2: K&R arg decl intro
!            ((and c-recognize-knr-p
!                  (c-in-knr-argdecl lim))
              (c-beginning-of-statement-1 lim)
              (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
              (if inclass-p
***************
*** 6493,6508 ****
                (c-add-syntax 'inline-close (point))))
             ;; CASE 16F: Can be a defun-close of a function declared
             ;; in a statement block, e.g. in Pike or when using gcc
!            ;; extensions.  Might also trigger it with some macros
!            ;; followed by blocks, and this gives sane indentation
!            ;; then too.  Let it through to be handled below.
             ;; C.f. cases B.3 and 17G.
             ((and (not inenclosing-p)
                   lim
                   (save-excursion
                     (and (not (c-looking-at-bos))
                          (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
!                         (setq placeholder (point)))))
              (back-to-indentation)
              (if (/= (point) containing-sexp)
                  (goto-char placeholder))
--- 6566,6589 ----
                (c-add-syntax 'inline-close (point))))
             ;; CASE 16F: Can be a defun-close of a function declared
             ;; in a statement block, e.g. in Pike or when using gcc
!            ;; extensions, but watch out for macros followed by
!            ;; blocks.  Let it through to be handled below.
             ;; C.f. cases B.3 and 17G.
             ((and (not inenclosing-p)
                   lim
                   (save-excursion
                     (and (not (c-looking-at-bos))
                          (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
!                         (setq placeholder (point))
!                         ;; Look for a type or identifier followed by a
!                         ;; symbol, i.e. the start of a function declaration.
!                         ;; Doesn't work for declarations like "int *foo()
!                         ;; ..."; we'd need to refactor the more competent
!                         ;; analysis in `c-font-lock-declarations' for that.
!                         (c-forward-type)
!                         (progn
!                           (c-forward-syntactic-ws)
!                           (looking-at c-symbol-start)))))
              (back-to-indentation)
              (if (/= (point) containing-sexp)
                  (goto-char placeholder))
***************
*** 6627,6639 ****
            (c-add-syntax 'defun-block-intro (point)))
           ;; CASE 17G: First statement in a function declared inside
           ;; a normal block.  This can occur in Pike and with
!          ;; e.g. the gcc extensions.  Might also trigger it with
!          ;; some macros followed by blocks, and this gives sane
!          ;; indentation then too.  C.f. cases B.3 and 16F.
           ((save-excursion
              (and (not (c-looking-at-bos))
                   (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
!                  (setq placeholder (point))))
            (back-to-indentation)
            (if (/= (point) containing-sexp)
                (goto-char placeholder))
--- 6708,6728 ----
            (c-add-syntax 'defun-block-intro (point)))
           ;; CASE 17G: First statement in a function declared inside
           ;; a normal block.  This can occur in Pike and with
!          ;; e.g. the gcc extensions, but watch out for macros
!          ;; followed by blocks.  C.f. cases B.3 and 16F.
           ((save-excursion
              (and (not (c-looking-at-bos))
                   (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
!                  (setq placeholder (point))
!                  ;; Look for a type or identifier followed by a
!                  ;; symbol, i.e. the start of a function declaration.
!                  ;; Doesn't work for declarations like "int *foo()
!                  ;; ..."; we'd need to refactor the more competent
!                  ;; analysis in `c-font-lock-declarations' for that.
!                  (c-forward-type)
!                  (progn
!                    (c-forward-syntactic-ws)
!                    (looking-at c-symbol-start))))
            (back-to-indentation)
            (if (/= (point) containing-sexp)
                (goto-char placeholder))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]