diff options
| author | Alan Mackenzie | 2011-03-06 16:57:31 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2011-03-06 16:57:31 +0000 |
| commit | 9d1f0f559d5331f6ace4feab5ac3e7c2932949a5 (patch) | |
| tree | b92964294166122e1f63d57f666436c1cf884d66 | |
| parent | 120d9389bf24bd04e6eb25e52a8b43faeb77dad4 (diff) | |
| download | emacs-9d1f0f559d5331f6ace4feab5ac3e7c2932949a5.tar.gz emacs-9d1f0f559d5331f6ace4feab5ac3e7c2932949a5.zip | |
progmodes/cc-engine.el (c-guess-basic-syntax): Reindent.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 2720 |
2 files changed, 1364 insertions, 1360 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e34fde79543..75c1818b24d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2011-03-06 Alan Mackenzie <acm@muc.de> | ||
| 2 | |||
| 3 | * progmodes/cc-engine.el (c-guess-basic-syntax): Reindent. | ||
| 4 | |||
| 1 | 2011-03-06 Jay Belanger <jay.p.belanger@gmail.com> | 5 | 2011-03-06 Jay Belanger <jay.p.belanger@gmail.com> |
| 2 | 6 | ||
| 3 | * calc/calc-ext.el (calc-init-extensions): | 7 | * calc/calc-ext.el (calc-init-extensions): |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 654323e03e4..e84ea3c1dcd 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -8725,841 +8725,841 @@ comment at the start of cc-engine.el for more info." | |||
| 8725 | (defun c-guess-basic-syntax () | 8725 | (defun c-guess-basic-syntax () |
| 8726 | "Return the syntactic context of the current line." | 8726 | "Return the syntactic context of the current line." |
| 8727 | (save-excursion | 8727 | (save-excursion |
| 8728 | (beginning-of-line) | 8728 | (beginning-of-line) |
| 8729 | (c-save-buffer-state | 8729 | (c-save-buffer-state |
| 8730 | ((indent-point (point)) | 8730 | ((indent-point (point)) |
| 8731 | (case-fold-search nil) | 8731 | (case-fold-search nil) |
| 8732 | ;; A whole ugly bunch of various temporary variables. Have | 8732 | ;; A whole ugly bunch of various temporary variables. Have |
| 8733 | ;; to declare them here since it's not possible to declare | 8733 | ;; to declare them here since it's not possible to declare |
| 8734 | ;; a variable with only the scope of a cond test and the | 8734 | ;; a variable with only the scope of a cond test and the |
| 8735 | ;; following result clauses, and most of this function is a | 8735 | ;; following result clauses, and most of this function is a |
| 8736 | ;; single gigantic cond. :P | 8736 | ;; single gigantic cond. :P |
| 8737 | literal char-before-ip before-ws-ip char-after-ip macro-start | 8737 | literal char-before-ip before-ws-ip char-after-ip macro-start |
| 8738 | in-macro-expr c-syntactic-context placeholder c-in-literal-cache | 8738 | in-macro-expr c-syntactic-context placeholder c-in-literal-cache |
| 8739 | step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos | 8739 | step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos |
| 8740 | containing-< | 8740 | containing-< |
| 8741 | ;; The following record some positions for the containing | 8741 | ;; The following record some positions for the containing |
| 8742 | ;; declaration block if we're directly within one: | 8742 | ;; declaration block if we're directly within one: |
| 8743 | ;; `containing-decl-open' is the position of the open | 8743 | ;; `containing-decl-open' is the position of the open |
| 8744 | ;; brace. `containing-decl-start' is the start of the | 8744 | ;; brace. `containing-decl-start' is the start of the |
| 8745 | ;; declaration. `containing-decl-kwd' is the keyword | 8745 | ;; declaration. `containing-decl-kwd' is the keyword |
| 8746 | ;; symbol of the keyword that tells what kind of block it | 8746 | ;; symbol of the keyword that tells what kind of block it |
| 8747 | ;; is. | 8747 | ;; is. |
| 8748 | containing-decl-open | 8748 | containing-decl-open |
| 8749 | containing-decl-start | 8749 | containing-decl-start |
| 8750 | containing-decl-kwd | 8750 | containing-decl-kwd |
| 8751 | ;; The open paren of the closest surrounding sexp or nil if | 8751 | ;; The open paren of the closest surrounding sexp or nil if |
| 8752 | ;; there is none. | 8752 | ;; there is none. |
| 8753 | containing-sexp | 8753 | containing-sexp |
| 8754 | ;; The position after the closest preceding brace sexp | 8754 | ;; The position after the closest preceding brace sexp |
| 8755 | ;; (nested sexps are ignored), or the position after | 8755 | ;; (nested sexps are ignored), or the position after |
| 8756 | ;; `containing-sexp' if there is none, or (point-min) if | 8756 | ;; `containing-sexp' if there is none, or (point-min) if |
| 8757 | ;; `containing-sexp' is nil. | 8757 | ;; `containing-sexp' is nil. |
| 8758 | lim | 8758 | lim |
| 8759 | ;; The paren state outside `containing-sexp', or at | 8759 | ;; The paren state outside `containing-sexp', or at |
| 8760 | ;; `indent-point' if `containing-sexp' is nil. | 8760 | ;; `indent-point' if `containing-sexp' is nil. |
| 8761 | (paren-state (c-parse-state)) | 8761 | (paren-state (c-parse-state)) |
| 8762 | ;; There's always at most one syntactic element which got | 8762 | ;; There's always at most one syntactic element which got |
| 8763 | ;; an anchor pos. It's stored in syntactic-relpos. | 8763 | ;; an anchor pos. It's stored in syntactic-relpos. |
| 8764 | syntactic-relpos | 8764 | syntactic-relpos |
| 8765 | (c-stmt-delim-chars c-stmt-delim-chars)) | 8765 | (c-stmt-delim-chars c-stmt-delim-chars)) |
| 8766 | 8766 | ||
| 8767 | ;; Check if we're directly inside an enclosing declaration | 8767 | ;; Check if we're directly inside an enclosing declaration |
| 8768 | ;; level block. | 8768 | ;; level block. |
| 8769 | (when (and (setq containing-sexp | 8769 | (when (and (setq containing-sexp |
| 8770 | (c-most-enclosing-brace paren-state)) | 8770 | (c-most-enclosing-brace paren-state)) |
| 8771 | (progn | 8771 | (progn |
| 8772 | (goto-char containing-sexp) | 8772 | (goto-char containing-sexp) |
| 8773 | (eq (char-after) ?{)) | 8773 | (eq (char-after) ?{)) |
| 8774 | (setq placeholder | 8774 | (setq placeholder |
| 8775 | (c-looking-at-decl-block | 8775 | (c-looking-at-decl-block |
| 8776 | (c-most-enclosing-brace paren-state | 8776 | (c-most-enclosing-brace paren-state |
| 8777 | containing-sexp) | 8777 | containing-sexp) |
| 8778 | t))) | 8778 | t))) |
| 8779 | (setq containing-decl-open containing-sexp | 8779 | (setq containing-decl-open containing-sexp |
| 8780 | containing-decl-start (point) | 8780 | containing-decl-start (point) |
| 8781 | containing-sexp nil) | 8781 | containing-sexp nil) |
| 8782 | (goto-char placeholder) | 8782 | (goto-char placeholder) |
| 8783 | (setq containing-decl-kwd (and (looking-at c-keywords-regexp) | 8783 | (setq containing-decl-kwd (and (looking-at c-keywords-regexp) |
| 8784 | (c-keyword-sym (match-string 1))))) | 8784 | (c-keyword-sym (match-string 1))))) |
| 8785 | 8785 | ||
| 8786 | ;; Init some position variables. | 8786 | ;; Init some position variables. |
| 8787 | (if c-state-cache | 8787 | (if c-state-cache |
| 8788 | (progn | 8788 | (progn |
| 8789 | (setq containing-sexp (car paren-state) | 8789 | (setq containing-sexp (car paren-state) |
| 8790 | paren-state (cdr paren-state)) | 8790 | paren-state (cdr paren-state)) |
| 8791 | (if (consp containing-sexp) | 8791 | (if (consp containing-sexp) |
| 8792 | (progn | 8792 | (progn |
| 8793 | (setq lim (cdr containing-sexp)) | 8793 | (setq lim (cdr containing-sexp)) |
| 8794 | (if (cdr c-state-cache) | 8794 | (if (cdr c-state-cache) |
| 8795 | ;; Ignore balanced paren. The next entry | 8795 | ;; Ignore balanced paren. The next entry |
| 8796 | ;; can't be another one. | 8796 | ;; can't be another one. |
| 8797 | (setq containing-sexp (car (cdr c-state-cache)) | 8797 | (setq containing-sexp (car (cdr c-state-cache)) |
| 8798 | paren-state (cdr paren-state)) | 8798 | paren-state (cdr paren-state)) |
| 8799 | ;; If there is no surrounding open paren then | 8799 | ;; If there is no surrounding open paren then |
| 8800 | ;; put the last balanced pair back on paren-state. | 8800 | ;; put the last balanced pair back on paren-state. |
| 8801 | (setq paren-state (cons containing-sexp paren-state) | 8801 | (setq paren-state (cons containing-sexp paren-state) |
| 8802 | containing-sexp nil))) | 8802 | containing-sexp nil))) |
| 8803 | (setq lim (1+ containing-sexp)))) | 8803 | (setq lim (1+ containing-sexp)))) |
| 8804 | (setq lim (point-min))) | 8804 | (setq lim (point-min))) |
| 8805 | 8805 | ||
| 8806 | ;; If we're in a parenthesis list then ',' delimits the | 8806 | ;; If we're in a parenthesis list then ',' delimits the |
| 8807 | ;; "statements" rather than being an operator (with the | 8807 | ;; "statements" rather than being an operator (with the |
| 8808 | ;; exception of the "for" clause). This difference is | 8808 | ;; exception of the "for" clause). This difference is |
| 8809 | ;; typically only noticeable when statements are used in macro | 8809 | ;; typically only noticeable when statements are used in macro |
| 8810 | ;; arglists. | 8810 | ;; arglists. |
| 8811 | (when (and containing-sexp | 8811 | (when (and containing-sexp |
| 8812 | (eq (char-after containing-sexp) ?\()) | 8812 | (eq (char-after containing-sexp) ?\()) |
| 8813 | (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) | 8813 | (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) |
| 8814 | ;; cache char before and after indent point, and move point to | 8814 | ;; cache char before and after indent point, and move point to |
| 8815 | ;; the most likely position to perform the majority of tests | 8815 | ;; the most likely position to perform the majority of tests |
| 8816 | (goto-char indent-point) | 8816 | (goto-char indent-point) |
| 8817 | (c-backward-syntactic-ws lim) | 8817 | (c-backward-syntactic-ws lim) |
| 8818 | (setq before-ws-ip (point) | 8818 | (setq before-ws-ip (point) |
| 8819 | char-before-ip (char-before)) | 8819 | char-before-ip (char-before)) |
| 8820 | (goto-char indent-point) | 8820 | (goto-char indent-point) |
| 8821 | (skip-chars-forward " \t") | 8821 | (skip-chars-forward " \t") |
| 8822 | (setq char-after-ip (char-after)) | 8822 | (setq char-after-ip (char-after)) |
| 8823 | 8823 | ||
| 8824 | ;; are we in a literal? | 8824 | ;; are we in a literal? |
| 8825 | (setq literal (c-in-literal lim)) | 8825 | (setq literal (c-in-literal lim)) |
| 8826 | 8826 | ||
| 8827 | ;; now figure out syntactic qualities of the current line | 8827 | ;; now figure out syntactic qualities of the current line |
| 8828 | (cond | 8828 | (cond |
| 8829 | 8829 | ||
| 8830 | ;; CASE 1: in a string. | 8830 | ;; CASE 1: in a string. |
| 8831 | ((eq literal 'string) | 8831 | ((eq literal 'string) |
| 8832 | (c-add-syntax 'string (c-point 'bopl))) | 8832 | (c-add-syntax 'string (c-point 'bopl))) |
| 8833 | 8833 | ||
| 8834 | ;; CASE 2: in a C or C++ style comment. | 8834 | ;; CASE 2: in a C or C++ style comment. |
| 8835 | ((and (memq literal '(c c++)) | 8835 | ((and (memq literal '(c c++)) |
| 8836 | ;; This is a kludge for XEmacs where we use | 8836 | ;; This is a kludge for XEmacs where we use |
| 8837 | ;; `buffer-syntactic-context', which doesn't correctly | 8837 | ;; `buffer-syntactic-context', which doesn't correctly |
| 8838 | ;; recognize "\*/" to end a block comment. | 8838 | ;; recognize "\*/" to end a block comment. |
| 8839 | ;; `parse-partial-sexp' which is used by | 8839 | ;; `parse-partial-sexp' which is used by |
| 8840 | ;; `c-literal-limits' will however do that in most | 8840 | ;; `c-literal-limits' will however do that in most |
| 8841 | ;; versions, which results in that we get nil from | 8841 | ;; versions, which results in that we get nil from |
| 8842 | ;; `c-literal-limits' even when `c-in-literal' claims | 8842 | ;; `c-literal-limits' even when `c-in-literal' claims |
| 8843 | ;; we're inside a comment. | 8843 | ;; we're inside a comment. |
| 8844 | (setq placeholder (c-literal-limits lim))) | 8844 | (setq placeholder (c-literal-limits lim))) |
| 8845 | (c-add-syntax literal (car placeholder))) | 8845 | (c-add-syntax literal (car placeholder))) |
| 8846 | 8846 | ||
| 8847 | ;; CASE 3: in a cpp preprocessor macro continuation. | 8847 | ;; CASE 3: in a cpp preprocessor macro continuation. |
| 8848 | ((and (save-excursion | 8848 | ((and (save-excursion |
| 8849 | (when (c-beginning-of-macro) | 8849 | (when (c-beginning-of-macro) |
| 8850 | (setq macro-start (point)))) | 8850 | (setq macro-start (point)))) |
| 8851 | (/= macro-start (c-point 'boi)) | 8851 | (/= macro-start (c-point 'boi)) |
| 8852 | (progn | 8852 | (progn |
| 8853 | (setq tmpsymbol 'cpp-macro-cont) | 8853 | (setq tmpsymbol 'cpp-macro-cont) |
| 8854 | (or (not c-syntactic-indentation-in-macros) | 8854 | (or (not c-syntactic-indentation-in-macros) |
| 8855 | (save-excursion | 8855 | (save-excursion |
| 8856 | (goto-char macro-start) | 8856 | (goto-char macro-start) |
| 8857 | ;; If at the beginning of the body of a #define | 8857 | ;; If at the beginning of the body of a #define |
| 8858 | ;; directive then analyze as cpp-define-intro | 8858 | ;; directive then analyze as cpp-define-intro |
| 8859 | ;; only. Go on with the syntactic analysis | 8859 | ;; only. Go on with the syntactic analysis |
| 8860 | ;; otherwise. in-macro-expr is set if we're in a | 8860 | ;; otherwise. in-macro-expr is set if we're in a |
| 8861 | ;; cpp expression, i.e. before the #define body | 8861 | ;; cpp expression, i.e. before the #define body |
| 8862 | ;; or anywhere in a non-#define directive. | 8862 | ;; or anywhere in a non-#define directive. |
| 8863 | (if (c-forward-to-cpp-define-body) | 8863 | (if (c-forward-to-cpp-define-body) |
| 8864 | (let ((indent-boi (c-point 'boi indent-point))) | 8864 | (let ((indent-boi (c-point 'boi indent-point))) |
| 8865 | (setq in-macro-expr (> (point) indent-boi) | 8865 | (setq in-macro-expr (> (point) indent-boi) |
| 8866 | tmpsymbol 'cpp-define-intro) | 8866 | tmpsymbol 'cpp-define-intro) |
| 8867 | (= (point) indent-boi)) | 8867 | (= (point) indent-boi)) |
| 8868 | (setq in-macro-expr t) | 8868 | (setq in-macro-expr t) |
| 8869 | nil))))) | 8869 | nil))))) |
| 8870 | (c-add-syntax tmpsymbol macro-start) | 8870 | (c-add-syntax tmpsymbol macro-start) |
| 8871 | (setq macro-start nil)) | 8871 | (setq macro-start nil)) |
| 8872 | 8872 | ||
| 8873 | ;; CASE 11: an else clause? | 8873 | ;; CASE 11: an else clause? |
| 8874 | ((looking-at "else\\>[^_]") | 8874 | ((looking-at "else\\>[^_]") |
| 8875 | (c-beginning-of-statement-1 containing-sexp) | 8875 | (c-beginning-of-statement-1 containing-sexp) |
| 8876 | (c-add-stmt-syntax 'else-clause nil t | 8876 | (c-add-stmt-syntax 'else-clause nil t |
| 8877 | containing-sexp paren-state)) | 8877 | containing-sexp paren-state)) |
| 8878 | 8878 | ||
| 8879 | ;; CASE 12: while closure of a do/while construct? | 8879 | ;; CASE 12: while closure of a do/while construct? |
| 8880 | ((and (looking-at "while\\>[^_]") | 8880 | ((and (looking-at "while\\>[^_]") |
| 8881 | (save-excursion | 8881 | (save-excursion |
| 8882 | (prog1 (eq (c-beginning-of-statement-1 containing-sexp) | 8882 | (prog1 (eq (c-beginning-of-statement-1 containing-sexp) |
| 8883 | 'beginning) | 8883 | 'beginning) |
| 8884 | (setq placeholder (point))))) | 8884 | (setq placeholder (point))))) |
| 8885 | (goto-char placeholder) | 8885 | (goto-char placeholder) |
| 8886 | (c-add-stmt-syntax 'do-while-closure nil t | 8886 | (c-add-stmt-syntax 'do-while-closure nil t |
| 8887 | containing-sexp paren-state)) | 8887 | containing-sexp paren-state)) |
| 8888 | 8888 | ||
| 8889 | ;; CASE 13: A catch or finally clause? This case is simpler | 8889 | ;; CASE 13: A catch or finally clause? This case is simpler |
| 8890 | ;; than if-else and do-while, because a block is required | 8890 | ;; than if-else and do-while, because a block is required |
| 8891 | ;; after every try, catch and finally. | 8891 | ;; after every try, catch and finally. |
| 8892 | ((save-excursion | 8892 | ((save-excursion |
| 8893 | (and (cond ((c-major-mode-is 'c++-mode) | 8893 | (and (cond ((c-major-mode-is 'c++-mode) |
| 8894 | (looking-at "catch\\>[^_]")) | 8894 | (looking-at "catch\\>[^_]")) |
| 8895 | ((c-major-mode-is 'java-mode) | 8895 | ((c-major-mode-is 'java-mode) |
| 8896 | (looking-at "\\(catch\\|finally\\)\\>[^_]"))) | 8896 | (looking-at "\\(catch\\|finally\\)\\>[^_]"))) |
| 8897 | (and (c-safe (c-backward-syntactic-ws) | 8897 | (and (c-safe (c-backward-syntactic-ws) |
| 8898 | (c-backward-sexp) | 8898 | (c-backward-sexp) |
| 8899 | t) | 8899 | t) |
| 8900 | (eq (char-after) ?{) | 8900 | (eq (char-after) ?{) |
| 8901 | (c-safe (c-backward-syntactic-ws) | 8901 | (c-safe (c-backward-syntactic-ws) |
| 8902 | (c-backward-sexp) | 8902 | (c-backward-sexp) |
| 8903 | t) | 8903 | t) |
| 8904 | (if (eq (char-after) ?\() | 8904 | (if (eq (char-after) ?\() |
| 8905 | (c-safe (c-backward-sexp) t) | 8905 | (c-safe (c-backward-sexp) t) |
| 8906 | t)) | 8906 | t)) |
| 8907 | (looking-at "\\(try\\|catch\\)\\>[^_]") | 8907 | (looking-at "\\(try\\|catch\\)\\>[^_]") |
| 8908 | (setq placeholder (point)))) | 8908 | (setq placeholder (point)))) |
| 8909 | (goto-char placeholder) | 8909 | (goto-char placeholder) |
| 8910 | (c-add-stmt-syntax 'catch-clause nil t | 8910 | (c-add-stmt-syntax 'catch-clause nil t |
| 8911 | containing-sexp paren-state)) | 8911 | containing-sexp paren-state)) |
| 8912 | 8912 | ||
| 8913 | ;; CASE 18: A substatement we can recognize by keyword. | 8913 | ;; CASE 18: A substatement we can recognize by keyword. |
| 8914 | ((save-excursion | 8914 | ((save-excursion |
| 8915 | (and c-opt-block-stmt-key | 8915 | (and c-opt-block-stmt-key |
| 8916 | (not (eq char-before-ip ?\;)) | 8916 | (not (eq char-before-ip ?\;)) |
| 8917 | (not (c-at-vsemi-p before-ws-ip)) | 8917 | (not (c-at-vsemi-p before-ws-ip)) |
| 8918 | (not (memq char-after-ip '(?\) ?\] ?,))) | 8918 | (not (memq char-after-ip '(?\) ?\] ?,))) |
| 8919 | (or (not (eq char-before-ip ?})) | 8919 | (or (not (eq char-before-ip ?})) |
| 8920 | (c-looking-at-inexpr-block-backward c-state-cache)) | 8920 | (c-looking-at-inexpr-block-backward c-state-cache)) |
| 8921 | (> (point) | 8921 | (> (point) |
| 8922 | (progn | 8922 | (progn |
| 8923 | ;; Ought to cache the result from the | 8923 | ;; Ought to cache the result from the |
| 8924 | ;; c-beginning-of-statement-1 calls here. | 8924 | ;; c-beginning-of-statement-1 calls here. |
| 8925 | (setq placeholder (point)) | ||
| 8926 | (while (eq (setq step-type | ||
| 8927 | (c-beginning-of-statement-1 lim)) | ||
| 8928 | 'label)) | ||
| 8929 | (if (eq step-type 'previous) | ||
| 8930 | (goto-char placeholder) | ||
| 8925 | (setq placeholder (point)) | 8931 | (setq placeholder (point)) |
| 8926 | (while (eq (setq step-type | 8932 | (if (and (eq step-type 'same) |
| 8927 | (c-beginning-of-statement-1 lim)) | 8933 | (not (looking-at c-opt-block-stmt-key))) |
| 8928 | 'label)) | 8934 | ;; Step up to the containing statement if we |
| 8929 | (if (eq step-type 'previous) | 8935 | ;; stayed in the same one. |
| 8930 | (goto-char placeholder) | 8936 | (let (step) |
| 8931 | (setq placeholder (point)) | 8937 | (while (eq |
| 8932 | (if (and (eq step-type 'same) | 8938 | (setq step |
| 8933 | (not (looking-at c-opt-block-stmt-key))) | 8939 | (c-beginning-of-statement-1 lim)) |
| 8934 | ;; Step up to the containing statement if we | 8940 | 'label)) |
| 8935 | ;; stayed in the same one. | 8941 | (if (eq step 'up) |
| 8936 | (let (step) | 8942 | (setq placeholder (point)) |
| 8937 | (while (eq | 8943 | ;; There was no containing statement afterall. |
| 8938 | (setq step | 8944 | (goto-char placeholder))))) |
| 8939 | (c-beginning-of-statement-1 lim)) | 8945 | placeholder)) |
| 8940 | 'label)) | 8946 | (if (looking-at c-block-stmt-2-key) |
| 8941 | (if (eq step 'up) | 8947 | ;; Require a parenthesis after these keywords. |
| 8942 | (setq placeholder (point)) | 8948 | ;; Necessary to catch e.g. synchronized in Java, |
| 8943 | ;; There was no containing statement afterall. | 8949 | ;; which can be used both as statement and |
| 8944 | (goto-char placeholder))))) | 8950 | ;; modifier. |
| 8945 | placeholder)) | 8951 | (and (zerop (c-forward-token-2 1 nil)) |
| 8946 | (if (looking-at c-block-stmt-2-key) | 8952 | (eq (char-after) ?\()) |
| 8947 | ;; Require a parenthesis after these keywords. | 8953 | (looking-at c-opt-block-stmt-key)))) |
| 8948 | ;; Necessary to catch e.g. synchronized in Java, | 8954 | |
| 8949 | ;; which can be used both as statement and | 8955 | (if (eq step-type 'up) |
| 8950 | ;; modifier. | 8956 | ;; CASE 18A: Simple substatement. |
| 8951 | (and (zerop (c-forward-token-2 1 nil)) | 8957 | (progn |
| 8952 | (eq (char-after) ?\()) | 8958 | (goto-char placeholder) |
| 8953 | (looking-at c-opt-block-stmt-key)))) | 8959 | (cond |
| 8954 | 8960 | ((eq char-after-ip ?{) | |
| 8955 | (if (eq step-type 'up) | 8961 | (c-add-stmt-syntax 'substatement-open nil nil |
| 8956 | ;; CASE 18A: Simple substatement. | 8962 | containing-sexp paren-state)) |
| 8957 | (progn | 8963 | ((save-excursion |
| 8958 | (goto-char placeholder) | 8964 | (goto-char indent-point) |
| 8959 | (cond | 8965 | (back-to-indentation) |
| 8960 | ((eq char-after-ip ?{) | 8966 | (c-forward-label)) |
| 8961 | (c-add-stmt-syntax 'substatement-open nil nil | 8967 | (c-add-stmt-syntax 'substatement-label nil nil |
| 8962 | containing-sexp paren-state)) | 8968 | containing-sexp paren-state)) |
| 8963 | ((save-excursion | 8969 | (t |
| 8964 | (goto-char indent-point) | 8970 | (c-add-stmt-syntax 'substatement nil nil |
| 8965 | (back-to-indentation) | 8971 | containing-sexp paren-state)))) |
| 8966 | (c-forward-label)) | 8972 | |
| 8967 | (c-add-stmt-syntax 'substatement-label nil nil | 8973 | ;; CASE 18B: Some other substatement. This is shared |
| 8968 | containing-sexp paren-state)) | 8974 | ;; with case 10. |
| 8969 | (t | 8975 | (c-guess-continued-construct indent-point |
| 8970 | (c-add-stmt-syntax 'substatement nil nil | 8976 | char-after-ip |
| 8971 | containing-sexp paren-state)))) | 8977 | placeholder |
| 8972 | 8978 | lim | |
| 8973 | ;; CASE 18B: Some other substatement. This is shared | 8979 | paren-state))) |
| 8974 | ;; with case 10. | ||
| 8975 | (c-guess-continued-construct indent-point | ||
| 8976 | char-after-ip | ||
| 8977 | placeholder | ||
| 8978 | lim | ||
| 8979 | paren-state))) | ||
| 8980 | |||
| 8981 | ;; CASE 14: A case or default label | ||
| 8982 | ((looking-at c-label-kwds-regexp) | ||
| 8983 | (if containing-sexp | ||
| 8984 | (progn | ||
| 8985 | (goto-char containing-sexp) | ||
| 8986 | (setq lim (c-most-enclosing-brace c-state-cache | ||
| 8987 | containing-sexp)) | ||
| 8988 | (c-backward-to-block-anchor lim) | ||
| 8989 | (c-add-stmt-syntax 'case-label nil t lim paren-state)) | ||
| 8990 | ;; Got a bogus label at the top level. In lack of better | ||
| 8991 | ;; alternatives, anchor it on (point-min). | ||
| 8992 | (c-add-syntax 'case-label (point-min)))) | ||
| 8993 | |||
| 8994 | ;; CASE 15: any other label | ||
| 8995 | ((save-excursion | ||
| 8996 | (back-to-indentation) | ||
| 8997 | (and (not (looking-at c-syntactic-ws-start)) | ||
| 8998 | (c-forward-label))) | ||
| 8999 | (cond (containing-decl-open | ||
| 9000 | (setq placeholder (c-add-class-syntax 'inclass | ||
| 9001 | containing-decl-open | ||
| 9002 | containing-decl-start | ||
| 9003 | containing-decl-kwd | ||
| 9004 | paren-state)) | ||
| 9005 | ;; Append access-label with the same anchor point as | ||
| 9006 | ;; inclass gets. | ||
| 9007 | (c-append-syntax 'access-label placeholder)) | ||
| 9008 | |||
| 9009 | (containing-sexp | ||
| 9010 | (goto-char containing-sexp) | ||
| 9011 | (setq lim (c-most-enclosing-brace c-state-cache | ||
| 9012 | containing-sexp)) | ||
| 9013 | (save-excursion | ||
| 9014 | (setq tmpsymbol | ||
| 9015 | (if (and (eq (c-beginning-of-statement-1 lim) 'up) | ||
| 9016 | (looking-at "switch\\>[^_]")) | ||
| 9017 | ;; If the surrounding statement is a switch then | ||
| 9018 | ;; let's analyze all labels as switch labels, so | ||
| 9019 | ;; that they get lined up consistently. | ||
| 9020 | 'case-label | ||
| 9021 | 'label))) | ||
| 9022 | (c-backward-to-block-anchor lim) | ||
| 9023 | (c-add-stmt-syntax tmpsymbol nil t lim paren-state)) | ||
| 9024 | 8980 | ||
| 9025 | (t | 8981 | ;; CASE 14: A case or default label |
| 9026 | ;; A label on the top level. Treat it as a class | 8982 | ((looking-at c-label-kwds-regexp) |
| 9027 | ;; context. (point-min) is the closest we get to the | 8983 | (if containing-sexp |
| 9028 | ;; class open brace. | 8984 | (progn |
| 9029 | (c-add-syntax 'access-label (point-min))))) | 8985 | (goto-char containing-sexp) |
| 8986 | (setq lim (c-most-enclosing-brace c-state-cache | ||
| 8987 | containing-sexp)) | ||
| 8988 | (c-backward-to-block-anchor lim) | ||
| 8989 | (c-add-stmt-syntax 'case-label nil t lim paren-state)) | ||
| 8990 | ;; Got a bogus label at the top level. In lack of better | ||
| 8991 | ;; alternatives, anchor it on (point-min). | ||
| 8992 | (c-add-syntax 'case-label (point-min)))) | ||
| 9030 | 8993 | ||
| 9031 | ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and | 8994 | ;; CASE 15: any other label |
| 9032 | ;; 17E. | 8995 | ((save-excursion |
| 9033 | ((setq placeholder (c-looking-at-inexpr-block | ||
| 9034 | (c-safe-position containing-sexp paren-state) | ||
| 9035 | containing-sexp | ||
| 9036 | ;; Have to turn on the heuristics after | ||
| 9037 | ;; the point even though it doesn't work | ||
| 9038 | ;; very well. C.f. test case class-16.pike. | ||
| 9039 | t)) | ||
| 9040 | (setq tmpsymbol (assq (car placeholder) | ||
| 9041 | '((inexpr-class . class-open) | ||
| 9042 | (inexpr-statement . block-open)))) | ||
| 9043 | (if tmpsymbol | ||
| 9044 | ;; It's a statement block or an anonymous class. | ||
| 9045 | (setq tmpsymbol (cdr tmpsymbol)) | ||
| 9046 | ;; It's a Pike lambda. Check whether we are between the | ||
| 9047 | ;; lambda keyword and the argument list or at the defun | ||
| 9048 | ;; opener. | ||
| 9049 | (setq tmpsymbol (if (eq char-after-ip ?{) | ||
| 9050 | 'inline-open | ||
| 9051 | 'lambda-intro-cont))) | ||
| 9052 | (goto-char (cdr placeholder)) | ||
| 9053 | (back-to-indentation) | 8996 | (back-to-indentation) |
| 9054 | (c-add-stmt-syntax tmpsymbol nil t | 8997 | (and (not (looking-at c-syntactic-ws-start)) |
| 9055 | (c-most-enclosing-brace c-state-cache (point)) | 8998 | (c-forward-label))) |
| 9056 | paren-state) | 8999 | (cond (containing-decl-open |
| 9057 | (unless (eq (point) (cdr placeholder)) | 9000 | (setq placeholder (c-add-class-syntax 'inclass |
| 9058 | (c-add-syntax (car placeholder)))) | 9001 | containing-decl-open |
| 9059 | 9002 | containing-decl-start | |
| 9060 | ;; CASE 5: Line is inside a declaration level block or at top level. | 9003 | containing-decl-kwd |
| 9061 | ((or containing-decl-open (null containing-sexp)) | 9004 | paren-state)) |
| 9062 | (cond | 9005 | ;; Append access-label with the same anchor point as |
| 9063 | 9006 | ;; inclass gets. | |
| 9064 | ;; CASE 5A: we are looking at a defun, brace list, class, | 9007 | (c-append-syntax 'access-label placeholder)) |
| 9065 | ;; or inline-inclass method opening brace | 9008 | |
| 9066 | ((setq special-brace-list | 9009 | (containing-sexp |
| 9067 | (or (and c-special-brace-lists | 9010 | (goto-char containing-sexp) |
| 9068 | (c-looking-at-special-brace-list)) | 9011 | (setq lim (c-most-enclosing-brace c-state-cache |
| 9069 | (eq char-after-ip ?{))) | 9012 | containing-sexp)) |
| 9070 | (cond | 9013 | (save-excursion |
| 9014 | (setq tmpsymbol | ||
| 9015 | (if (and (eq (c-beginning-of-statement-1 lim) 'up) | ||
| 9016 | (looking-at "switch\\>[^_]")) | ||
| 9017 | ;; If the surrounding statement is a switch then | ||
| 9018 | ;; let's analyze all labels as switch labels, so | ||
| 9019 | ;; that they get lined up consistently. | ||
| 9020 | 'case-label | ||
| 9021 | 'label))) | ||
| 9022 | (c-backward-to-block-anchor lim) | ||
| 9023 | (c-add-stmt-syntax tmpsymbol nil t lim paren-state)) | ||
| 9071 | 9024 | ||
| 9072 | ;; CASE 5A.1: Non-class declaration block open. | 9025 | (t |
| 9073 | ((save-excursion | 9026 | ;; A label on the top level. Treat it as a class |
| 9074 | (let (tmp) | 9027 | ;; context. (point-min) is the closest we get to the |
| 9075 | (and (eq char-after-ip ?{) | 9028 | ;; class open brace. |
| 9076 | (setq tmp (c-looking-at-decl-block containing-sexp t)) | 9029 | (c-add-syntax 'access-label (point-min))))) |
| 9077 | (progn | 9030 | |
| 9078 | (setq placeholder (point)) | 9031 | ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and |
| 9079 | (goto-char tmp) | 9032 | ;; 17E. |
| 9080 | (looking-at c-symbol-key)) | 9033 | ((setq placeholder (c-looking-at-inexpr-block |
| 9081 | (c-keyword-member | 9034 | (c-safe-position containing-sexp paren-state) |
| 9082 | (c-keyword-sym (setq keyword (match-string 0))) | 9035 | containing-sexp |
| 9083 | 'c-other-block-decl-kwds)))) | 9036 | ;; Have to turn on the heuristics after |
| 9084 | (goto-char placeholder) | 9037 | ;; the point even though it doesn't work |
| 9085 | (c-add-stmt-syntax | 9038 | ;; very well. C.f. test case class-16.pike. |
| 9086 | (if (string-equal keyword "extern") | 9039 | t)) |
| 9087 | ;; Special case for extern-lang-open. | 9040 | (setq tmpsymbol (assq (car placeholder) |
| 9088 | 'extern-lang-open | 9041 | '((inexpr-class . class-open) |
| 9089 | (intern (concat keyword "-open"))) | 9042 | (inexpr-statement . block-open)))) |
| 9090 | nil t containing-sexp paren-state)) | 9043 | (if tmpsymbol |
| 9091 | 9044 | ;; It's a statement block or an anonymous class. | |
| 9092 | ;; CASE 5A.2: we are looking at a class opening brace | 9045 | (setq tmpsymbol (cdr tmpsymbol)) |
| 9093 | ((save-excursion | 9046 | ;; It's a Pike lambda. Check whether we are between the |
| 9094 | (goto-char indent-point) | 9047 | ;; lambda keyword and the argument list or at the defun |
| 9095 | (skip-chars-forward " \t") | 9048 | ;; opener. |
| 9096 | (and (eq (char-after) ?{) | 9049 | (setq tmpsymbol (if (eq char-after-ip ?{) |
| 9097 | (c-looking-at-decl-block containing-sexp t) | 9050 | 'inline-open |
| 9098 | (setq placeholder (point)))) | 9051 | 'lambda-intro-cont))) |
| 9099 | (c-add-syntax 'class-open placeholder)) | 9052 | (goto-char (cdr placeholder)) |
| 9100 | 9053 | (back-to-indentation) | |
| 9101 | ;; CASE 5A.3: brace list open | 9054 | (c-add-stmt-syntax tmpsymbol nil t |
| 9102 | ((save-excursion | 9055 | (c-most-enclosing-brace c-state-cache (point)) |
| 9103 | (c-beginning-of-decl-1 lim) | 9056 | paren-state) |
| 9104 | (while (looking-at c-specifier-key) | 9057 | (unless (eq (point) (cdr placeholder)) |
| 9105 | (goto-char (match-end 1)) | 9058 | (c-add-syntax (car placeholder)))) |
| 9106 | (c-forward-syntactic-ws indent-point)) | ||
| 9107 | (setq placeholder (c-point 'boi)) | ||
| 9108 | (or (consp special-brace-list) | ||
| 9109 | (and (or (save-excursion | ||
| 9110 | (goto-char indent-point) | ||
| 9111 | (setq tmpsymbol nil) | ||
| 9112 | (while (and (> (point) placeholder) | ||
| 9113 | (zerop (c-backward-token-2 1 t)) | ||
| 9114 | (/= (char-after) ?=)) | ||
| 9115 | (and c-opt-inexpr-brace-list-key | ||
| 9116 | (not tmpsymbol) | ||
| 9117 | (looking-at c-opt-inexpr-brace-list-key) | ||
| 9118 | (setq tmpsymbol 'topmost-intro-cont))) | ||
| 9119 | (eq (char-after) ?=)) | ||
| 9120 | (looking-at c-brace-list-key)) | ||
| 9121 | (save-excursion | ||
| 9122 | (while (and (< (point) indent-point) | ||
| 9123 | (zerop (c-forward-token-2 1 t)) | ||
| 9124 | (not (memq (char-after) '(?\; ?\())))) | ||
| 9125 | (not (memq (char-after) '(?\; ?\())) | ||
| 9126 | )))) | ||
| 9127 | (if (and (not c-auto-newline-analysis) | ||
| 9128 | (c-major-mode-is 'java-mode) | ||
| 9129 | (eq tmpsymbol 'topmost-intro-cont)) | ||
| 9130 | ;; We're in Java and have found that the open brace | ||
| 9131 | ;; belongs to a "new Foo[]" initialization list, | ||
| 9132 | ;; which means the brace list is part of an | ||
| 9133 | ;; expression and not a top level definition. We | ||
| 9134 | ;; therefore treat it as any topmost continuation | ||
| 9135 | ;; even though the semantically correct symbol still | ||
| 9136 | ;; is brace-list-open, on the same grounds as in | ||
| 9137 | ;; case B.2. | ||
| 9138 | (progn | ||
| 9139 | (c-beginning-of-statement-1 lim) | ||
| 9140 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) | ||
| 9141 | (c-add-syntax 'brace-list-open placeholder))) | ||
| 9142 | |||
| 9143 | ;; CASE 5A.4: inline defun open | ||
| 9144 | ((and containing-decl-open | ||
| 9145 | (not (c-keyword-member containing-decl-kwd | ||
| 9146 | 'c-other-block-decl-kwds))) | ||
| 9147 | (c-add-syntax 'inline-open) | ||
| 9148 | (c-add-class-syntax 'inclass | ||
| 9149 | containing-decl-open | ||
| 9150 | containing-decl-start | ||
| 9151 | containing-decl-kwd | ||
| 9152 | paren-state)) | ||
| 9153 | |||
| 9154 | ;; CASE 5A.5: ordinary defun open | ||
| 9155 | (t | ||
| 9156 | (save-excursion | ||
| 9157 | (c-beginning-of-decl-1 lim) | ||
| 9158 | (while (looking-at c-specifier-key) | ||
| 9159 | (goto-char (match-end 1)) | ||
| 9160 | (c-forward-syntactic-ws indent-point)) | ||
| 9161 | (c-add-syntax 'defun-open (c-point 'boi)) | ||
| 9162 | ;; Bogus to use bol here, but it's the legacy. (Resolved, | ||
| 9163 | ;; 2007-11-09) | ||
| 9164 | )))) | ||
| 9165 | |||
| 9166 | ;; CASE 5B: After a function header but before the body (or | ||
| 9167 | ;; the ending semicolon if there's no body). | ||
| 9168 | ((save-excursion | ||
| 9169 | (when (setq placeholder (c-just-after-func-arglist-p lim)) | ||
| 9170 | (setq tmp-pos (point)))) | ||
| 9171 | (cond | ||
| 9172 | 9059 | ||
| 9173 | ;; CASE 5B.1: Member init list. | 9060 | ;; CASE 5: Line is inside a declaration level block or at top level. |
| 9174 | ((eq (char-after tmp-pos) ?:) | 9061 | ((or containing-decl-open (null containing-sexp)) |
| 9175 | (if (or (> tmp-pos indent-point) | 9062 | (cond |
| 9176 | (= (c-point 'bosws) (1+ tmp-pos))) | ||
| 9177 | (progn | ||
| 9178 | ;; There is no preceding member init clause. | ||
| 9179 | ;; Indent relative to the beginning of indentation | ||
| 9180 | ;; for the topmost-intro line that contains the | ||
| 9181 | ;; prototype's open paren. | ||
| 9182 | (goto-char placeholder) | ||
| 9183 | (c-add-syntax 'member-init-intro (c-point 'boi))) | ||
| 9184 | ;; Indent relative to the first member init clause. | ||
| 9185 | (goto-char (1+ tmp-pos)) | ||
| 9186 | (c-forward-syntactic-ws) | ||
| 9187 | (c-add-syntax 'member-init-cont (point)))) | ||
| 9188 | 9063 | ||
| 9189 | ;; CASE 5B.2: K&R arg decl intro | 9064 | ;; CASE 5A: we are looking at a defun, brace list, class, |
| 9190 | ((and c-recognize-knr-p | 9065 | ;; or inline-inclass method opening brace |
| 9191 | (c-in-knr-argdecl lim)) | 9066 | ((setq special-brace-list |
| 9192 | (c-beginning-of-statement-1 lim) | 9067 | (or (and c-special-brace-lists |
| 9193 | (c-add-syntax 'knr-argdecl-intro (c-point 'boi)) | 9068 | (c-looking-at-special-brace-list)) |
| 9194 | (if containing-decl-open | 9069 | (eq char-after-ip ?{))) |
| 9195 | (c-add-class-syntax 'inclass | 9070 | (cond |
| 9196 | containing-decl-open | ||
| 9197 | containing-decl-start | ||
| 9198 | containing-decl-kwd | ||
| 9199 | paren-state))) | ||
| 9200 | |||
| 9201 | ;; CASE 5B.4: Nether region after a C++ or Java func | ||
| 9202 | ;; decl, which could include a `throws' declaration. | ||
| 9203 | (t | ||
| 9204 | (c-beginning-of-statement-1 lim) | ||
| 9205 | (c-add-syntax 'func-decl-cont (c-point 'boi)) | ||
| 9206 | ))) | ||
| 9207 | 9071 | ||
| 9208 | ;; CASE 5C: inheritance line. could be first inheritance | 9072 | ;; CASE 5A.1: Non-class declaration block open. |
| 9209 | ;; line, or continuation of a multiple inheritance | 9073 | ((save-excursion |
| 9210 | ((or (and (c-major-mode-is 'c++-mode) | 9074 | (let (tmp) |
| 9075 | (and (eq char-after-ip ?{) | ||
| 9076 | (setq tmp (c-looking-at-decl-block containing-sexp t)) | ||
| 9211 | (progn | 9077 | (progn |
| 9212 | (when (eq char-after-ip ?,) | 9078 | (setq placeholder (point)) |
| 9213 | (skip-chars-forward " \t") | 9079 | (goto-char tmp) |
| 9214 | (forward-char)) | 9080 | (looking-at c-symbol-key)) |
| 9215 | (looking-at c-opt-postfix-decl-spec-key))) | 9081 | (c-keyword-member |
| 9216 | (and (or (eq char-before-ip ?:) | 9082 | (c-keyword-sym (setq keyword (match-string 0))) |
| 9217 | ;; watch out for scope operator | 9083 | 'c-other-block-decl-kwds)))) |
| 9218 | (save-excursion | 9084 | (goto-char placeholder) |
| 9219 | (and (eq char-after-ip ?:) | 9085 | (c-add-stmt-syntax |
| 9220 | (c-safe (forward-char 1) t) | 9086 | (if (string-equal keyword "extern") |
| 9221 | (not (eq (char-after) ?:)) | 9087 | ;; Special case for extern-lang-open. |
| 9222 | ))) | 9088 | 'extern-lang-open |
| 9223 | (save-excursion | 9089 | (intern (concat keyword "-open"))) |
| 9224 | (c-backward-syntactic-ws lim) | 9090 | nil t containing-sexp paren-state)) |
| 9225 | (if (eq char-before-ip ?:) | ||
| 9226 | (progn | ||
| 9227 | (forward-char -1) | ||
| 9228 | (c-backward-syntactic-ws lim))) | ||
| 9229 | (back-to-indentation) | ||
| 9230 | (looking-at c-class-key))) | ||
| 9231 | ;; for Java | ||
| 9232 | (and (c-major-mode-is 'java-mode) | ||
| 9233 | (let ((fence (save-excursion | ||
| 9234 | (c-beginning-of-statement-1 lim) | ||
| 9235 | (point))) | ||
| 9236 | cont done) | ||
| 9237 | (save-excursion | ||
| 9238 | (while (not done) | ||
| 9239 | (cond ((looking-at c-opt-postfix-decl-spec-key) | ||
| 9240 | (setq injava-inher (cons cont (point)) | ||
| 9241 | done t)) | ||
| 9242 | ((or (not (c-safe (c-forward-sexp -1) t)) | ||
| 9243 | (<= (point) fence)) | ||
| 9244 | (setq done t)) | ||
| 9245 | ) | ||
| 9246 | (setq cont t))) | ||
| 9247 | injava-inher) | ||
| 9248 | (not (c-crosses-statement-barrier-p (cdr injava-inher) | ||
| 9249 | (point))) | ||
| 9250 | )) | ||
| 9251 | (cond | ||
| 9252 | |||
| 9253 | ;; CASE 5C.1: non-hanging colon on an inher intro | ||
| 9254 | ((eq char-after-ip ?:) | ||
| 9255 | (c-beginning-of-statement-1 lim) | ||
| 9256 | (c-add-syntax 'inher-intro (c-point 'boi)) | ||
| 9257 | ;; don't add inclass symbol since relative point already | ||
| 9258 | ;; contains any class offset | ||
| 9259 | ) | ||
| 9260 | 9091 | ||
| 9261 | ;; CASE 5C.2: hanging colon on an inher intro | 9092 | ;; CASE 5A.2: we are looking at a class opening brace |
| 9262 | ((eq char-before-ip ?:) | ||
| 9263 | (c-beginning-of-statement-1 lim) | ||
| 9264 | (c-add-syntax 'inher-intro (c-point 'boi)) | ||
| 9265 | (if containing-decl-open | ||
| 9266 | (c-add-class-syntax 'inclass | ||
| 9267 | containing-decl-open | ||
| 9268 | containing-decl-start | ||
| 9269 | containing-decl-kwd | ||
| 9270 | paren-state))) | ||
| 9271 | |||
| 9272 | ;; CASE 5C.3: in a Java implements/extends | ||
| 9273 | (injava-inher | ||
| 9274 | (let ((where (cdr injava-inher)) | ||
| 9275 | (cont (car injava-inher))) | ||
| 9276 | (goto-char where) | ||
| 9277 | (cond ((looking-at "throws\\>[^_]") | ||
| 9278 | (c-add-syntax 'func-decl-cont | ||
| 9279 | (progn (c-beginning-of-statement-1 lim) | ||
| 9280 | (c-point 'boi)))) | ||
| 9281 | (cont (c-add-syntax 'inher-cont where)) | ||
| 9282 | (t (c-add-syntax 'inher-intro | ||
| 9283 | (progn (goto-char (cdr injava-inher)) | ||
| 9284 | (c-beginning-of-statement-1 lim) | ||
| 9285 | (point)))) | ||
| 9286 | ))) | ||
| 9287 | |||
| 9288 | ;; CASE 5C.4: a continued inheritance line | ||
| 9289 | (t | ||
| 9290 | (c-beginning-of-inheritance-list lim) | ||
| 9291 | (c-add-syntax 'inher-cont (point)) | ||
| 9292 | ;; don't add inclass symbol since relative point already | ||
| 9293 | ;; contains any class offset | ||
| 9294 | ))) | ||
| 9295 | |||
| 9296 | ;; CASE 5D: this could be a top-level initialization, a | ||
| 9297 | ;; member init list continuation, or a template argument | ||
| 9298 | ;; list continuation. | ||
| 9299 | ((save-excursion | 9093 | ((save-excursion |
| 9300 | ;; Note: We use the fact that lim is always after any | 9094 | (goto-char indent-point) |
| 9301 | ;; preceding brace sexp. | 9095 | (skip-chars-forward " \t") |
| 9302 | (if c-recognize-<>-arglists | 9096 | (and (eq (char-after) ?{) |
| 9303 | (while (and | 9097 | (c-looking-at-decl-block containing-sexp t) |
| 9304 | (progn | 9098 | (setq placeholder (point)))) |
| 9305 | (c-syntactic-skip-backward "^;,=<>" lim t) | 9099 | (c-add-syntax 'class-open placeholder)) |
| 9306 | (> (point) lim)) | 9100 | |
| 9307 | (or | 9101 | ;; CASE 5A.3: brace list open |
| 9308 | (when c-overloadable-operators-regexp | 9102 | ((save-excursion |
| 9309 | (when (setq placeholder (c-after-special-operator-id lim)) | 9103 | (c-beginning-of-decl-1 lim) |
| 9310 | (goto-char placeholder) | 9104 | (while (looking-at c-specifier-key) |
| 9311 | t)) | 9105 | (goto-char (match-end 1)) |
| 9312 | (cond | 9106 | (c-forward-syntactic-ws indent-point)) |
| 9313 | ((eq (char-before) ?>) | 9107 | (setq placeholder (c-point 'boi)) |
| 9314 | (or (c-backward-<>-arglist nil lim) | 9108 | (or (consp special-brace-list) |
| 9315 | (backward-char)) | 9109 | (and (or (save-excursion |
| 9316 | t) | 9110 | (goto-char indent-point) |
| 9317 | ((eq (char-before) ?<) | 9111 | (setq tmpsymbol nil) |
| 9318 | (backward-char) | 9112 | (while (and (> (point) placeholder) |
| 9319 | (if (save-excursion | 9113 | (zerop (c-backward-token-2 1 t)) |
| 9320 | (c-forward-<>-arglist nil)) | 9114 | (/= (char-after) ?=)) |
| 9321 | (progn (forward-char) | 9115 | (and c-opt-inexpr-brace-list-key |
| 9322 | nil) | 9116 | (not tmpsymbol) |
| 9323 | t)) | 9117 | (looking-at c-opt-inexpr-brace-list-key) |
| 9324 | (t nil))))) | 9118 | (setq tmpsymbol 'topmost-intro-cont))) |
| 9325 | ;; NB: No c-after-special-operator-id stuff in this | 9119 | (eq (char-after) ?=)) |
| 9326 | ;; clause - we assume only C++ needs it. | 9120 | (looking-at c-brace-list-key)) |
| 9327 | (c-syntactic-skip-backward "^;,=" lim t)) | 9121 | (save-excursion |
| 9328 | (memq (char-before) '(?, ?= ?<))) | 9122 | (while (and (< (point) indent-point) |
| 9329 | (cond | 9123 | (zerop (c-forward-token-2 1 t)) |
| 9330 | 9124 | (not (memq (char-after) '(?\; ?\())))) | |
| 9331 | ;; CASE 5D.3: perhaps a template list continuation? | 9125 | (not (memq (char-after) '(?\; ?\())) |
| 9332 | ((and (c-major-mode-is 'c++-mode) | 9126 | )))) |
| 9333 | (save-excursion | 9127 | (if (and (not c-auto-newline-analysis) |
| 9334 | (save-restriction | 9128 | (c-major-mode-is 'java-mode) |
| 9335 | (c-with-syntax-table c++-template-syntax-table | 9129 | (eq tmpsymbol 'topmost-intro-cont)) |
| 9336 | (goto-char indent-point) | 9130 | ;; We're in Java and have found that the open brace |
| 9337 | (setq placeholder (c-up-list-backward)) | 9131 | ;; belongs to a "new Foo[]" initialization list, |
| 9338 | (and placeholder | 9132 | ;; which means the brace list is part of an |
| 9339 | (eq (char-after placeholder) ?<)))))) | 9133 | ;; expression and not a top level definition. We |
| 9340 | (c-with-syntax-table c++-template-syntax-table | 9134 | ;; therefore treat it as any topmost continuation |
| 9341 | (goto-char placeholder) | 9135 | ;; even though the semantically correct symbol still |
| 9342 | (c-beginning-of-statement-1 lim t) | 9136 | ;; is brace-list-open, on the same grounds as in |
| 9343 | (if (save-excursion | 9137 | ;; case B.2. |
| 9344 | (c-backward-syntactic-ws lim) | 9138 | (progn |
| 9345 | (eq (char-before) ?<)) | 9139 | (c-beginning-of-statement-1 lim) |
| 9346 | ;; In a nested template arglist. | 9140 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) |
| 9347 | (progn | 9141 | (c-add-syntax 'brace-list-open placeholder))) |
| 9348 | (goto-char placeholder) | 9142 | |
| 9349 | (c-syntactic-skip-backward "^,;" lim t) | 9143 | ;; CASE 5A.4: inline defun open |
| 9350 | (c-forward-syntactic-ws)) | 9144 | ((and containing-decl-open |
| 9351 | (back-to-indentation))) | 9145 | (not (c-keyword-member containing-decl-kwd |
| 9352 | ;; FIXME: Should use c-add-stmt-syntax, but it's not yet | 9146 | 'c-other-block-decl-kwds))) |
| 9353 | ;; template aware. | 9147 | (c-add-syntax 'inline-open) |
| 9354 | (c-add-syntax 'template-args-cont (point) placeholder)) | 9148 | (c-add-class-syntax 'inclass |
| 9355 | |||
| 9356 | ;; CASE 5D.4: perhaps a multiple inheritance line? | ||
| 9357 | ((and (c-major-mode-is 'c++-mode) | ||
| 9358 | (save-excursion | ||
| 9359 | (c-beginning-of-statement-1 lim) | ||
| 9360 | (setq placeholder (point)) | ||
| 9361 | (if (looking-at "static\\>[^_]") | ||
| 9362 | (c-forward-token-2 1 nil indent-point)) | ||
| 9363 | (and (looking-at c-class-key) | ||
| 9364 | (zerop (c-forward-token-2 2 nil indent-point)) | ||
| 9365 | (if (eq (char-after) ?<) | ||
| 9366 | (c-with-syntax-table c++-template-syntax-table | ||
| 9367 | (zerop (c-forward-token-2 1 t indent-point))) | ||
| 9368 | t) | ||
| 9369 | (eq (char-after) ?:)))) | ||
| 9370 | (goto-char placeholder) | ||
| 9371 | (c-add-syntax 'inher-cont (c-point 'boi))) | ||
| 9372 | |||
| 9373 | ;; CASE 5D.5: Continuation of the "expression part" of a | ||
| 9374 | ;; top level construct. Or, perhaps, an unrecognised construct. | ||
| 9375 | (t | ||
| 9376 | (while (and (setq placeholder (point)) | ||
| 9377 | (eq (car (c-beginning-of-decl-1 containing-sexp)) | ||
| 9378 | 'same) | ||
| 9379 | (save-excursion | ||
| 9380 | (c-backward-syntactic-ws) | ||
| 9381 | (eq (char-before) ?})) | ||
| 9382 | (< (point) placeholder))) | ||
| 9383 | (c-add-stmt-syntax | ||
| 9384 | (cond | ||
| 9385 | ((eq (point) placeholder) 'statement) ; unrecognised construct | ||
| 9386 | ;; A preceding comma at the top level means that a | ||
| 9387 | ;; new variable declaration starts here. Use | ||
| 9388 | ;; topmost-intro-cont for it, for consistency with | ||
| 9389 | ;; the first variable declaration. C.f. case 5N. | ||
| 9390 | ((eq char-before-ip ?,) 'topmost-intro-cont) | ||
| 9391 | (t 'statement-cont)) | ||
| 9392 | nil nil containing-sexp paren-state)) | ||
| 9393 | )) | ||
| 9394 | |||
| 9395 | ;; CASE 5F: Close of a non-class declaration level block. | ||
| 9396 | ((and (eq char-after-ip ?}) | ||
| 9397 | (c-keyword-member containing-decl-kwd | ||
| 9398 | 'c-other-block-decl-kwds)) | ||
| 9399 | ;; This is inconsistent: Should use `containing-decl-open' | ||
| 9400 | ;; here if it's at boi, like in case 5J. | ||
| 9401 | (goto-char containing-decl-start) | ||
| 9402 | (c-add-stmt-syntax | ||
| 9403 | (if (string-equal (symbol-name containing-decl-kwd) "extern") | ||
| 9404 | ;; Special case for compatibility with the | ||
| 9405 | ;; extern-lang syntactic symbols. | ||
| 9406 | 'extern-lang-close | ||
| 9407 | (intern (concat (symbol-name containing-decl-kwd) | ||
| 9408 | "-close"))) | ||
| 9409 | nil t | ||
| 9410 | (c-most-enclosing-brace paren-state (point)) | ||
| 9411 | paren-state)) | ||
| 9412 | |||
| 9413 | ;; CASE 5G: we are looking at the brace which closes the | ||
| 9414 | ;; enclosing nested class decl | ||
| 9415 | ((and containing-sexp | ||
| 9416 | (eq char-after-ip ?}) | ||
| 9417 | (eq containing-decl-open containing-sexp)) | ||
| 9418 | (c-add-class-syntax 'class-close | ||
| 9419 | containing-decl-open | 9149 | containing-decl-open |
| 9420 | containing-decl-start | 9150 | containing-decl-start |
| 9421 | containing-decl-kwd | 9151 | containing-decl-kwd |
| 9422 | paren-state)) | 9152 | paren-state)) |
| 9423 | 9153 | ||
| 9424 | ;; CASE 5H: we could be looking at subsequent knr-argdecls | 9154 | ;; CASE 5A.5: ordinary defun open |
| 9155 | (t | ||
| 9156 | (save-excursion | ||
| 9157 | (c-beginning-of-decl-1 lim) | ||
| 9158 | (while (looking-at c-specifier-key) | ||
| 9159 | (goto-char (match-end 1)) | ||
| 9160 | (c-forward-syntactic-ws indent-point)) | ||
| 9161 | (c-add-syntax 'defun-open (c-point 'boi)) | ||
| 9162 | ;; Bogus to use bol here, but it's the legacy. (Resolved, | ||
| 9163 | ;; 2007-11-09) | ||
| 9164 | )))) | ||
| 9165 | |||
| 9166 | ;; CASE 5B: After a function header but before the body (or | ||
| 9167 | ;; the ending semicolon if there's no body). | ||
| 9168 | ((save-excursion | ||
| 9169 | (when (setq placeholder (c-just-after-func-arglist-p lim)) | ||
| 9170 | (setq tmp-pos (point)))) | ||
| 9171 | (cond | ||
| 9172 | |||
| 9173 | ;; CASE 5B.1: Member init list. | ||
| 9174 | ((eq (char-after tmp-pos) ?:) | ||
| 9175 | (if (or (> tmp-pos indent-point) | ||
| 9176 | (= (c-point 'bosws) (1+ tmp-pos))) | ||
| 9177 | (progn | ||
| 9178 | ;; There is no preceding member init clause. | ||
| 9179 | ;; Indent relative to the beginning of indentation | ||
| 9180 | ;; for the topmost-intro line that contains the | ||
| 9181 | ;; prototype's open paren. | ||
| 9182 | (goto-char placeholder) | ||
| 9183 | (c-add-syntax 'member-init-intro (c-point 'boi))) | ||
| 9184 | ;; Indent relative to the first member init clause. | ||
| 9185 | (goto-char (1+ tmp-pos)) | ||
| 9186 | (c-forward-syntactic-ws) | ||
| 9187 | (c-add-syntax 'member-init-cont (point)))) | ||
| 9188 | |||
| 9189 | ;; CASE 5B.2: K&R arg decl intro | ||
| 9425 | ((and c-recognize-knr-p | 9190 | ((and c-recognize-knr-p |
| 9426 | (not containing-sexp) ; can't be knr inside braces. | 9191 | (c-in-knr-argdecl lim)) |
| 9427 | (not (eq char-before-ip ?})) | 9192 | (c-beginning-of-statement-1 lim) |
| 9428 | (save-excursion | 9193 | (c-add-syntax 'knr-argdecl-intro (c-point 'boi)) |
| 9429 | (setq placeholder (cdr (c-beginning-of-decl-1 lim))) | 9194 | (if containing-decl-open |
| 9430 | (and placeholder | 9195 | (c-add-class-syntax 'inclass |
| 9431 | ;; Do an extra check to avoid tripping up on | 9196 | containing-decl-open |
| 9432 | ;; statements that occur in invalid contexts | 9197 | containing-decl-start |
| 9433 | ;; (e.g. in macro bodies where we don't really | 9198 | containing-decl-kwd |
| 9434 | ;; know the context of what we're looking at). | 9199 | paren-state))) |
| 9435 | (not (and c-opt-block-stmt-key | 9200 | |
| 9436 | (looking-at c-opt-block-stmt-key))))) | 9201 | ;; CASE 5B.4: Nether region after a C++ or Java func |
| 9437 | (< placeholder indent-point)) | 9202 | ;; decl, which could include a `throws' declaration. |
| 9438 | (goto-char placeholder) | 9203 | (t |
| 9439 | (c-add-syntax 'knr-argdecl (point))) | 9204 | (c-beginning-of-statement-1 lim) |
| 9440 | 9205 | (c-add-syntax 'func-decl-cont (c-point 'boi)) | |
| 9441 | ;; CASE 5I: ObjC method definition. | 9206 | ))) |
| 9442 | ((and c-opt-method-key | 9207 | |
| 9443 | (looking-at c-opt-method-key)) | 9208 | ;; CASE 5C: inheritance line. could be first inheritance |
| 9444 | (c-beginning-of-statement-1 nil t) | 9209 | ;; line, or continuation of a multiple inheritance |
| 9445 | (if (= (point) indent-point) | 9210 | ((or (and (c-major-mode-is 'c++-mode) |
| 9446 | ;; Handle the case when it's the first (non-comment) | 9211 | (progn |
| 9447 | ;; thing in the buffer. Can't look for a 'same return | 9212 | (when (eq char-after-ip ?,) |
| 9448 | ;; value from cbos1 since ObjC directives currently | 9213 | (skip-chars-forward " \t") |
| 9449 | ;; aren't recognized fully, so that we get 'same | 9214 | (forward-char)) |
| 9450 | ;; instead of 'previous if it moved over a preceding | 9215 | (looking-at c-opt-postfix-decl-spec-key))) |
| 9451 | ;; directive. | 9216 | (and (or (eq char-before-ip ?:) |
| 9452 | (goto-char (point-min))) | 9217 | ;; watch out for scope operator |
| 9453 | (c-add-syntax 'objc-method-intro (c-point 'boi))) | 9218 | (save-excursion |
| 9454 | 9219 | (and (eq char-after-ip ?:) | |
| 9455 | ;; CASE 5P: AWK pattern or function or continuation | 9220 | (c-safe (forward-char 1) t) |
| 9456 | ;; thereof. | 9221 | (not (eq (char-after) ?:)) |
| 9457 | ((c-major-mode-is 'awk-mode) | 9222 | ))) |
| 9458 | (setq placeholder (point)) | ||
| 9459 | (c-add-stmt-syntax | ||
| 9460 | (if (and (eq (c-beginning-of-statement-1) 'same) | ||
| 9461 | (/= (point) placeholder)) | ||
| 9462 | 'topmost-intro-cont | ||
| 9463 | 'topmost-intro) | ||
| 9464 | nil nil | ||
| 9465 | containing-sexp paren-state)) | ||
| 9466 | |||
| 9467 | ;; CASE 5N: At a variable declaration that follows a class | ||
| 9468 | ;; definition or some other block declaration that doesn't | ||
| 9469 | ;; end at the closing '}'. C.f. case 5D.5. | ||
| 9470 | ((progn | ||
| 9471 | (c-backward-syntactic-ws lim) | ||
| 9472 | (and (eq (char-before) ?}) | ||
| 9473 | (save-excursion | 9223 | (save-excursion |
| 9474 | (let ((start (point))) | 9224 | (c-backward-syntactic-ws lim) |
| 9475 | (if (and c-state-cache | 9225 | (if (eq char-before-ip ?:) |
| 9476 | (consp (car c-state-cache)) | 9226 | (progn |
| 9477 | (eq (cdar c-state-cache) (point))) | 9227 | (forward-char -1) |
| 9478 | ;; Speed up the backward search a bit. | 9228 | (c-backward-syntactic-ws lim))) |
| 9479 | (goto-char (caar c-state-cache))) | 9229 | (back-to-indentation) |
| 9480 | (c-beginning-of-decl-1 containing-sexp) | 9230 | (looking-at c-class-key))) |
| 9481 | (setq placeholder (point)) | 9231 | ;; for Java |
| 9482 | (if (= start (point)) | 9232 | (and (c-major-mode-is 'java-mode) |
| 9483 | ;; The '}' is unbalanced. | 9233 | (let ((fence (save-excursion |
| 9484 | nil | 9234 | (c-beginning-of-statement-1 lim) |
| 9485 | (c-end-of-decl-1) | 9235 | (point))) |
| 9486 | (>= (point) indent-point)))))) | 9236 | cont done) |
| 9487 | (goto-char placeholder) | 9237 | (save-excursion |
| 9488 | (c-add-stmt-syntax 'topmost-intro-cont nil nil | 9238 | (while (not done) |
| 9489 | containing-sexp paren-state)) | 9239 | (cond ((looking-at c-opt-postfix-decl-spec-key) |
| 9240 | (setq injava-inher (cons cont (point)) | ||
| 9241 | done t)) | ||
| 9242 | ((or (not (c-safe (c-forward-sexp -1) t)) | ||
| 9243 | (<= (point) fence)) | ||
| 9244 | (setq done t)) | ||
| 9245 | ) | ||
| 9246 | (setq cont t))) | ||
| 9247 | injava-inher) | ||
| 9248 | (not (c-crosses-statement-barrier-p (cdr injava-inher) | ||
| 9249 | (point))) | ||
| 9250 | )) | ||
| 9251 | (cond | ||
| 9490 | 9252 | ||
| 9491 | ;; NOTE: The point is at the end of the previous token here. | 9253 | ;; CASE 5C.1: non-hanging colon on an inher intro |
| 9254 | ((eq char-after-ip ?:) | ||
| 9255 | (c-beginning-of-statement-1 lim) | ||
| 9256 | (c-add-syntax 'inher-intro (c-point 'boi)) | ||
| 9257 | ;; don't add inclass symbol since relative point already | ||
| 9258 | ;; contains any class offset | ||
| 9259 | ) | ||
| 9492 | 9260 | ||
| 9493 | ;; CASE 5J: we are at the topmost level, make | 9261 | ;; CASE 5C.2: hanging colon on an inher intro |
| 9494 | ;; sure we skip back past any access specifiers | 9262 | ((eq char-before-ip ?:) |
| 9495 | ((and | 9263 | (c-beginning-of-statement-1 lim) |
| 9496 | ;; A macro continuation line is never at top level. | 9264 | (c-add-syntax 'inher-intro (c-point 'boi)) |
| 9497 | (not (and macro-start | ||
| 9498 | (> indent-point macro-start))) | ||
| 9499 | (save-excursion | ||
| 9500 | (setq placeholder (point)) | ||
| 9501 | (or (memq char-before-ip '(?\; ?{ ?} nil)) | ||
| 9502 | (c-at-vsemi-p before-ws-ip) | ||
| 9503 | (when (and (eq char-before-ip ?:) | ||
| 9504 | (eq (c-beginning-of-statement-1 lim) | ||
| 9505 | 'label)) | ||
| 9506 | (c-backward-syntactic-ws lim) | ||
| 9507 | (setq placeholder (point))) | ||
| 9508 | (and (c-major-mode-is 'objc-mode) | ||
| 9509 | (catch 'not-in-directive | ||
| 9510 | (c-beginning-of-statement-1 lim) | ||
| 9511 | (setq placeholder (point)) | ||
| 9512 | (while (and (c-forward-objc-directive) | ||
| 9513 | (< (point) indent-point)) | ||
| 9514 | (c-forward-syntactic-ws) | ||
| 9515 | (if (>= (point) indent-point) | ||
| 9516 | (throw 'not-in-directive t)) | ||
| 9517 | (setq placeholder (point))) | ||
| 9518 | nil))))) | ||
| 9519 | ;; For historic reasons we anchor at bol of the last | ||
| 9520 | ;; line of the previous declaration. That's clearly | ||
| 9521 | ;; highly bogus and useless, and it makes our lives hard | ||
| 9522 | ;; to remain compatible. :P | ||
| 9523 | (goto-char placeholder) | ||
| 9524 | (c-add-syntax 'topmost-intro (c-point 'bol)) | ||
| 9525 | (if containing-decl-open | 9265 | (if containing-decl-open |
| 9526 | (if (c-keyword-member containing-decl-kwd | 9266 | (c-add-class-syntax 'inclass |
| 9527 | 'c-other-block-decl-kwds) | 9267 | containing-decl-open |
| 9528 | (progn | 9268 | containing-decl-start |
| 9529 | (goto-char (c-brace-anchor-point containing-decl-open)) | 9269 | containing-decl-kwd |
| 9530 | (c-add-stmt-syntax | 9270 | paren-state))) |
| 9531 | (if (string-equal (symbol-name containing-decl-kwd) | 9271 | |
| 9532 | "extern") | 9272 | ;; CASE 5C.3: in a Java implements/extends |
| 9533 | ;; Special case for compatibility with the | 9273 | (injava-inher |
| 9534 | ;; extern-lang syntactic symbols. | 9274 | (let ((where (cdr injava-inher)) |
| 9535 | 'inextern-lang | 9275 | (cont (car injava-inher))) |
| 9536 | (intern (concat "in" | 9276 | (goto-char where) |
| 9537 | (symbol-name containing-decl-kwd)))) | 9277 | (cond ((looking-at "throws\\>[^_]") |
| 9538 | nil t | 9278 | (c-add-syntax 'func-decl-cont |
| 9539 | (c-most-enclosing-brace paren-state (point)) | 9279 | (progn (c-beginning-of-statement-1 lim) |
| 9540 | paren-state)) | 9280 | (c-point 'boi)))) |
| 9541 | (c-add-class-syntax 'inclass | 9281 | (cont (c-add-syntax 'inher-cont where)) |
| 9542 | containing-decl-open | 9282 | (t (c-add-syntax 'inher-intro |
| 9543 | containing-decl-start | 9283 | (progn (goto-char (cdr injava-inher)) |
| 9544 | containing-decl-kwd | 9284 | (c-beginning-of-statement-1 lim) |
| 9545 | paren-state))) | 9285 | (point)))) |
| 9546 | (when (and c-syntactic-indentation-in-macros | 9286 | ))) |
| 9547 | macro-start | 9287 | |
| 9548 | (/= macro-start (c-point 'boi indent-point))) | 9288 | ;; CASE 5C.4: a continued inheritance line |
| 9549 | (c-add-syntax 'cpp-define-intro) | 9289 | (t |
| 9550 | (setq macro-start nil))) | 9290 | (c-beginning-of-inheritance-list lim) |
| 9551 | 9291 | (c-add-syntax 'inher-cont (point)) | |
| 9552 | ;; CASE 5K: we are at an ObjC method definition | 9292 | ;; don't add inclass symbol since relative point already |
| 9553 | ;; continuation line. | 9293 | ;; contains any class offset |
| 9554 | ((and c-opt-method-key | 9294 | ))) |
| 9295 | |||
| 9296 | ;; CASE 5D: this could be a top-level initialization, a | ||
| 9297 | ;; member init list continuation, or a template argument | ||
| 9298 | ;; list continuation. | ||
| 9299 | ((save-excursion | ||
| 9300 | ;; Note: We use the fact that lim is always after any | ||
| 9301 | ;; preceding brace sexp. | ||
| 9302 | (if c-recognize-<>-arglists | ||
| 9303 | (while (and | ||
| 9304 | (progn | ||
| 9305 | (c-syntactic-skip-backward "^;,=<>" lim t) | ||
| 9306 | (> (point) lim)) | ||
| 9307 | (or | ||
| 9308 | (when c-overloadable-operators-regexp | ||
| 9309 | (when (setq placeholder (c-after-special-operator-id lim)) | ||
| 9310 | (goto-char placeholder) | ||
| 9311 | t)) | ||
| 9312 | (cond | ||
| 9313 | ((eq (char-before) ?>) | ||
| 9314 | (or (c-backward-<>-arglist nil lim) | ||
| 9315 | (backward-char)) | ||
| 9316 | t) | ||
| 9317 | ((eq (char-before) ?<) | ||
| 9318 | (backward-char) | ||
| 9319 | (if (save-excursion | ||
| 9320 | (c-forward-<>-arglist nil)) | ||
| 9321 | (progn (forward-char) | ||
| 9322 | nil) | ||
| 9323 | t)) | ||
| 9324 | (t nil))))) | ||
| 9325 | ;; NB: No c-after-special-operator-id stuff in this | ||
| 9326 | ;; clause - we assume only C++ needs it. | ||
| 9327 | (c-syntactic-skip-backward "^;,=" lim t)) | ||
| 9328 | (memq (char-before) '(?, ?= ?<))) | ||
| 9329 | (cond | ||
| 9330 | |||
| 9331 | ;; CASE 5D.3: perhaps a template list continuation? | ||
| 9332 | ((and (c-major-mode-is 'c++-mode) | ||
| 9333 | (save-excursion | ||
| 9334 | (save-restriction | ||
| 9335 | (c-with-syntax-table c++-template-syntax-table | ||
| 9336 | (goto-char indent-point) | ||
| 9337 | (setq placeholder (c-up-list-backward)) | ||
| 9338 | (and placeholder | ||
| 9339 | (eq (char-after placeholder) ?<)))))) | ||
| 9340 | (c-with-syntax-table c++-template-syntax-table | ||
| 9341 | (goto-char placeholder) | ||
| 9342 | (c-beginning-of-statement-1 lim t) | ||
| 9343 | (if (save-excursion | ||
| 9344 | (c-backward-syntactic-ws lim) | ||
| 9345 | (eq (char-before) ?<)) | ||
| 9346 | ;; In a nested template arglist. | ||
| 9347 | (progn | ||
| 9348 | (goto-char placeholder) | ||
| 9349 | (c-syntactic-skip-backward "^,;" lim t) | ||
| 9350 | (c-forward-syntactic-ws)) | ||
| 9351 | (back-to-indentation))) | ||
| 9352 | ;; FIXME: Should use c-add-stmt-syntax, but it's not yet | ||
| 9353 | ;; template aware. | ||
| 9354 | (c-add-syntax 'template-args-cont (point) placeholder)) | ||
| 9355 | |||
| 9356 | ;; CASE 5D.4: perhaps a multiple inheritance line? | ||
| 9357 | ((and (c-major-mode-is 'c++-mode) | ||
| 9555 | (save-excursion | 9358 | (save-excursion |
| 9556 | (c-beginning-of-statement-1 lim) | 9359 | (c-beginning-of-statement-1 lim) |
| 9557 | (beginning-of-line) | 9360 | (setq placeholder (point)) |
| 9558 | (when (looking-at c-opt-method-key) | 9361 | (if (looking-at "static\\>[^_]") |
| 9559 | (setq placeholder (point))))) | 9362 | (c-forward-token-2 1 nil indent-point)) |
| 9560 | (c-add-syntax 'objc-method-args-cont placeholder)) | 9363 | (and (looking-at c-class-key) |
| 9364 | (zerop (c-forward-token-2 2 nil indent-point)) | ||
| 9365 | (if (eq (char-after) ?<) | ||
| 9366 | (c-with-syntax-table c++-template-syntax-table | ||
| 9367 | (zerop (c-forward-token-2 1 t indent-point))) | ||
| 9368 | t) | ||
| 9369 | (eq (char-after) ?:)))) | ||
| 9370 | (goto-char placeholder) | ||
| 9371 | (c-add-syntax 'inher-cont (c-point 'boi))) | ||
| 9372 | |||
| 9373 | ;; CASE 5D.5: Continuation of the "expression part" of a | ||
| 9374 | ;; top level construct. Or, perhaps, an unrecognised construct. | ||
| 9375 | (t | ||
| 9376 | (while (and (setq placeholder (point)) | ||
| 9377 | (eq (car (c-beginning-of-decl-1 containing-sexp)) | ||
| 9378 | 'same) | ||
| 9379 | (save-excursion | ||
| 9380 | (c-backward-syntactic-ws) | ||
| 9381 | (eq (char-before) ?})) | ||
| 9382 | (< (point) placeholder))) | ||
| 9383 | (c-add-stmt-syntax | ||
| 9384 | (cond | ||
| 9385 | ((eq (point) placeholder) 'statement) ; unrecognised construct | ||
| 9386 | ;; A preceding comma at the top level means that a | ||
| 9387 | ;; new variable declaration starts here. Use | ||
| 9388 | ;; topmost-intro-cont for it, for consistency with | ||
| 9389 | ;; the first variable declaration. C.f. case 5N. | ||
| 9390 | ((eq char-before-ip ?,) 'topmost-intro-cont) | ||
| 9391 | (t 'statement-cont)) | ||
| 9392 | nil nil containing-sexp paren-state)) | ||
| 9393 | )) | ||
| 9561 | 9394 | ||
| 9562 | ;; CASE 5L: we are at the first argument of a template | 9395 | ;; CASE 5F: Close of a non-class declaration level block. |
| 9396 | ((and (eq char-after-ip ?}) | ||
| 9397 | (c-keyword-member containing-decl-kwd | ||
| 9398 | 'c-other-block-decl-kwds)) | ||
| 9399 | ;; This is inconsistent: Should use `containing-decl-open' | ||
| 9400 | ;; here if it's at boi, like in case 5J. | ||
| 9401 | (goto-char containing-decl-start) | ||
| 9402 | (c-add-stmt-syntax | ||
| 9403 | (if (string-equal (symbol-name containing-decl-kwd) "extern") | ||
| 9404 | ;; Special case for compatibility with the | ||
| 9405 | ;; extern-lang syntactic symbols. | ||
| 9406 | 'extern-lang-close | ||
| 9407 | (intern (concat (symbol-name containing-decl-kwd) | ||
| 9408 | "-close"))) | ||
| 9409 | nil t | ||
| 9410 | (c-most-enclosing-brace paren-state (point)) | ||
| 9411 | paren-state)) | ||
| 9412 | |||
| 9413 | ;; CASE 5G: we are looking at the brace which closes the | ||
| 9414 | ;; enclosing nested class decl | ||
| 9415 | ((and containing-sexp | ||
| 9416 | (eq char-after-ip ?}) | ||
| 9417 | (eq containing-decl-open containing-sexp)) | ||
| 9418 | (c-add-class-syntax 'class-close | ||
| 9419 | containing-decl-open | ||
| 9420 | containing-decl-start | ||
| 9421 | containing-decl-kwd | ||
| 9422 | paren-state)) | ||
| 9423 | |||
| 9424 | ;; CASE 5H: we could be looking at subsequent knr-argdecls | ||
| 9425 | ((and c-recognize-knr-p | ||
| 9426 | (not containing-sexp) ; can't be knr inside braces. | ||
| 9427 | (not (eq char-before-ip ?})) | ||
| 9428 | (save-excursion | ||
| 9429 | (setq placeholder (cdr (c-beginning-of-decl-1 lim))) | ||
| 9430 | (and placeholder | ||
| 9431 | ;; Do an extra check to avoid tripping up on | ||
| 9432 | ;; statements that occur in invalid contexts | ||
| 9433 | ;; (e.g. in macro bodies where we don't really | ||
| 9434 | ;; know the context of what we're looking at). | ||
| 9435 | (not (and c-opt-block-stmt-key | ||
| 9436 | (looking-at c-opt-block-stmt-key))))) | ||
| 9437 | (< placeholder indent-point)) | ||
| 9438 | (goto-char placeholder) | ||
| 9439 | (c-add-syntax 'knr-argdecl (point))) | ||
| 9440 | |||
| 9441 | ;; CASE 5I: ObjC method definition. | ||
| 9442 | ((and c-opt-method-key | ||
| 9443 | (looking-at c-opt-method-key)) | ||
| 9444 | (c-beginning-of-statement-1 nil t) | ||
| 9445 | (if (= (point) indent-point) | ||
| 9446 | ;; Handle the case when it's the first (non-comment) | ||
| 9447 | ;; thing in the buffer. Can't look for a 'same return | ||
| 9448 | ;; value from cbos1 since ObjC directives currently | ||
| 9449 | ;; aren't recognized fully, so that we get 'same | ||
| 9450 | ;; instead of 'previous if it moved over a preceding | ||
| 9451 | ;; directive. | ||
| 9452 | (goto-char (point-min))) | ||
| 9453 | (c-add-syntax 'objc-method-intro (c-point 'boi))) | ||
| 9454 | |||
| 9455 | ;; CASE 5P: AWK pattern or function or continuation | ||
| 9456 | ;; thereof. | ||
| 9457 | ((c-major-mode-is 'awk-mode) | ||
| 9458 | (setq placeholder (point)) | ||
| 9459 | (c-add-stmt-syntax | ||
| 9460 | (if (and (eq (c-beginning-of-statement-1) 'same) | ||
| 9461 | (/= (point) placeholder)) | ||
| 9462 | 'topmost-intro-cont | ||
| 9463 | 'topmost-intro) | ||
| 9464 | nil nil | ||
| 9465 | containing-sexp paren-state)) | ||
| 9466 | |||
| 9467 | ;; CASE 5N: At a variable declaration that follows a class | ||
| 9468 | ;; definition or some other block declaration that doesn't | ||
| 9469 | ;; end at the closing '}'. C.f. case 5D.5. | ||
| 9470 | ((progn | ||
| 9471 | (c-backward-syntactic-ws lim) | ||
| 9472 | (and (eq (char-before) ?}) | ||
| 9473 | (save-excursion | ||
| 9474 | (let ((start (point))) | ||
| 9475 | (if (and c-state-cache | ||
| 9476 | (consp (car c-state-cache)) | ||
| 9477 | (eq (cdar c-state-cache) (point))) | ||
| 9478 | ;; Speed up the backward search a bit. | ||
| 9479 | (goto-char (caar c-state-cache))) | ||
| 9480 | (c-beginning-of-decl-1 containing-sexp) | ||
| 9481 | (setq placeholder (point)) | ||
| 9482 | (if (= start (point)) | ||
| 9483 | ;; The '}' is unbalanced. | ||
| 9484 | nil | ||
| 9485 | (c-end-of-decl-1) | ||
| 9486 | (>= (point) indent-point)))))) | ||
| 9487 | (goto-char placeholder) | ||
| 9488 | (c-add-stmt-syntax 'topmost-intro-cont nil nil | ||
| 9489 | containing-sexp paren-state)) | ||
| 9490 | |||
| 9491 | ;; NOTE: The point is at the end of the previous token here. | ||
| 9492 | |||
| 9493 | ;; CASE 5J: we are at the topmost level, make | ||
| 9494 | ;; sure we skip back past any access specifiers | ||
| 9495 | ((and | ||
| 9496 | ;; A macro continuation line is never at top level. | ||
| 9497 | (not (and macro-start | ||
| 9498 | (> indent-point macro-start))) | ||
| 9499 | (save-excursion | ||
| 9500 | (setq placeholder (point)) | ||
| 9501 | (or (memq char-before-ip '(?\; ?{ ?} nil)) | ||
| 9502 | (c-at-vsemi-p before-ws-ip) | ||
| 9503 | (when (and (eq char-before-ip ?:) | ||
| 9504 | (eq (c-beginning-of-statement-1 lim) | ||
| 9505 | 'label)) | ||
| 9506 | (c-backward-syntactic-ws lim) | ||
| 9507 | (setq placeholder (point))) | ||
| 9508 | (and (c-major-mode-is 'objc-mode) | ||
| 9509 | (catch 'not-in-directive | ||
| 9510 | (c-beginning-of-statement-1 lim) | ||
| 9511 | (setq placeholder (point)) | ||
| 9512 | (while (and (c-forward-objc-directive) | ||
| 9513 | (< (point) indent-point)) | ||
| 9514 | (c-forward-syntactic-ws) | ||
| 9515 | (if (>= (point) indent-point) | ||
| 9516 | (throw 'not-in-directive t)) | ||
| 9517 | (setq placeholder (point))) | ||
| 9518 | nil))))) | ||
| 9519 | ;; For historic reasons we anchor at bol of the last | ||
| 9520 | ;; line of the previous declaration. That's clearly | ||
| 9521 | ;; highly bogus and useless, and it makes our lives hard | ||
| 9522 | ;; to remain compatible. :P | ||
| 9523 | (goto-char placeholder) | ||
| 9524 | (c-add-syntax 'topmost-intro (c-point 'bol)) | ||
| 9525 | (if containing-decl-open | ||
| 9526 | (if (c-keyword-member containing-decl-kwd | ||
| 9527 | 'c-other-block-decl-kwds) | ||
| 9528 | (progn | ||
| 9529 | (goto-char (c-brace-anchor-point containing-decl-open)) | ||
| 9530 | (c-add-stmt-syntax | ||
| 9531 | (if (string-equal (symbol-name containing-decl-kwd) | ||
| 9532 | "extern") | ||
| 9533 | ;; Special case for compatibility with the | ||
| 9534 | ;; extern-lang syntactic symbols. | ||
| 9535 | 'inextern-lang | ||
| 9536 | (intern (concat "in" | ||
| 9537 | (symbol-name containing-decl-kwd)))) | ||
| 9538 | nil t | ||
| 9539 | (c-most-enclosing-brace paren-state (point)) | ||
| 9540 | paren-state)) | ||
| 9541 | (c-add-class-syntax 'inclass | ||
| 9542 | containing-decl-open | ||
| 9543 | containing-decl-start | ||
| 9544 | containing-decl-kwd | ||
| 9545 | paren-state))) | ||
| 9546 | (when (and c-syntactic-indentation-in-macros | ||
| 9547 | macro-start | ||
| 9548 | (/= macro-start (c-point 'boi indent-point))) | ||
| 9549 | (c-add-syntax 'cpp-define-intro) | ||
| 9550 | (setq macro-start nil))) | ||
| 9551 | |||
| 9552 | ;; CASE 5K: we are at an ObjC method definition | ||
| 9553 | ;; continuation line. | ||
| 9554 | ((and c-opt-method-key | ||
| 9555 | (save-excursion | ||
| 9556 | (c-beginning-of-statement-1 lim) | ||
| 9557 | (beginning-of-line) | ||
| 9558 | (when (looking-at c-opt-method-key) | ||
| 9559 | (setq placeholder (point))))) | ||
| 9560 | (c-add-syntax 'objc-method-args-cont placeholder)) | ||
| 9561 | |||
| 9562 | ;; CASE 5L: we are at the first argument of a template | ||
| 9563 | ;; arglist that begins on the previous line. | 9563 | ;; arglist that begins on the previous line. |
| 9564 | ((and c-recognize-<>-arglists | 9564 | ((and c-recognize-<>-arglists |
| 9565 | (eq (char-before) ?<) | 9565 | (eq (char-before) ?<) |
| @@ -9573,32 +9573,32 @@ comment at the start of cc-engine.el for more info." | |||
| 9573 | (c-beginning-of-statement-1 containing-sexp) | 9573 | (c-beginning-of-statement-1 containing-sexp) |
| 9574 | (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) | 9574 | (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) |
| 9575 | 9575 | ||
| 9576 | ;;CASE 5N: We are at a tompmost continuation line and the only | 9576 | ;;CASE 5N: We are at a tompmost continuation line and the only |
| 9577 | ;;preceding items are annotations. | 9577 | ;;preceding items are annotations. |
| 9578 | ((and (c-major-mode-is 'java-mode) | 9578 | ((and (c-major-mode-is 'java-mode) |
| 9579 | (setq placeholder (point)) | 9579 | (setq placeholder (point)) |
| 9580 | (c-beginning-of-statement-1) | 9580 | (c-beginning-of-statement-1) |
| 9581 | (progn | 9581 | (progn |
| 9582 | (while (and (c-forward-annotation)) | 9582 | (while (and (c-forward-annotation)) |
| 9583 | (c-forward-syntactic-ws)) | 9583 | (c-forward-syntactic-ws)) |
| 9584 | t) | 9584 | t) |
| 9585 | (prog1 | 9585 | (prog1 |
| 9586 | (>= (point) placeholder) | 9586 | (>= (point) placeholder) |
| 9587 | (goto-char placeholder))) | 9587 | (goto-char placeholder))) |
| 9588 | (c-add-syntax 'annotation-top-cont (c-point 'boi))) | 9588 | (c-add-syntax 'annotation-top-cont (c-point 'boi))) |
| 9589 | 9589 | ||
| 9590 | ;; CASE 5M: we are at a topmost continuation line | 9590 | ;; CASE 5M: we are at a topmost continuation line |
| 9591 | (t | 9591 | (t |
| 9592 | (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) | 9592 | (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) |
| 9593 | (when (c-major-mode-is 'objc-mode) | 9593 | (when (c-major-mode-is 'objc-mode) |
| 9594 | (setq placeholder (point)) | 9594 | (setq placeholder (point)) |
| 9595 | (while (and (c-forward-objc-directive) | 9595 | (while (and (c-forward-objc-directive) |
| 9596 | (< (point) indent-point)) | 9596 | (< (point) indent-point)) |
| 9597 | (c-forward-syntactic-ws) | 9597 | (c-forward-syntactic-ws) |
| 9598 | (setq placeholder (point))) | 9598 | (setq placeholder (point))) |
| 9599 | (goto-char placeholder)) | 9599 | (goto-char placeholder)) |
| 9600 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) | 9600 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) |
| 9601 | )) | 9601 | )) |
| 9602 | 9602 | ||
| 9603 | 9603 | ||
| 9604 | ;; (CASE 6 has been removed.) | 9604 | ;; (CASE 6 has been removed.) |
| @@ -9614,576 +9614,576 @@ comment at the start of cc-engine.el for more info." | |||
| 9614 | (cond | 9614 | (cond |
| 9615 | 9615 | ||
| 9616 | ;; CASE 7A: we are looking at the arglist closing paren. | 9616 | ;; CASE 7A: we are looking at the arglist closing paren. |
| 9617 | ;; C.f. case 7F. | 9617 | ;; C.f. case 7F. |
| 9618 | ((memq char-after-ip '(?\) ?\])) | 9618 | ((memq char-after-ip '(?\) ?\])) |
| 9619 | (goto-char containing-sexp) | 9619 | (goto-char containing-sexp) |
| 9620 | (setq placeholder (c-point 'boi)) | 9620 | (setq placeholder (c-point 'boi)) |
| 9621 | (if (and (c-safe (backward-up-list 1) t) | 9621 | (if (and (c-safe (backward-up-list 1) t) |
| 9622 | (>= (point) placeholder)) | 9622 | (>= (point) placeholder)) |
| 9623 | (progn | 9623 | (progn |
| 9624 | (forward-char) | 9624 | (forward-char) |
| 9625 | (skip-chars-forward " \t")) | 9625 | (skip-chars-forward " \t")) |
| 9626 | (goto-char placeholder)) | 9626 | (goto-char placeholder)) |
| 9627 | (c-add-stmt-syntax 'arglist-close (list containing-sexp) t | 9627 | (c-add-stmt-syntax 'arglist-close (list containing-sexp) t |
| 9628 | (c-most-enclosing-brace paren-state (point)) | 9628 | (c-most-enclosing-brace paren-state (point)) |
| 9629 | paren-state)) | 9629 | paren-state)) |
| 9630 | 9630 | ||
| 9631 | ;; CASE 19: line is an expression, not a statement, and is directly | 9631 | ;; CASE 19: line is an expression, not a statement, and is directly |
| 9632 | ;; contained by a template delimiter. Most likely, we are in a | 9632 | ;; contained by a template delimiter. Most likely, we are in a |
| 9633 | ;; template arglist within a statement. This case is based on CASE | 9633 | ;; template arglist within a statement. This case is based on CASE |
| 9634 | ;; 7. At some point in the future, we may wish to create more | 9634 | ;; 7. At some point in the future, we may wish to create more |
| 9635 | ;; syntactic symbols such as `template-intro', | 9635 | ;; syntactic symbols such as `template-intro', |
| 9636 | ;; `template-cont-nonempty', etc., and distinguish between them as we | 9636 | ;; `template-cont-nonempty', etc., and distinguish between them as we |
| 9637 | ;; do for `arglist-intro' etc. (2009-12-07). | 9637 | ;; do for `arglist-intro' etc. (2009-12-07). |
| 9638 | ((and c-recognize-<>-arglists | 9638 | ((and c-recognize-<>-arglists |
| 9639 | (setq containing-< (c-up-list-backward indent-point containing-sexp)) | 9639 | (setq containing-< (c-up-list-backward indent-point containing-sexp)) |
| 9640 | (eq (char-after containing-<) ?\<)) | 9640 | (eq (char-after containing-<) ?\<)) |
| 9641 | (setq placeholder (c-point 'boi containing-<)) | 9641 | (setq placeholder (c-point 'boi containing-<)) |
| 9642 | (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not | 9642 | (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not |
| 9643 | ; '<') before indent-point. | 9643 | ; '<') before indent-point. |
| 9644 | (if (>= (point) placeholder) | 9644 | (if (>= (point) placeholder) |
| 9645 | (progn | 9645 | (progn |
| 9646 | (forward-char) | 9646 | (forward-char) |
| 9647 | (skip-chars-forward " \t")) | 9647 | (skip-chars-forward " \t")) |
| 9648 | (goto-char placeholder)) | 9648 | (goto-char placeholder)) |
| 9649 | (c-add-stmt-syntax 'template-args-cont (list containing-<) t | 9649 | (c-add-stmt-syntax 'template-args-cont (list containing-<) t |
| 9650 | (c-most-enclosing-brace c-state-cache (point)) | 9650 | (c-most-enclosing-brace c-state-cache (point)) |
| 9651 | paren-state)) | 9651 | paren-state)) |
| 9652 | 9652 | ||
| 9653 | ;; CASE 7B: Looking at the opening brace of an | 9653 | ;; CASE 7B: Looking at the opening brace of an |
| 9654 | ;; in-expression block or brace list. C.f. cases 4, 16A | 9654 | ;; in-expression block or brace list. C.f. cases 4, 16A |
| 9655 | ;; and 17E. | 9655 | ;; and 17E. |
| 9656 | ((and (eq char-after-ip ?{) | 9656 | ((and (eq char-after-ip ?{) |
| 9657 | (progn | 9657 | (progn |
| 9658 | (setq placeholder (c-inside-bracelist-p (point) | 9658 | (setq placeholder (c-inside-bracelist-p (point) |
| 9659 | paren-state)) | 9659 | paren-state)) |
| 9660 | (if placeholder | 9660 | (if placeholder |
| 9661 | (setq tmpsymbol '(brace-list-open . inexpr-class)) | 9661 | (setq tmpsymbol '(brace-list-open . inexpr-class)) |
| 9662 | (setq tmpsymbol '(block-open . inexpr-statement) | 9662 | (setq tmpsymbol '(block-open . inexpr-statement) |
| 9663 | placeholder | 9663 | placeholder |
| 9664 | (cdr-safe (c-looking-at-inexpr-block | 9664 | (cdr-safe (c-looking-at-inexpr-block |
| 9665 | (c-safe-position containing-sexp | 9665 | (c-safe-position containing-sexp |
| 9666 | paren-state) | 9666 | paren-state) |
| 9667 | containing-sexp))) | 9667 | containing-sexp))) |
| 9668 | ;; placeholder is nil if it's a block directly in | 9668 | ;; placeholder is nil if it's a block directly in |
| 9669 | ;; a function arglist. That makes us skip out of | 9669 | ;; a function arglist. That makes us skip out of |
| 9670 | ;; this case. | 9670 | ;; this case. |
| 9671 | ))) | 9671 | ))) |
| 9672 | (goto-char placeholder) | 9672 | (goto-char placeholder) |
| 9673 | (back-to-indentation) | 9673 | (back-to-indentation) |
| 9674 | (c-add-stmt-syntax (car tmpsymbol) nil t | 9674 | (c-add-stmt-syntax (car tmpsymbol) nil t |
| 9675 | (c-most-enclosing-brace paren-state (point)) | 9675 | (c-most-enclosing-brace paren-state (point)) |
| 9676 | paren-state) | 9676 | paren-state) |
| 9677 | (if (/= (point) placeholder) | 9677 | (if (/= (point) placeholder) |
| 9678 | (c-add-syntax (cdr tmpsymbol)))) | 9678 | (c-add-syntax (cdr tmpsymbol)))) |
| 9679 | |||
| 9680 | ;; CASE 7C: we are looking at the first argument in an empty | ||
| 9681 | ;; argument list. Use arglist-close if we're actually | ||
| 9682 | ;; looking at a close paren or bracket. | ||
| 9683 | ((memq char-before-ip '(?\( ?\[)) | ||
| 9684 | (goto-char containing-sexp) | ||
| 9685 | (setq placeholder (c-point 'boi)) | ||
| 9686 | (if (and (c-safe (backward-up-list 1) t) | ||
| 9687 | (>= (point) placeholder)) | ||
| 9688 | (progn | ||
| 9689 | (forward-char) | ||
| 9690 | (skip-chars-forward " \t")) | ||
| 9691 | (goto-char placeholder)) | ||
| 9692 | (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t | ||
| 9693 | (c-most-enclosing-brace paren-state (point)) | ||
| 9694 | paren-state)) | ||
| 9679 | 9695 | ||
| 9680 | ;; CASE 7C: we are looking at the first argument in an empty | 9696 | ;; CASE 7D: we are inside a conditional test clause. treat |
| 9681 | ;; argument list. Use arglist-close if we're actually | 9697 | ;; these things as statements |
| 9682 | ;; looking at a close paren or bracket. | 9698 | ((progn |
| 9683 | ((memq char-before-ip '(?\( ?\[)) | ||
| 9684 | (goto-char containing-sexp) | 9699 | (goto-char containing-sexp) |
| 9685 | (setq placeholder (c-point 'boi)) | 9700 | (and (c-safe (c-forward-sexp -1) t) |
| 9686 | (if (and (c-safe (backward-up-list 1) t) | 9701 | (looking-at "\\<for\\>[^_]"))) |
| 9687 | (>= (point) placeholder)) | 9702 | (goto-char (1+ containing-sexp)) |
| 9688 | (progn | 9703 | (c-forward-syntactic-ws indent-point) |
| 9689 | (forward-char) | 9704 | (if (eq char-before-ip ?\;) |
| 9690 | (skip-chars-forward " \t")) | 9705 | (c-add-syntax 'statement (point)) |
| 9691 | (goto-char placeholder)) | 9706 | (c-add-syntax 'statement-cont (point)) |
| 9692 | (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t | 9707 | )) |
| 9693 | (c-most-enclosing-brace paren-state (point)) | 9708 | |
| 9694 | paren-state)) | 9709 | ;; CASE 7E: maybe a continued ObjC method call. This is the |
| 9710 | ;; case when we are inside a [] bracketed exp, and what | ||
| 9711 | ;; precede the opening bracket is not an identifier. | ||
| 9712 | ((and c-opt-method-key | ||
| 9713 | (eq (char-after containing-sexp) ?\[) | ||
| 9714 | (progn | ||
| 9715 | (goto-char (1- containing-sexp)) | ||
| 9716 | (c-backward-syntactic-ws (c-point 'bod)) | ||
| 9717 | (if (not (looking-at c-symbol-key)) | ||
| 9718 | (c-add-syntax 'objc-method-call-cont containing-sexp)) | ||
| 9719 | ))) | ||
| 9695 | 9720 | ||
| 9696 | ;; CASE 7D: we are inside a conditional test clause. treat | 9721 | ;; CASE 7F: we are looking at an arglist continuation line, |
| 9697 | ;; these things as statements | 9722 | ;; but the preceding argument is on the same line as the |
| 9698 | ((progn | 9723 | ;; opening paren. This case includes multi-line |
| 9699 | (goto-char containing-sexp) | 9724 | ;; mathematical paren groupings, but we could be on a |
| 9700 | (and (c-safe (c-forward-sexp -1) t) | 9725 | ;; for-list continuation line. C.f. case 7A. |
| 9701 | (looking-at "\\<for\\>[^_]"))) | 9726 | ((progn |
| 9702 | (goto-char (1+ containing-sexp)) | 9727 | (goto-char (1+ containing-sexp)) |
| 9703 | (c-forward-syntactic-ws indent-point) | 9728 | (< (save-excursion |
| 9704 | (if (eq char-before-ip ?\;) | 9729 | (c-forward-syntactic-ws) |
| 9705 | (c-add-syntax 'statement (point)) | 9730 | (point)) |
| 9706 | (c-add-syntax 'statement-cont (point)) | 9731 | (c-point 'bonl))) |
| 9707 | )) | 9732 | (goto-char containing-sexp) ; paren opening the arglist |
| 9708 | 9733 | (setq placeholder (c-point 'boi)) | |
| 9709 | ;; CASE 7E: maybe a continued ObjC method call. This is the | 9734 | (if (and (c-safe (backward-up-list 1) t) |
| 9710 | ;; case when we are inside a [] bracketed exp, and what | 9735 | (>= (point) placeholder)) |
| 9711 | ;; precede the opening bracket is not an identifier. | 9736 | (progn |
| 9712 | ((and c-opt-method-key | 9737 | (forward-char) |
| 9713 | (eq (char-after containing-sexp) ?\[) | 9738 | (skip-chars-forward " \t")) |
| 9714 | (progn | 9739 | (goto-char placeholder)) |
| 9715 | (goto-char (1- containing-sexp)) | 9740 | (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t |
| 9716 | (c-backward-syntactic-ws (c-point 'bod)) | 9741 | (c-most-enclosing-brace c-state-cache (point)) |
| 9717 | (if (not (looking-at c-symbol-key)) | 9742 | paren-state)) |
| 9718 | (c-add-syntax 'objc-method-call-cont containing-sexp)) | ||
| 9719 | ))) | ||
| 9720 | 9743 | ||
| 9721 | ;; CASE 7F: we are looking at an arglist continuation line, | 9744 | ;; CASE 7G: we are looking at just a normal arglist |
| 9722 | ;; but the preceding argument is on the same line as the | 9745 | ;; continuation line |
| 9723 | ;; opening paren. This case includes multi-line | 9746 | (t (c-forward-syntactic-ws indent-point) |
| 9724 | ;; mathematical paren groupings, but we could be on a | 9747 | (c-add-syntax 'arglist-cont (c-point 'boi))) |
| 9725 | ;; for-list continuation line. C.f. case 7A. | 9748 | )) |
| 9726 | ((progn | ||
| 9727 | (goto-char (1+ containing-sexp)) | ||
| 9728 | (< (save-excursion | ||
| 9729 | (c-forward-syntactic-ws) | ||
| 9730 | (point)) | ||
| 9731 | (c-point 'bonl))) | ||
| 9732 | (goto-char containing-sexp) ; paren opening the arglist | ||
| 9733 | (setq placeholder (c-point 'boi)) | ||
| 9734 | (if (and (c-safe (backward-up-list 1) t) | ||
| 9735 | (>= (point) placeholder)) | ||
| 9736 | (progn | ||
| 9737 | (forward-char) | ||
| 9738 | (skip-chars-forward " \t")) | ||
| 9739 | (goto-char placeholder)) | ||
| 9740 | (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t | ||
| 9741 | (c-most-enclosing-brace c-state-cache (point)) | ||
| 9742 | paren-state)) | ||
| 9743 | 9749 | ||
| 9744 | ;; CASE 7G: we are looking at just a normal arglist | 9750 | ;; CASE 8: func-local multi-inheritance line |
| 9745 | ;; continuation line | 9751 | ((and (c-major-mode-is 'c++-mode) |
| 9746 | (t (c-forward-syntactic-ws indent-point) | 9752 | (save-excursion |
| 9747 | (c-add-syntax 'arglist-cont (c-point 'boi))) | 9753 | (goto-char indent-point) |
| 9748 | )) | 9754 | (skip-chars-forward " \t") |
| 9755 | (looking-at c-opt-postfix-decl-spec-key))) | ||
| 9756 | (goto-char indent-point) | ||
| 9757 | (skip-chars-forward " \t") | ||
| 9758 | (cond | ||
| 9749 | 9759 | ||
| 9750 | ;; CASE 8: func-local multi-inheritance line | 9760 | ;; CASE 8A: non-hanging colon on an inher intro |
| 9751 | ((and (c-major-mode-is 'c++-mode) | 9761 | ((eq char-after-ip ?:) |
| 9752 | (save-excursion | 9762 | (c-backward-syntactic-ws lim) |
| 9753 | (goto-char indent-point) | 9763 | (c-add-syntax 'inher-intro (c-point 'boi))) |
| 9754 | (skip-chars-forward " \t") | ||
| 9755 | (looking-at c-opt-postfix-decl-spec-key))) | ||
| 9756 | (goto-char indent-point) | ||
| 9757 | (skip-chars-forward " \t") | ||
| 9758 | (cond | ||
| 9759 | 9764 | ||
| 9760 | ;; CASE 8A: non-hanging colon on an inher intro | 9765 | ;; CASE 8B: hanging colon on an inher intro |
| 9761 | ((eq char-after-ip ?:) | 9766 | ((eq char-before-ip ?:) |
| 9762 | (c-backward-syntactic-ws lim) | 9767 | (c-add-syntax 'inher-intro (c-point 'boi))) |
| 9763 | (c-add-syntax 'inher-intro (c-point 'boi))) | ||
| 9764 | 9768 | ||
| 9765 | ;; CASE 8B: hanging colon on an inher intro | 9769 | ;; CASE 8C: a continued inheritance line |
| 9766 | ((eq char-before-ip ?:) | 9770 | (t |
| 9767 | (c-add-syntax 'inher-intro (c-point 'boi))) | 9771 | (c-beginning-of-inheritance-list lim) |
| 9772 | (c-add-syntax 'inher-cont (point)) | ||
| 9773 | ))) | ||
| 9774 | |||
| 9775 | ;; CASE 9: we are inside a brace-list | ||
| 9776 | ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29) | ||
| 9777 | (setq special-brace-list | ||
| 9778 | (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!! | ||
| 9779 | (save-excursion | ||
| 9780 | (goto-char containing-sexp) | ||
| 9781 | (c-looking-at-special-brace-list))) | ||
| 9782 | (c-inside-bracelist-p containing-sexp paren-state)))) | ||
| 9783 | (cond | ||
| 9768 | 9784 | ||
| 9769 | ;; CASE 8C: a continued inheritance line | 9785 | ;; CASE 9A: In the middle of a special brace list opener. |
| 9770 | (t | 9786 | ((and (consp special-brace-list) |
| 9771 | (c-beginning-of-inheritance-list lim) | 9787 | (save-excursion |
| 9772 | (c-add-syntax 'inher-cont (point)) | 9788 | (goto-char containing-sexp) |
| 9773 | ))) | 9789 | (eq (char-after) ?\()) |
| 9790 | (eq char-after-ip (car (cdr special-brace-list)))) | ||
| 9791 | (goto-char (car (car special-brace-list))) | ||
| 9792 | (skip-chars-backward " \t") | ||
| 9793 | (if (and (bolp) | ||
| 9794 | (assoc 'statement-cont | ||
| 9795 | (setq placeholder (c-guess-basic-syntax)))) | ||
| 9796 | (setq c-syntactic-context placeholder) | ||
| 9797 | (c-beginning-of-statement-1 | ||
| 9798 | (c-safe-position (1- containing-sexp) paren-state)) | ||
| 9799 | (c-forward-token-2 0) | ||
| 9800 | (while (looking-at c-specifier-key) | ||
| 9801 | (goto-char (match-end 1)) | ||
| 9802 | (c-forward-syntactic-ws)) | ||
| 9803 | (c-add-syntax 'brace-list-open (c-point 'boi)))) | ||
| 9804 | |||
| 9805 | ;; CASE 9B: brace-list-close brace | ||
| 9806 | ((if (consp special-brace-list) | ||
| 9807 | ;; Check special brace list closer. | ||
| 9808 | (progn | ||
| 9809 | (goto-char (car (car special-brace-list))) | ||
| 9810 | (save-excursion | ||
| 9811 | (goto-char indent-point) | ||
| 9812 | (back-to-indentation) | ||
| 9813 | (or | ||
| 9814 | ;; We were between the special close char and the `)'. | ||
| 9815 | (and (eq (char-after) ?\)) | ||
| 9816 | (eq (1+ (point)) (cdr (car special-brace-list)))) | ||
| 9817 | ;; We were before the special close char. | ||
| 9818 | (and (eq (char-after) (cdr (cdr special-brace-list))) | ||
| 9819 | (zerop (c-forward-token-2)) | ||
| 9820 | (eq (1+ (point)) (cdr (car special-brace-list))))))) | ||
| 9821 | ;; Normal brace list check. | ||
| 9822 | (and (eq char-after-ip ?}) | ||
| 9823 | (c-safe (goto-char (c-up-list-backward (point))) t) | ||
| 9824 | (= (point) containing-sexp))) | ||
| 9825 | (if (eq (point) (c-point 'boi)) | ||
| 9826 | (c-add-syntax 'brace-list-close (point)) | ||
| 9827 | (setq lim (c-most-enclosing-brace c-state-cache (point))) | ||
| 9828 | (c-beginning-of-statement-1 lim) | ||
| 9829 | (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) | ||
| 9774 | 9830 | ||
| 9775 | ;; CASE 9: we are inside a brace-list | 9831 | (t |
| 9776 | ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29) | 9832 | ;; Prepare for the rest of the cases below by going to the |
| 9777 | (setq special-brace-list | 9833 | ;; token following the opening brace |
| 9778 | (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!! | 9834 | (if (consp special-brace-list) |
| 9779 | (save-excursion | 9835 | (progn |
| 9780 | (goto-char containing-sexp) | 9836 | (goto-char (car (car special-brace-list))) |
| 9781 | (c-looking-at-special-brace-list))) | 9837 | (c-forward-token-2 1 nil indent-point)) |
| 9782 | (c-inside-bracelist-p containing-sexp paren-state)))) | 9838 | (goto-char containing-sexp)) |
| 9839 | (forward-char) | ||
| 9840 | (let ((start (point))) | ||
| 9841 | (c-forward-syntactic-ws indent-point) | ||
| 9842 | (goto-char (max start (c-point 'bol)))) | ||
| 9843 | (c-skip-ws-forward indent-point) | ||
| 9783 | (cond | 9844 | (cond |
| 9784 | 9845 | ||
| 9785 | ;; CASE 9A: In the middle of a special brace list opener. | 9846 | ;; CASE 9C: we're looking at the first line in a brace-list |
| 9786 | ((and (consp special-brace-list) | 9847 | ((= (point) indent-point) |
| 9787 | (save-excursion | 9848 | (if (consp special-brace-list) |
| 9788 | (goto-char containing-sexp) | 9849 | (goto-char (car (car special-brace-list))) |
| 9789 | (eq (char-after) ?\()) | 9850 | (goto-char containing-sexp)) |
| 9790 | (eq char-after-ip (car (cdr special-brace-list)))) | ||
| 9791 | (goto-char (car (car special-brace-list))) | ||
| 9792 | (skip-chars-backward " \t") | ||
| 9793 | (if (and (bolp) | ||
| 9794 | (assoc 'statement-cont | ||
| 9795 | (setq placeholder (c-guess-basic-syntax)))) | ||
| 9796 | (setq c-syntactic-context placeholder) | ||
| 9797 | (c-beginning-of-statement-1 | ||
| 9798 | (c-safe-position (1- containing-sexp) paren-state)) | ||
| 9799 | (c-forward-token-2 0) | ||
| 9800 | (while (looking-at c-specifier-key) | ||
| 9801 | (goto-char (match-end 1)) | ||
| 9802 | (c-forward-syntactic-ws)) | ||
| 9803 | (c-add-syntax 'brace-list-open (c-point 'boi)))) | ||
| 9804 | |||
| 9805 | ;; CASE 9B: brace-list-close brace | ||
| 9806 | ((if (consp special-brace-list) | ||
| 9807 | ;; Check special brace list closer. | ||
| 9808 | (progn | ||
| 9809 | (goto-char (car (car special-brace-list))) | ||
| 9810 | (save-excursion | ||
| 9811 | (goto-char indent-point) | ||
| 9812 | (back-to-indentation) | ||
| 9813 | (or | ||
| 9814 | ;; We were between the special close char and the `)'. | ||
| 9815 | (and (eq (char-after) ?\)) | ||
| 9816 | (eq (1+ (point)) (cdr (car special-brace-list)))) | ||
| 9817 | ;; We were before the special close char. | ||
| 9818 | (and (eq (char-after) (cdr (cdr special-brace-list))) | ||
| 9819 | (zerop (c-forward-token-2)) | ||
| 9820 | (eq (1+ (point)) (cdr (car special-brace-list))))))) | ||
| 9821 | ;; Normal brace list check. | ||
| 9822 | (and (eq char-after-ip ?}) | ||
| 9823 | (c-safe (goto-char (c-up-list-backward (point))) t) | ||
| 9824 | (= (point) containing-sexp))) | ||
| 9825 | (if (eq (point) (c-point 'boi)) | 9851 | (if (eq (point) (c-point 'boi)) |
| 9826 | (c-add-syntax 'brace-list-close (point)) | 9852 | (c-add-syntax 'brace-list-intro (point)) |
| 9827 | (setq lim (c-most-enclosing-brace c-state-cache (point))) | 9853 | (setq lim (c-most-enclosing-brace c-state-cache (point))) |
| 9828 | (c-beginning-of-statement-1 lim) | 9854 | (c-beginning-of-statement-1 lim) |
| 9829 | (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) | 9855 | (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) |
| 9830 | 9856 | ||
| 9831 | (t | 9857 | ;; CASE 9D: this is just a later brace-list-entry or |
| 9832 | ;; Prepare for the rest of the cases below by going to the | 9858 | ;; brace-entry-open |
| 9833 | ;; token following the opening brace | 9859 | (t (if (or (eq char-after-ip ?{) |
| 9834 | (if (consp special-brace-list) | 9860 | (and c-special-brace-lists |
| 9835 | (progn | 9861 | (save-excursion |
| 9836 | (goto-char (car (car special-brace-list))) | 9862 | (goto-char indent-point) |
| 9837 | (c-forward-token-2 1 nil indent-point)) | 9863 | (c-forward-syntactic-ws (c-point 'eol)) |
| 9838 | (goto-char containing-sexp)) | 9864 | (c-looking-at-special-brace-list (point))))) |
| 9839 | (forward-char) | 9865 | (c-add-syntax 'brace-entry-open (point)) |
| 9840 | (let ((start (point))) | 9866 | (c-add-syntax 'brace-list-entry (point)) |
| 9841 | (c-forward-syntactic-ws indent-point) | 9867 | )) |
| 9842 | (goto-char (max start (c-point 'bol)))) | 9868 | )))) |
| 9843 | (c-skip-ws-forward indent-point) | 9869 | |
| 9844 | (cond | 9870 | ;; CASE 10: A continued statement or top level construct. |
| 9871 | ((and (not (memq char-before-ip '(?\; ?:))) | ||
| 9872 | (not (c-at-vsemi-p before-ws-ip)) | ||
| 9873 | (or (not (eq char-before-ip ?})) | ||
| 9874 | (c-looking-at-inexpr-block-backward c-state-cache)) | ||
| 9875 | (> (point) | ||
| 9876 | (save-excursion | ||
| 9877 | (c-beginning-of-statement-1 containing-sexp) | ||
| 9878 | (setq placeholder (point)))) | ||
| 9879 | (/= placeholder containing-sexp)) | ||
| 9880 | ;; This is shared with case 18. | ||
| 9881 | (c-guess-continued-construct indent-point | ||
| 9882 | char-after-ip | ||
| 9883 | placeholder | ||
| 9884 | containing-sexp | ||
| 9885 | paren-state)) | ||
| 9886 | |||
| 9887 | ;; CASE 16: block close brace, possibly closing the defun or | ||
| 9888 | ;; the class | ||
| 9889 | ((eq char-after-ip ?}) | ||
| 9890 | ;; From here on we have the next containing sexp in lim. | ||
| 9891 | (setq lim (c-most-enclosing-brace paren-state)) | ||
| 9892 | (goto-char containing-sexp) | ||
| 9893 | (cond | ||
| 9845 | 9894 | ||
| 9846 | ;; CASE 9C: we're looking at the first line in a brace-list | 9895 | ;; CASE 16E: Closing a statement block? This catches |
| 9847 | ((= (point) indent-point) | 9896 | ;; cases where it's preceded by a statement keyword, |
| 9848 | (if (consp special-brace-list) | 9897 | ;; which works even when used in an "invalid" context, |
| 9849 | (goto-char (car (car special-brace-list))) | 9898 | ;; e.g. a macro argument. |
| 9850 | (goto-char containing-sexp)) | 9899 | ((c-after-conditional) |
| 9851 | (if (eq (point) (c-point 'boi)) | 9900 | (c-backward-to-block-anchor lim) |
| 9852 | (c-add-syntax 'brace-list-intro (point)) | 9901 | (c-add-stmt-syntax 'block-close nil t lim paren-state)) |
| 9853 | (setq lim (c-most-enclosing-brace c-state-cache (point))) | 9902 | |
| 9854 | (c-beginning-of-statement-1 lim) | 9903 | ;; CASE 16A: closing a lambda defun or an in-expression |
| 9855 | (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) | 9904 | ;; block? C.f. cases 4, 7B and 17E. |
| 9856 | 9905 | ((setq placeholder (c-looking-at-inexpr-block | |
| 9857 | ;; CASE 9D: this is just a later brace-list-entry or | 9906 | (c-safe-position containing-sexp paren-state) |
| 9858 | ;; brace-entry-open | 9907 | nil)) |
| 9859 | (t (if (or (eq char-after-ip ?{) | 9908 | (setq tmpsymbol (if (eq (car placeholder) 'inlambda) |
| 9860 | (and c-special-brace-lists | 9909 | 'inline-close |
| 9861 | (save-excursion | 9910 | 'block-close)) |
| 9862 | (goto-char indent-point) | ||
| 9863 | (c-forward-syntactic-ws (c-point 'eol)) | ||
| 9864 | (c-looking-at-special-brace-list (point))))) | ||
| 9865 | (c-add-syntax 'brace-entry-open (point)) | ||
| 9866 | (c-add-syntax 'brace-list-entry (point)) | ||
| 9867 | )) | ||
| 9868 | )))) | ||
| 9869 | |||
| 9870 | ;; CASE 10: A continued statement or top level construct. | ||
| 9871 | ((and (not (memq char-before-ip '(?\; ?:))) | ||
| 9872 | (not (c-at-vsemi-p before-ws-ip)) | ||
| 9873 | (or (not (eq char-before-ip ?})) | ||
| 9874 | (c-looking-at-inexpr-block-backward c-state-cache)) | ||
| 9875 | (> (point) | ||
| 9876 | (save-excursion | ||
| 9877 | (c-beginning-of-statement-1 containing-sexp) | ||
| 9878 | (setq placeholder (point)))) | ||
| 9879 | (/= placeholder containing-sexp)) | ||
| 9880 | ;; This is shared with case 18. | ||
| 9881 | (c-guess-continued-construct indent-point | ||
| 9882 | char-after-ip | ||
| 9883 | placeholder | ||
| 9884 | containing-sexp | ||
| 9885 | paren-state)) | ||
| 9886 | |||
| 9887 | ;; CASE 16: block close brace, possibly closing the defun or | ||
| 9888 | ;; the class | ||
| 9889 | ((eq char-after-ip ?}) | ||
| 9890 | ;; From here on we have the next containing sexp in lim. | ||
| 9891 | (setq lim (c-most-enclosing-brace paren-state)) | ||
| 9892 | (goto-char containing-sexp) | 9911 | (goto-char containing-sexp) |
| 9893 | (cond | 9912 | (back-to-indentation) |
| 9913 | (if (= containing-sexp (point)) | ||
| 9914 | (c-add-syntax tmpsymbol (point)) | ||
| 9915 | (goto-char (cdr placeholder)) | ||
| 9916 | (back-to-indentation) | ||
| 9917 | (c-add-stmt-syntax tmpsymbol nil t | ||
| 9918 | (c-most-enclosing-brace paren-state (point)) | ||
| 9919 | paren-state) | ||
| 9920 | (if (/= (point) (cdr placeholder)) | ||
| 9921 | (c-add-syntax (car placeholder))))) | ||
| 9894 | 9922 | ||
| 9895 | ;; CASE 16E: Closing a statement block? This catches | 9923 | ;; CASE 16B: does this close an inline or a function in |
| 9896 | ;; cases where it's preceded by a statement keyword, | 9924 | ;; a non-class declaration level block? |
| 9897 | ;; which works even when used in an "invalid" context, | 9925 | ((save-excursion |
| 9898 | ;; e.g. a macro argument. | 9926 | (and lim |
| 9899 | ((c-after-conditional) | 9927 | (progn |
| 9900 | (c-backward-to-block-anchor lim) | 9928 | (goto-char lim) |
| 9901 | (c-add-stmt-syntax 'block-close nil t lim paren-state)) | 9929 | (c-looking-at-decl-block |
| 9902 | 9930 | (c-most-enclosing-brace paren-state lim) | |
| 9903 | ;; CASE 16A: closing a lambda defun or an in-expression | 9931 | nil)) |
| 9904 | ;; block? C.f. cases 4, 7B and 17E. | 9932 | (setq placeholder (point)))) |
| 9905 | ((setq placeholder (c-looking-at-inexpr-block | 9933 | (c-backward-to-decl-anchor lim) |
| 9906 | (c-safe-position containing-sexp paren-state) | 9934 | (back-to-indentation) |
| 9907 | nil)) | 9935 | (if (save-excursion |
| 9908 | (setq tmpsymbol (if (eq (car placeholder) 'inlambda) | 9936 | (goto-char placeholder) |
| 9909 | 'inline-close | 9937 | (looking-at c-other-decl-block-key)) |
| 9910 | 'block-close)) | 9938 | (c-add-syntax 'defun-close (point)) |
| 9911 | (goto-char containing-sexp) | 9939 | (c-add-syntax 'inline-close (point)))) |
| 9912 | (back-to-indentation) | 9940 | |
| 9913 | (if (= containing-sexp (point)) | 9941 | ;; CASE 16F: Can be a defun-close of a function declared |
| 9914 | (c-add-syntax tmpsymbol (point)) | 9942 | ;; in a statement block, e.g. in Pike or when using gcc |
| 9915 | (goto-char (cdr placeholder)) | 9943 | ;; extensions, but watch out for macros followed by |
| 9916 | (back-to-indentation) | 9944 | ;; blocks. Let it through to be handled below. |
| 9917 | (c-add-stmt-syntax tmpsymbol nil t | 9945 | ;; C.f. cases B.3 and 17G. |
| 9918 | (c-most-enclosing-brace paren-state (point)) | 9946 | ((save-excursion |
| 9919 | paren-state) | 9947 | (and (not (c-at-statement-start-p)) |
| 9920 | (if (/= (point) (cdr placeholder)) | 9948 | (eq (c-beginning-of-statement-1 lim nil nil t) 'same) |
| 9921 | (c-add-syntax (car placeholder))))) | 9949 | (setq placeholder (point)) |
| 9922 | 9950 | (let ((c-recognize-typeless-decls nil)) | |
| 9923 | ;; CASE 16B: does this close an inline or a function in | 9951 | ;; Turn off recognition of constructs that |
| 9924 | ;; a non-class declaration level block? | 9952 | ;; lacks a type in this case, since that's more |
| 9925 | ((save-excursion | 9953 | ;; likely to be a macro followed by a block. |
| 9926 | (and lim | 9954 | (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) |
| 9927 | (progn | 9955 | (back-to-indentation) |
| 9928 | (goto-char lim) | 9956 | (if (/= (point) containing-sexp) |
| 9929 | (c-looking-at-decl-block | 9957 | (goto-char placeholder)) |
| 9930 | (c-most-enclosing-brace paren-state lim) | 9958 | (c-add-stmt-syntax 'defun-close nil t lim paren-state)) |
| 9931 | nil)) | 9959 | |
| 9932 | (setq placeholder (point)))) | 9960 | ;; CASE 16C: If there is an enclosing brace then this is |
| 9933 | (c-backward-to-decl-anchor lim) | 9961 | ;; a block close since defun closes inside declaration |
| 9934 | (back-to-indentation) | 9962 | ;; level blocks have been handled above. |
| 9935 | (if (save-excursion | 9963 | (lim |
| 9936 | (goto-char placeholder) | 9964 | ;; If the block is preceded by a case/switch label on |
| 9937 | (looking-at c-other-decl-block-key)) | 9965 | ;; the same line, we anchor at the first preceding label |
| 9938 | (c-add-syntax 'defun-close (point)) | 9966 | ;; at boi. The default handling in c-add-stmt-syntax |
| 9939 | (c-add-syntax 'inline-close (point)))) | 9967 | ;; really fixes it better, but we do like this to keep |
| 9940 | 9968 | ;; the indentation compatible with version 5.28 and | |
| 9941 | ;; CASE 16F: Can be a defun-close of a function declared | 9969 | ;; earlier. C.f. case 17H. |
| 9942 | ;; in a statement block, e.g. in Pike or when using gcc | 9970 | (while (and (/= (setq placeholder (point)) (c-point 'boi)) |
| 9943 | ;; extensions, but watch out for macros followed by | 9971 | (eq (c-beginning-of-statement-1 lim) 'label))) |
| 9944 | ;; blocks. Let it through to be handled below. | 9972 | (goto-char placeholder) |
| 9945 | ;; C.f. cases B.3 and 17G. | 9973 | (if (looking-at c-label-kwds-regexp) |
| 9946 | ((save-excursion | 9974 | (c-add-syntax 'block-close (point)) |
| 9947 | (and (not (c-at-statement-start-p)) | 9975 | (goto-char containing-sexp) |
| 9948 | (eq (c-beginning-of-statement-1 lim nil nil t) 'same) | 9976 | ;; c-backward-to-block-anchor not necessary here; those |
| 9949 | (setq placeholder (point)) | 9977 | ;; situations are handled in case 16E above. |
| 9950 | (let ((c-recognize-typeless-decls nil)) | 9978 | (c-add-stmt-syntax 'block-close nil t lim paren-state))) |
| 9951 | ;; Turn off recognition of constructs that | ||
| 9952 | ;; lacks a type in this case, since that's more | ||
| 9953 | ;; likely to be a macro followed by a block. | ||
| 9954 | (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) | ||
| 9955 | (back-to-indentation) | ||
| 9956 | (if (/= (point) containing-sexp) | ||
| 9957 | (goto-char placeholder)) | ||
| 9958 | (c-add-stmt-syntax 'defun-close nil t lim paren-state)) | ||
| 9959 | |||
| 9960 | ;; CASE 16C: If there is an enclosing brace then this is | ||
| 9961 | ;; a block close since defun closes inside declaration | ||
| 9962 | ;; level blocks have been handled above. | ||
| 9963 | (lim | ||
| 9964 | ;; If the block is preceded by a case/switch label on | ||
| 9965 | ;; the same line, we anchor at the first preceding label | ||
| 9966 | ;; at boi. The default handling in c-add-stmt-syntax | ||
| 9967 | ;; really fixes it better, but we do like this to keep | ||
| 9968 | ;; the indentation compatible with version 5.28 and | ||
| 9969 | ;; earlier. C.f. case 17H. | ||
| 9970 | (while (and (/= (setq placeholder (point)) (c-point 'boi)) | ||
| 9971 | (eq (c-beginning-of-statement-1 lim) 'label))) | ||
| 9972 | (goto-char placeholder) | ||
| 9973 | (if (looking-at c-label-kwds-regexp) | ||
| 9974 | (c-add-syntax 'block-close (point)) | ||
| 9975 | (goto-char containing-sexp) | ||
| 9976 | ;; c-backward-to-block-anchor not necessary here; those | ||
| 9977 | ;; situations are handled in case 16E above. | ||
| 9978 | (c-add-stmt-syntax 'block-close nil t lim paren-state))) | ||
| 9979 | |||
| 9980 | ;; CASE 16D: Only top level defun close left. | ||
| 9981 | (t | ||
| 9982 | (goto-char containing-sexp) | ||
| 9983 | (c-backward-to-decl-anchor lim) | ||
| 9984 | (c-add-stmt-syntax 'defun-close nil nil | ||
| 9985 | (c-most-enclosing-brace paren-state) | ||
| 9986 | paren-state)) | ||
| 9987 | )) | ||
| 9988 | 9979 | ||
| 9989 | ;; CASE 17: Statement or defun catchall. | 9980 | ;; CASE 16D: Only top level defun close left. |
| 9990 | (t | 9981 | (t |
| 9991 | (goto-char indent-point) | 9982 | (goto-char containing-sexp) |
| 9992 | ;; Back up statements until we find one that starts at boi. | 9983 | (c-backward-to-decl-anchor lim) |
| 9993 | (while (let* ((prev-point (point)) | 9984 | (c-add-stmt-syntax 'defun-close nil nil |
| 9994 | (last-step-type (c-beginning-of-statement-1 | 9985 | (c-most-enclosing-brace paren-state) |
| 9995 | containing-sexp))) | 9986 | paren-state)) |
| 9996 | (if (= (point) prev-point) | 9987 | )) |
| 9997 | (progn | ||
| 9998 | (setq step-type (or step-type last-step-type)) | ||
| 9999 | nil) | ||
| 10000 | (setq step-type last-step-type) | ||
| 10001 | (/= (point) (c-point 'boi))))) | ||
| 10002 | (cond | ||
| 10003 | 9988 | ||
| 10004 | ;; CASE 17B: continued statement | 9989 | ;; CASE 17: Statement or defun catchall. |
| 10005 | ((and (eq step-type 'same) | 9990 | (t |
| 10006 | (/= (point) indent-point)) | 9991 | (goto-char indent-point) |
| 10007 | (c-add-stmt-syntax 'statement-cont nil nil | 9992 | ;; Back up statements until we find one that starts at boi. |
| 10008 | containing-sexp paren-state)) | 9993 | (while (let* ((prev-point (point)) |
| 10009 | 9994 | (last-step-type (c-beginning-of-statement-1 | |
| 10010 | ;; CASE 17A: After a case/default label? | 9995 | containing-sexp))) |
| 10011 | ((progn | 9996 | (if (= (point) prev-point) |
| 10012 | (while (and (eq step-type 'label) | 9997 | (progn |
| 10013 | (not (looking-at c-label-kwds-regexp))) | 9998 | (setq step-type (or step-type last-step-type)) |
| 10014 | (setq step-type | 9999 | nil) |
| 10015 | (c-beginning-of-statement-1 containing-sexp))) | 10000 | (setq step-type last-step-type) |
| 10016 | (eq step-type 'label)) | 10001 | (/= (point) (c-point 'boi))))) |
| 10017 | (c-add-stmt-syntax (if (eq char-after-ip ?{) | 10002 | (cond |
| 10018 | 'statement-case-open | ||
| 10019 | 'statement-case-intro) | ||
| 10020 | nil t containing-sexp paren-state)) | ||
| 10021 | |||
| 10022 | ;; CASE 17D: any old statement | ||
| 10023 | ((progn | ||
| 10024 | (while (eq step-type 'label) | ||
| 10025 | (setq step-type | ||
| 10026 | (c-beginning-of-statement-1 containing-sexp))) | ||
| 10027 | (eq step-type 'previous)) | ||
| 10028 | (c-add-stmt-syntax 'statement nil t | ||
| 10029 | containing-sexp paren-state) | ||
| 10030 | (if (eq char-after-ip ?{) | ||
| 10031 | (c-add-syntax 'block-open))) | ||
| 10032 | |||
| 10033 | ;; CASE 17I: Inside a substatement block. | ||
| 10034 | ((progn | ||
| 10035 | ;; The following tests are all based on containing-sexp. | ||
| 10036 | (goto-char containing-sexp) | ||
| 10037 | ;; From here on we have the next containing sexp in lim. | ||
| 10038 | (setq lim (c-most-enclosing-brace paren-state containing-sexp)) | ||
| 10039 | (c-after-conditional)) | ||
| 10040 | (c-backward-to-block-anchor lim) | ||
| 10041 | (c-add-stmt-syntax 'statement-block-intro nil t | ||
| 10042 | lim paren-state) | ||
| 10043 | (if (eq char-after-ip ?{) | ||
| 10044 | (c-add-syntax 'block-open))) | ||
| 10045 | |||
| 10046 | ;; CASE 17E: first statement in an in-expression block. | ||
| 10047 | ;; C.f. cases 4, 7B and 16A. | ||
| 10048 | ((setq placeholder (c-looking-at-inexpr-block | ||
| 10049 | (c-safe-position containing-sexp paren-state) | ||
| 10050 | nil)) | ||
| 10051 | (setq tmpsymbol (if (eq (car placeholder) 'inlambda) | ||
| 10052 | 'defun-block-intro | ||
| 10053 | 'statement-block-intro)) | ||
| 10054 | (back-to-indentation) | ||
| 10055 | (if (= containing-sexp (point)) | ||
| 10056 | (c-add-syntax tmpsymbol (point)) | ||
| 10057 | (goto-char (cdr placeholder)) | ||
| 10058 | (back-to-indentation) | ||
| 10059 | (c-add-stmt-syntax tmpsymbol nil t | ||
| 10060 | (c-most-enclosing-brace c-state-cache (point)) | ||
| 10061 | paren-state) | ||
| 10062 | (if (/= (point) (cdr placeholder)) | ||
| 10063 | (c-add-syntax (car placeholder)))) | ||
| 10064 | (if (eq char-after-ip ?{) | ||
| 10065 | (c-add-syntax 'block-open))) | ||
| 10066 | |||
| 10067 | ;; CASE 17F: first statement in an inline, or first | ||
| 10068 | ;; statement in a top-level defun. we can tell this is it | ||
| 10069 | ;; if there are no enclosing braces that haven't been | ||
| 10070 | ;; narrowed out by a class (i.e. don't use bod here). | ||
| 10071 | ((save-excursion | ||
| 10072 | (or (not (setq placeholder (c-most-enclosing-brace | ||
| 10073 | paren-state))) | ||
| 10074 | (and (progn | ||
| 10075 | (goto-char placeholder) | ||
| 10076 | (eq (char-after) ?{)) | ||
| 10077 | (c-looking-at-decl-block (c-most-enclosing-brace | ||
| 10078 | paren-state (point)) | ||
| 10079 | nil)))) | ||
| 10080 | (c-backward-to-decl-anchor lim) | ||
| 10081 | (back-to-indentation) | ||
| 10082 | (c-add-syntax 'defun-block-intro (point))) | ||
| 10083 | 10003 | ||
| 10084 | ;; CASE 17G: First statement in a function declared inside | 10004 | ;; CASE 17B: continued statement |
| 10085 | ;; a normal block. This can occur in Pike and with | 10005 | ((and (eq step-type 'same) |
| 10086 | ;; e.g. the gcc extensions, but watch out for macros | 10006 | (/= (point) indent-point)) |
| 10087 | ;; followed by blocks. C.f. cases B.3 and 16F. | 10007 | (c-add-stmt-syntax 'statement-cont nil nil |
| 10088 | ((save-excursion | 10008 | containing-sexp paren-state)) |
| 10089 | (and (not (c-at-statement-start-p)) | 10009 | |
| 10090 | (eq (c-beginning-of-statement-1 lim nil nil t) 'same) | 10010 | ;; CASE 17A: After a case/default label? |
| 10091 | (setq placeholder (point)) | 10011 | ((progn |
| 10092 | (let ((c-recognize-typeless-decls nil)) | 10012 | (while (and (eq step-type 'label) |
| 10093 | ;; Turn off recognition of constructs that lacks | 10013 | (not (looking-at c-label-kwds-regexp))) |
| 10094 | ;; a type in this case, since that's more likely | 10014 | (setq step-type |
| 10095 | ;; to be a macro followed by a block. | 10015 | (c-beginning-of-statement-1 containing-sexp))) |
| 10096 | (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) | 10016 | (eq step-type 'label)) |
| 10017 | (c-add-stmt-syntax (if (eq char-after-ip ?{) | ||
| 10018 | 'statement-case-open | ||
| 10019 | 'statement-case-intro) | ||
| 10020 | nil t containing-sexp paren-state)) | ||
| 10021 | |||
| 10022 | ;; CASE 17D: any old statement | ||
| 10023 | ((progn | ||
| 10024 | (while (eq step-type 'label) | ||
| 10025 | (setq step-type | ||
| 10026 | (c-beginning-of-statement-1 containing-sexp))) | ||
| 10027 | (eq step-type 'previous)) | ||
| 10028 | (c-add-stmt-syntax 'statement nil t | ||
| 10029 | containing-sexp paren-state) | ||
| 10030 | (if (eq char-after-ip ?{) | ||
| 10031 | (c-add-syntax 'block-open))) | ||
| 10032 | |||
| 10033 | ;; CASE 17I: Inside a substatement block. | ||
| 10034 | ((progn | ||
| 10035 | ;; The following tests are all based on containing-sexp. | ||
| 10036 | (goto-char containing-sexp) | ||
| 10037 | ;; From here on we have the next containing sexp in lim. | ||
| 10038 | (setq lim (c-most-enclosing-brace paren-state containing-sexp)) | ||
| 10039 | (c-after-conditional)) | ||
| 10040 | (c-backward-to-block-anchor lim) | ||
| 10041 | (c-add-stmt-syntax 'statement-block-intro nil t | ||
| 10042 | lim paren-state) | ||
| 10043 | (if (eq char-after-ip ?{) | ||
| 10044 | (c-add-syntax 'block-open))) | ||
| 10045 | |||
| 10046 | ;; CASE 17E: first statement in an in-expression block. | ||
| 10047 | ;; C.f. cases 4, 7B and 16A. | ||
| 10048 | ((setq placeholder (c-looking-at-inexpr-block | ||
| 10049 | (c-safe-position containing-sexp paren-state) | ||
| 10050 | nil)) | ||
| 10051 | (setq tmpsymbol (if (eq (car placeholder) 'inlambda) | ||
| 10052 | 'defun-block-intro | ||
| 10053 | 'statement-block-intro)) | ||
| 10054 | (back-to-indentation) | ||
| 10055 | (if (= containing-sexp (point)) | ||
| 10056 | (c-add-syntax tmpsymbol (point)) | ||
| 10057 | (goto-char (cdr placeholder)) | ||
| 10097 | (back-to-indentation) | 10058 | (back-to-indentation) |
| 10098 | (if (/= (point) containing-sexp) | 10059 | (c-add-stmt-syntax tmpsymbol nil t |
| 10099 | (goto-char placeholder)) | 10060 | (c-most-enclosing-brace c-state-cache (point)) |
| 10100 | (c-add-stmt-syntax 'defun-block-intro nil t | 10061 | paren-state) |
| 10101 | lim paren-state)) | 10062 | (if (/= (point) (cdr placeholder)) |
| 10063 | (c-add-syntax (car placeholder)))) | ||
| 10064 | (if (eq char-after-ip ?{) | ||
| 10065 | (c-add-syntax 'block-open))) | ||
| 10066 | |||
| 10067 | ;; CASE 17F: first statement in an inline, or first | ||
| 10068 | ;; statement in a top-level defun. we can tell this is it | ||
| 10069 | ;; if there are no enclosing braces that haven't been | ||
| 10070 | ;; narrowed out by a class (i.e. don't use bod here). | ||
| 10071 | ((save-excursion | ||
| 10072 | (or (not (setq placeholder (c-most-enclosing-brace | ||
| 10073 | paren-state))) | ||
| 10074 | (and (progn | ||
| 10075 | (goto-char placeholder) | ||
| 10076 | (eq (char-after) ?{)) | ||
| 10077 | (c-looking-at-decl-block (c-most-enclosing-brace | ||
| 10078 | paren-state (point)) | ||
| 10079 | nil)))) | ||
| 10080 | (c-backward-to-decl-anchor lim) | ||
| 10081 | (back-to-indentation) | ||
| 10082 | (c-add-syntax 'defun-block-intro (point))) | ||
| 10102 | 10083 | ||
| 10103 | ;; CASE 17H: First statement in a block. | 10084 | ;; CASE 17G: First statement in a function declared inside |
| 10104 | (t | 10085 | ;; a normal block. This can occur in Pike and with |
| 10105 | ;; If the block is preceded by a case/switch label on the | 10086 | ;; e.g. the gcc extensions, but watch out for macros |
| 10106 | ;; same line, we anchor at the first preceding label at | 10087 | ;; followed by blocks. C.f. cases B.3 and 16F. |
| 10107 | ;; boi. The default handling in c-add-stmt-syntax is | 10088 | ((save-excursion |
| 10108 | ;; really fixes it better, but we do like this to keep the | 10089 | (and (not (c-at-statement-start-p)) |
| 10109 | ;; indentation compatible with version 5.28 and earlier. | 10090 | (eq (c-beginning-of-statement-1 lim nil nil t) 'same) |
| 10110 | ;; C.f. case 16C. | 10091 | (setq placeholder (point)) |
| 10111 | (while (and (/= (setq placeholder (point)) (c-point 'boi)) | 10092 | (let ((c-recognize-typeless-decls nil)) |
| 10112 | (eq (c-beginning-of-statement-1 lim) 'label))) | 10093 | ;; Turn off recognition of constructs that lacks |
| 10113 | (goto-char placeholder) | 10094 | ;; a type in this case, since that's more likely |
| 10114 | (if (looking-at c-label-kwds-regexp) | 10095 | ;; to be a macro followed by a block. |
| 10115 | (c-add-syntax 'statement-block-intro (point)) | 10096 | (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) |
| 10116 | (goto-char containing-sexp) | 10097 | (back-to-indentation) |
| 10117 | ;; c-backward-to-block-anchor not necessary here; those | 10098 | (if (/= (point) containing-sexp) |
| 10118 | ;; situations are handled in case 17I above. | 10099 | (goto-char placeholder)) |
| 10119 | (c-add-stmt-syntax 'statement-block-intro nil t | 10100 | (c-add-stmt-syntax 'defun-block-intro nil t |
| 10120 | lim paren-state)) | 10101 | lim paren-state)) |
| 10121 | (if (eq char-after-ip ?{) | ||
| 10122 | (c-add-syntax 'block-open))) | ||
| 10123 | )) | ||
| 10124 | ) | ||
| 10125 | 10102 | ||
| 10126 | ;; now we need to look at any modifiers | 10103 | ;; CASE 17H: First statement in a block. |
| 10127 | (goto-char indent-point) | 10104 | (t |
| 10128 | (skip-chars-forward " \t") | 10105 | ;; If the block is preceded by a case/switch label on the |
| 10106 | ;; same line, we anchor at the first preceding label at | ||
| 10107 | ;; boi. The default handling in c-add-stmt-syntax is | ||
| 10108 | ;; really fixes it better, but we do like this to keep the | ||
| 10109 | ;; indentation compatible with version 5.28 and earlier. | ||
| 10110 | ;; C.f. case 16C. | ||
| 10111 | (while (and (/= (setq placeholder (point)) (c-point 'boi)) | ||
| 10112 | (eq (c-beginning-of-statement-1 lim) 'label))) | ||
| 10113 | (goto-char placeholder) | ||
| 10114 | (if (looking-at c-label-kwds-regexp) | ||
| 10115 | (c-add-syntax 'statement-block-intro (point)) | ||
| 10116 | (goto-char containing-sexp) | ||
| 10117 | ;; c-backward-to-block-anchor not necessary here; those | ||
| 10118 | ;; situations are handled in case 17I above. | ||
| 10119 | (c-add-stmt-syntax 'statement-block-intro nil t | ||
| 10120 | lim paren-state)) | ||
| 10121 | (if (eq char-after-ip ?{) | ||
| 10122 | (c-add-syntax 'block-open))) | ||
| 10123 | )) | ||
| 10124 | ) | ||
| 10125 | |||
| 10126 | ;; now we need to look at any modifiers | ||
| 10127 | (goto-char indent-point) | ||
| 10128 | (skip-chars-forward " \t") | ||
| 10129 | |||
| 10130 | ;; are we looking at a comment only line? | ||
| 10131 | (when (and (looking-at c-comment-start-regexp) | ||
| 10132 | (/= (c-forward-token-2 0 nil (c-point 'eol)) 0)) | ||
| 10133 | (c-append-syntax 'comment-intro)) | ||
| 10134 | |||
| 10135 | ;; we might want to give additional offset to friends (in C++). | ||
| 10136 | (when (and c-opt-friend-key | ||
| 10137 | (looking-at c-opt-friend-key)) | ||
| 10138 | (c-append-syntax 'friend)) | ||
| 10139 | |||
| 10140 | ;; Set syntactic-relpos. | ||
| 10141 | (let ((p c-syntactic-context)) | ||
| 10142 | (while (and p | ||
| 10143 | (if (integerp (c-langelem-pos (car p))) | ||
| 10144 | (progn | ||
| 10145 | (setq syntactic-relpos (c-langelem-pos (car p))) | ||
| 10146 | nil) | ||
| 10147 | t)) | ||
| 10148 | (setq p (cdr p)))) | ||
| 10129 | 10149 | ||
| 10130 | ;; are we looking at a comment only line? | 10150 | ;; Start of or a continuation of a preprocessor directive? |
| 10131 | (when (and (looking-at c-comment-start-regexp) | 10151 | (if (and macro-start |
| 10132 | (/= (c-forward-token-2 0 nil (c-point 'eol)) 0)) | 10152 | (eq macro-start (c-point 'boi)) |
| 10133 | (c-append-syntax 'comment-intro)) | 10153 | (not (and (c-major-mode-is 'pike-mode) |
| 10134 | 10154 | (eq (char-after (1+ macro-start)) ?\")))) | |
| 10135 | ;; we might want to give additional offset to friends (in C++). | 10155 | (c-append-syntax 'cpp-macro) |
| 10136 | (when (and c-opt-friend-key | 10156 | (when (and c-syntactic-indentation-in-macros macro-start) |
| 10137 | (looking-at c-opt-friend-key)) | 10157 | (if in-macro-expr |
| 10138 | (c-append-syntax 'friend)) | 10158 | (when (or |
| 10139 | 10159 | (< syntactic-relpos macro-start) | |
| 10140 | ;; Set syntactic-relpos. | 10160 | (not (or |
| 10141 | (let ((p c-syntactic-context)) | 10161 | (assq 'arglist-intro c-syntactic-context) |
| 10142 | (while (and p | 10162 | (assq 'arglist-cont c-syntactic-context) |
| 10143 | (if (integerp (c-langelem-pos (car p))) | 10163 | (assq 'arglist-cont-nonempty c-syntactic-context) |
| 10144 | (progn | 10164 | (assq 'arglist-close c-syntactic-context)))) |
| 10145 | (setq syntactic-relpos (c-langelem-pos (car p))) | 10165 | ;; If inside a cpp expression, i.e. anywhere in a |
| 10146 | nil) | 10166 | ;; cpp directive except a #define body, we only let |
| 10147 | t)) | 10167 | ;; through the syntactic analysis that is internal |
| 10148 | (setq p (cdr p)))) | 10168 | ;; in the expression. That means the arglist |
| 10149 | 10169 | ;; elements, if they are anchored inside the cpp | |
| 10150 | ;; Start of or a continuation of a preprocessor directive? | 10170 | ;; expression. |
| 10151 | (if (and macro-start | 10171 | (setq c-syntactic-context nil) |
| 10152 | (eq macro-start (c-point 'boi)) | 10172 | (c-add-syntax 'cpp-macro-cont macro-start)) |
| 10153 | (not (and (c-major-mode-is 'pike-mode) | 10173 | (when (and (eq macro-start syntactic-relpos) |
| 10154 | (eq (char-after (1+ macro-start)) ?\")))) | 10174 | (not (assq 'cpp-define-intro c-syntactic-context)) |
| 10155 | (c-append-syntax 'cpp-macro) | 10175 | (save-excursion |
| 10156 | (when (and c-syntactic-indentation-in-macros macro-start) | 10176 | (goto-char macro-start) |
| 10157 | (if in-macro-expr | 10177 | (or (not (c-forward-to-cpp-define-body)) |
| 10158 | (when (or | 10178 | (<= (point) (c-point 'boi indent-point))))) |
| 10159 | (< syntactic-relpos macro-start) | 10179 | ;; Inside a #define body and the syntactic analysis is |
| 10160 | (not (or | 10180 | ;; anchored on the start of the #define. In this case |
| 10161 | (assq 'arglist-intro c-syntactic-context) | 10181 | ;; we add cpp-define-intro to get the extra |
| 10162 | (assq 'arglist-cont c-syntactic-context) | 10182 | ;; indentation of the #define body. |
| 10163 | (assq 'arglist-cont-nonempty c-syntactic-context) | 10183 | (c-add-syntax 'cpp-define-intro))))) |
| 10164 | (assq 'arglist-close c-syntactic-context)))) | 10184 | |
| 10165 | ;; If inside a cpp expression, i.e. anywhere in a | 10185 | ;; return the syntax |
| 10166 | ;; cpp directive except a #define body, we only let | 10186 | c-syntactic-context))) |
| 10167 | ;; through the syntactic analysis that is internal | ||
| 10168 | ;; in the expression. That means the arglist | ||
| 10169 | ;; elements, if they are anchored inside the cpp | ||
| 10170 | ;; expression. | ||
| 10171 | (setq c-syntactic-context nil) | ||
| 10172 | (c-add-syntax 'cpp-macro-cont macro-start)) | ||
| 10173 | (when (and (eq macro-start syntactic-relpos) | ||
| 10174 | (not (assq 'cpp-define-intro c-syntactic-context)) | ||
| 10175 | (save-excursion | ||
| 10176 | (goto-char macro-start) | ||
| 10177 | (or (not (c-forward-to-cpp-define-body)) | ||
| 10178 | (<= (point) (c-point 'boi indent-point))))) | ||
| 10179 | ;; Inside a #define body and the syntactic analysis is | ||
| 10180 | ;; anchored on the start of the #define. In this case | ||
| 10181 | ;; we add cpp-define-intro to get the extra | ||
| 10182 | ;; indentation of the #define body. | ||
| 10183 | (c-add-syntax 'cpp-define-intro))))) | ||
| 10184 | |||
| 10185 | ;; return the syntax | ||
| 10186 | c-syntactic-context))) | ||
| 10187 | 10187 | ||
| 10188 | 10188 | ||
| 10189 | ;; Indentation calculation. | 10189 | ;; Indentation calculation. |