diff options
| author | Stefan Monnier | 2014-10-04 00:03:49 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-10-04 00:03:49 -0400 |
| commit | 03c4553666d2e99d4e6f51f2195c0136d317f0c9 (patch) | |
| tree | 24202d64586ca32194ec48d9843f44059598eacc | |
| parent | 94ab176a44d514ffebf343d43527d99c13cdfb93 (diff) | |
| download | emacs-03c4553666d2e99d4e6f51f2195c0136d317f0c9.tar.gz emacs-03c4553666d2e99d4e6f51f2195c0136d317f0c9.zip | |
Merge trivially safe differences from standalone CC-mode.
* lisp/progmodes/cc-mode.el (c-initialize-cc-mode): Don't quote a symbol
just to then pass it to `symbol-value'.
(prog-mode): Provide fallback definition, if needed.
* lisp/progmodes/cc-langs.el: Always load `cl'. Don't load `cl-lib'.
Remove "cl-" prefix accordingly.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-string): Use integerp or
characterp depending on the type of characters.
(c-font-lock-enum-tail): Remove unused var `start'.
* lisp/progmodes/cc-engine.el: Load CL at compile-time.
(c-declare-lang-variables): Use mapcan.
(c-append-to-state-cache): Remove unused var `ce+1'.
(c-parse-state-state): Make buffer-local.
(c-ssb-lit-begin): Remove unused var `pps-end-pos'.
(c-just-after-func-arglist-p): Remove unused var `end'.
* lisp/progmodes/cc-defs.el: Load cc-fix if delete-dups is undefined.
(c-<-as-paren-syntax, c->-as-paren-syntax): Move definition earlier.
(c-make-keywords-re): Use delete-dups.
(c-get-current-file): Avoid file-name-base.
* lisp/progmodes/cc-cmds.el (c-electric-lt-gt): Remove unused var
`close-paren-inserted'.
* lisp/progmodes/cc-awk.el (c-forward-sws): Remove unused declaration.
| -rw-r--r-- | lisp/ChangeLog | 23 | ||||
| -rw-r--r-- | lisp/progmodes/cc-awk.el | 1 | ||||
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 65 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 1010 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 47 | ||||
| -rw-r--r-- | lisp/progmodes/cc-guess.el | 3 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 51 | ||||
| -rw-r--r-- | lisp/progmodes/cc-menus.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 4 | ||||
| -rw-r--r-- | lisp/progmodes/cc-vars.el | 24 |
11 files changed, 622 insertions, 610 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3591afde4ac..75dac546c0f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,28 @@ | |||
| 1 | 2014-10-04 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2014-10-04 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | Merge trivially safe differences from standalone CC-mode. | ||
| 4 | * progmodes/cc-mode.el (c-initialize-cc-mode): Don't quote a symbol | ||
| 5 | just to then pass it to `symbol-value'. | ||
| 6 | (prog-mode): Provide fallback definition, if needed. | ||
| 7 | * progmodes/cc-langs.el: Always load `cl'. Don't load `cl-lib'. | ||
| 8 | Remove "cl-" prefix accordingly. | ||
| 9 | * progmodes/cc-fonts.el (c-font-lock-invalid-string): Use integerp or | ||
| 10 | characterp depending on the type of characters. | ||
| 11 | (c-font-lock-enum-tail): Remove unused var `start'. | ||
| 12 | * progmodes/cc-engine.el: Load CL at compile-time. | ||
| 13 | (c-declare-lang-variables): Use mapcan. | ||
| 14 | (c-append-to-state-cache): Remove unused var `ce+1'. | ||
| 15 | (c-parse-state-state): Make buffer-local. | ||
| 16 | (c-ssb-lit-begin): Remove unused var `pps-end-pos'. | ||
| 17 | (c-just-after-func-arglist-p): Remove unused var `end'. | ||
| 18 | * progmodes/cc-defs.el: Load cc-fix if delete-dups is undefined. | ||
| 19 | (c-<-as-paren-syntax, c->-as-paren-syntax): Move definition earlier. | ||
| 20 | (c-make-keywords-re): Use delete-dups. | ||
| 21 | (c-get-current-file): Avoid file-name-base. | ||
| 22 | * progmodes/cc-cmds.el (c-electric-lt-gt): Remove unused var | ||
| 23 | `close-paren-inserted'. | ||
| 24 | * progmodes/cc-awk.el (c-forward-sws): Remove unused declaration. | ||
| 25 | |||
| 3 | * progmodes/python.el: Avoid building unneeded markers. | 26 | * progmodes/python.el: Avoid building unneeded markers. |
| 4 | (python-font-lock-keywords, python-indent-dedent-line) | 27 | (python-font-lock-keywords, python-indent-dedent-line) |
| 5 | (python-fill-paren, python-shell-completion-complete-or-indent): | 28 | (python-fill-paren, python-shell-completion-complete-or-indent): |
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el index 44d69d7d0f1..d57d601cd7a 100644 --- a/lisp/progmodes/cc-awk.el +++ b/lisp/progmodes/cc-awk.el | |||
| @@ -61,7 +61,6 @@ | |||
| 61 | (cc-bytecomp-defun c-backward-token-1) | 61 | (cc-bytecomp-defun c-backward-token-1) |
| 62 | (cc-bytecomp-defun c-beginning-of-statement-1) | 62 | (cc-bytecomp-defun c-beginning-of-statement-1) |
| 63 | (cc-bytecomp-defun c-backward-sws) | 63 | (cc-bytecomp-defun c-backward-sws) |
| 64 | (cc-bytecomp-defun c-forward-sws) | ||
| 65 | 64 | ||
| 66 | (defvar awk-mode-syntax-table | 65 | (defvar awk-mode-syntax-table |
| 67 | (let ((st (make-syntax-table))) | 66 | (let ((st (make-syntax-table))) |
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 4f205d62a4c..afbd577b10d 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -1090,7 +1090,7 @@ numeric argument is supplied, or the point is inside a literal." | |||
| 1090 | 1090 | ||
| 1091 | (interactive "*P") | 1091 | (interactive "*P") |
| 1092 | (let ((c-echo-syntactic-information-p nil) | 1092 | (let ((c-echo-syntactic-information-p nil) |
| 1093 | final-pos close-paren-inserted found-delim case-fold-search) | 1093 | final-pos found-delim case-fold-search) |
| 1094 | 1094 | ||
| 1095 | (self-insert-command (prefix-numeric-value arg)) | 1095 | (self-insert-command (prefix-numeric-value arg)) |
| 1096 | (setq final-pos (point)) | 1096 | (setq final-pos (point)) |
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 5d528caabb2..dc31fde131d 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -86,6 +86,11 @@ | |||
| 86 | font-lock-keywords))) | 86 | font-lock-keywords))) |
| 87 | (cc-load "cc-fix"))) | 87 | (cc-load "cc-fix"))) |
| 88 | 88 | ||
| 89 | ;; XEmacs 21.4 doesn't have `delete-dups'. | ||
| 90 | (eval-and-compile | ||
| 91 | (if (and (not (fboundp 'delete-dups)) | ||
| 92 | (not (featurep 'cc-fix))) | ||
| 93 | (cc-load "cc-fix"))) | ||
| 89 | 94 | ||
| 90 | ;;; Variables also used at compile time. | 95 | ;;; Variables also used at compile time. |
| 91 | 96 | ||
| @@ -913,6 +918,12 @@ MODE is either a mode symbol or a list of mode symbols." | |||
| 913 | (cc-bytecomp-fboundp 'delete-extent) | 918 | (cc-bytecomp-fboundp 'delete-extent) |
| 914 | (cc-bytecomp-fboundp 'map-extents)))) | 919 | (cc-bytecomp-fboundp 'map-extents)))) |
| 915 | 920 | ||
| 921 | (defconst c-<-as-paren-syntax '(4 . ?>)) | ||
| 922 | (put 'c-<-as-paren-syntax 'syntax-table c-<-as-paren-syntax) | ||
| 923 | |||
| 924 | (defconst c->-as-paren-syntax '(5 . ?<)) | ||
| 925 | (put 'c->-as-paren-syntax 'syntax-table c->-as-paren-syntax) | ||
| 926 | |||
| 916 | ;; `c-put-char-property' is complex enough in XEmacs and Emacs < 21 to | 927 | ;; `c-put-char-property' is complex enough in XEmacs and Emacs < 21 to |
| 917 | ;; make it a function. | 928 | ;; make it a function. |
| 918 | (defalias 'c-put-char-property-fun | 929 | (defalias 'c-put-char-property-fun |
| @@ -1188,9 +1199,6 @@ been put there by c-put-char-property. POINT remains unchanged." | |||
| 1188 | (if (< (point) start) | 1199 | (if (< (point) start) |
| 1189 | (goto-char (point-max))))) | 1200 | (goto-char (point-max))))) |
| 1190 | 1201 | ||
| 1191 | (defconst c-<-as-paren-syntax '(4 . ?>)) | ||
| 1192 | (put 'c-<-as-paren-syntax 'syntax-table c-<-as-paren-syntax) | ||
| 1193 | |||
| 1194 | (defsubst c-mark-<-as-paren (pos) | 1202 | (defsubst c-mark-<-as-paren (pos) |
| 1195 | ;; Mark the "<" character at POS as a template opener using the | 1203 | ;; Mark the "<" character at POS as a template opener using the |
| 1196 | ;; `syntax-table' property via the `category' property. | 1204 | ;; `syntax-table' property via the `category' property. |
| @@ -1201,9 +1209,6 @@ been put there by c-put-char-property. POINT remains unchanged." | |||
| 1201 | ;; cheaply. We use this, for instance, in `c-parse-state'. | 1209 | ;; cheaply. We use this, for instance, in `c-parse-state'. |
| 1202 | (c-put-char-property pos 'category 'c-<-as-paren-syntax)) | 1210 | (c-put-char-property pos 'category 'c-<-as-paren-syntax)) |
| 1203 | 1211 | ||
| 1204 | (defconst c->-as-paren-syntax '(5 . ?<)) | ||
| 1205 | (put 'c->-as-paren-syntax 'syntax-table c->-as-paren-syntax) | ||
| 1206 | |||
| 1207 | (defsubst c-mark->-as-paren (pos) | 1212 | (defsubst c-mark->-as-paren (pos) |
| 1208 | ;; Mark the ">" character at POS as an sexp list closer using the | 1213 | ;; Mark the ">" character at POS as an sexp list closer using the |
| 1209 | ;; syntax-table property. | 1214 | ;; syntax-table property. |
| @@ -1419,8 +1424,8 @@ Notably, null elements in LIST are ignored." | |||
| 1419 | 1424 | ||
| 1420 | (defun c-make-keywords-re (adorn list &optional mode) | 1425 | (defun c-make-keywords-re (adorn list &optional mode) |
| 1421 | "Make a regexp that matches all the strings the list. | 1426 | "Make a regexp that matches all the strings the list. |
| 1422 | Duplicates and nil elements in the list are removed. The resulting | 1427 | Duplicates and nil elements in the list are removed. The |
| 1423 | regexp may contain zero or more submatch expressions. | 1428 | resulting regexp may contain zero or more submatch expressions. |
| 1424 | 1429 | ||
| 1425 | If ADORN is t there will be at least one submatch and the first | 1430 | If ADORN is t there will be at least one submatch and the first |
| 1426 | surrounds the matched alternative, and the regexp will also not match | 1431 | surrounds the matched alternative, and the regexp will also not match |
| @@ -1438,11 +1443,7 @@ The optional MODE specifies the language to get `c-nonsymbol-key' from | |||
| 1438 | when it's needed. The default is the current language taken from | 1443 | when it's needed. The default is the current language taken from |
| 1439 | `c-buffer-is-cc-mode'." | 1444 | `c-buffer-is-cc-mode'." |
| 1440 | 1445 | ||
| 1441 | (let (unique) | 1446 | (setq list (delete nil (delete-dups list))) |
| 1442 | (dolist (elt list) | ||
| 1443 | (unless (member elt unique) | ||
| 1444 | (push elt unique))) | ||
| 1445 | (setq list (delete nil unique))) | ||
| 1446 | (if list | 1447 | (if list |
| 1447 | (let (re) | 1448 | (let (re) |
| 1448 | 1449 | ||
| @@ -1638,13 +1639,13 @@ non-nil, a caret is prepended to invert the set." | |||
| 1638 | "support for the `syntax-table' text property " | 1639 | "support for the `syntax-table' text property " |
| 1639 | "is required."))) | 1640 | "is required."))) |
| 1640 | 1641 | ||
| 1641 | ;; Find out if generic comment delimiters work. | 1642 | ;; Find out if "\\s!" (generic comment delimiters) work. |
| 1642 | (c-safe | 1643 | (c-safe |
| 1643 | (modify-syntax-entry ?x "!") | 1644 | (modify-syntax-entry ?x "!") |
| 1644 | (if (string-match "\\s!" "x") | 1645 | (if (string-match "\\s!" "x") |
| 1645 | (setq list (cons 'gen-comment-delim list)))) | 1646 | (setq list (cons 'gen-comment-delim list)))) |
| 1646 | 1647 | ||
| 1647 | ;; Find out if generic string delimiters work. | 1648 | ;; Find out if "\\s|" (generic string delimiters) work. |
| 1648 | (c-safe | 1649 | (c-safe |
| 1649 | (modify-syntax-entry ?x "|") | 1650 | (modify-syntax-entry ?x "|") |
| 1650 | (if (string-match "\\s|" "x") | 1651 | (if (string-match "\\s|" "x") |
| @@ -1691,7 +1692,8 @@ non-nil, a caret is prepended to invert the set." | |||
| 1691 | (kill-buffer buf)) | 1692 | (kill-buffer buf)) |
| 1692 | 1693 | ||
| 1693 | ;; See if `parse-partial-sexp' returns the eighth element. | 1694 | ;; See if `parse-partial-sexp' returns the eighth element. |
| 1694 | (if (c-safe (>= (length (save-excursion (parse-partial-sexp (point) (point)))) | 1695 | (if (c-safe (>= (length (save-excursion |
| 1696 | (parse-partial-sexp (point) (point)))) | ||
| 1695 | 10)) | 1697 | 10)) |
| 1696 | (setq list (cons 'pps-extended-state list)) | 1698 | (setq list (cons 'pps-extended-state list)) |
| 1697 | (error (concat | 1699 | (error (concat |
| @@ -1707,9 +1709,8 @@ might be present: | |||
| 1707 | 1709 | ||
| 1708 | '8-bit 8 bit syntax entry flags (XEmacs style). | 1710 | '8-bit 8 bit syntax entry flags (XEmacs style). |
| 1709 | '1-bit 1 bit syntax entry flags (Emacs style). | 1711 | '1-bit 1 bit syntax entry flags (Emacs style). |
| 1710 | 'argumentative-bod-function beginning-of-defun passes ARG through | 1712 | 'argumentative-bod-function beginning-of-defun and end-of-defun pass |
| 1711 | to a non-null beginning-of-defun-function. It is assumed | 1713 | ARG through to beginning/end-of-defun-function. |
| 1712 | the end-of-defun does the same thing. | ||
| 1713 | 'syntax-properties It works to override the syntax for specific characters | 1714 | 'syntax-properties It works to override the syntax for specific characters |
| 1714 | in the buffer with the 'syntax-table property. It's | 1715 | in the buffer with the 'syntax-table property. It's |
| 1715 | always set - CC Mode no longer works in emacsen without | 1716 | always set - CC Mode no longer works in emacsen without |
| @@ -1803,18 +1804,18 @@ system." | |||
| 1803 | (error "Unknown base mode `%s'" base-mode)) | 1804 | (error "Unknown base mode `%s'" base-mode)) |
| 1804 | (put mode 'c-fallback-mode base-mode)) | 1805 | (put mode 'c-fallback-mode base-mode)) |
| 1805 | 1806 | ||
| 1806 | (defvar c-lang-constants (make-vector 151 0) | 1807 | (defvar c-lang-constants (make-vector 151 0)) |
| 1807 | "Obarray used as a cache to keep track of the language constants. | 1808 | ;; Obarray used as a cache to keep track of the language constants. |
| 1808 | The constants stored are those defined by `c-lang-defconst' and the values | 1809 | ;; The constants stored are those defined by `c-lang-defconst' and the values |
| 1809 | computed by `c-lang-const'. It's mostly used at compile time but it's not | 1810 | ;; computed by `c-lang-const'. It's mostly used at compile time but it's not |
| 1810 | stored in compiled files. | 1811 | ;; stored in compiled files. |
| 1811 | 1812 | ||
| 1812 | The obarray contains all the language constants as symbols. The | 1813 | ;; The obarray contains all the language constants as symbols. The |
| 1813 | value cells hold the evaluated values as alists where each car is | 1814 | ;; value cells hold the evaluated values as alists where each car is |
| 1814 | the mode name symbol and the corresponding cdr is the evaluated | 1815 | ;; the mode name symbol and the corresponding cdr is the evaluated |
| 1815 | value in that mode. The property lists hold the source definitions | 1816 | ;; value in that mode. The property lists hold the source definitions |
| 1816 | and other miscellaneous data. The obarray might also contain | 1817 | ;; and other miscellaneous data. The obarray might also contain |
| 1817 | various other symbols, but those don't have any variable bindings.") | 1818 | ;; various other symbols, but those don't have any variable bindings. |
| 1818 | 1819 | ||
| 1819 | (defvar c-lang-const-expansion nil) | 1820 | (defvar c-lang-const-expansion nil) |
| 1820 | 1821 | ||
| @@ -1831,7 +1832,9 @@ various other symbols, but those don't have any variable bindings.") | |||
| 1831 | (t | 1832 | (t |
| 1832 | ;; Being evaluated interactively. | 1833 | ;; Being evaluated interactively. |
| 1833 | (buffer-file-name))))) | 1834 | (buffer-file-name))))) |
| 1834 | (and file (file-name-base file)))) | 1835 | (and file |
| 1836 | (file-name-sans-extension | ||
| 1837 | (file-name-nondirectory file))))) | ||
| 1835 | 1838 | ||
| 1836 | (defmacro c-lang-defconst-eval-immediately (form) | 1839 | (defmacro c-lang-defconst-eval-immediately (form) |
| 1837 | "Can be used inside a VAL in `c-lang-defconst' to evaluate FORM | 1840 | "Can be used inside a VAL in `c-lang-defconst' to evaluate FORM |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 224ea36a22a..d17be71a2d1 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -147,18 +147,19 @@ | |||
| 147 | (cc-require-when-compile 'cc-langs) | 147 | (cc-require-when-compile 'cc-langs) |
| 148 | (cc-require 'cc-vars) | 148 | (cc-require 'cc-vars) |
| 149 | 149 | ||
| 150 | (eval-when-compile (require 'cl)) | ||
| 151 | |||
| 150 | 152 | ||
| 151 | ;; Make declarations for all the `c-lang-defvar' variables in cc-langs. | 153 | ;; Make declarations for all the `c-lang-defvar' variables in cc-langs. |
| 152 | 154 | ||
| 153 | (defmacro c-declare-lang-variables () | 155 | (defmacro c-declare-lang-variables () |
| 154 | `(progn | 156 | `(progn |
| 155 | ,@(apply 'nconc | 157 | ,@(mapcan (lambda (init) |
| 156 | (mapcar (lambda (init) | 158 | `(,(if (elt init 2) |
| 157 | `(,(if (elt init 2) | 159 | `(defvar ,(car init) nil ,(elt init 2)) |
| 158 | `(defvar ,(car init) nil ,(elt init 2)) | 160 | `(defvar ,(car init) nil)) |
| 159 | `(defvar ,(car init) nil)) | 161 | (make-variable-buffer-local ',(car init)))) |
| 160 | (make-variable-buffer-local ',(car init)))) | 162 | (cdr c-lang-variable-inits)))) |
| 161 | (cdr c-lang-variable-inits))))) | ||
| 162 | (c-declare-lang-variables) | 163 | (c-declare-lang-variables) |
| 163 | 164 | ||
| 164 | 165 | ||
| @@ -826,7 +827,6 @@ comment at the start of cc-engine.el for more info." | |||
| 826 | ;; Record this as the first token if not starting inside it. | 827 | ;; Record this as the first token if not starting inside it. |
| 827 | (setq tok start)) | 828 | (setq tok start)) |
| 828 | 829 | ||
| 829 | |||
| 830 | ;; The following while loop goes back one sexp (balanced parens, | 830 | ;; The following while loop goes back one sexp (balanced parens, |
| 831 | ;; etc. with contents, or symbol or suchlike) each iteration. This | 831 | ;; etc. with contents, or symbol or suchlike) each iteration. This |
| 832 | ;; movement is accomplished with a call to c-backward-sexp approx 170 | 832 | ;; movement is accomplished with a call to c-backward-sexp approx 170 |
| @@ -2159,7 +2159,6 @@ comment at the start of cc-engine.el for more info." | |||
| 2159 | ;; the middle of the desert, as long as it is not within a brace pair | 2159 | ;; the middle of the desert, as long as it is not within a brace pair |
| 2160 | ;; recorded in `c-state-cache' or a paren/bracket pair. | 2160 | ;; recorded in `c-state-cache' or a paren/bracket pair. |
| 2161 | 2161 | ||
| 2162 | |||
| 2163 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 2162 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2164 | ;; We maintain a simple cache of positions which aren't in a literal, so as to | 2163 | ;; We maintain a simple cache of positions which aren't in a literal, so as to |
| 2165 | ;; speed up testing for non-literality. | 2164 | ;; speed up testing for non-literality. |
| @@ -2780,7 +2779,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2780 | paren+1 ; Pos after some opening or closing paren. | 2779 | paren+1 ; Pos after some opening or closing paren. |
| 2781 | paren+1s ; A list of `paren+1's; used to determine a | 2780 | paren+1s ; A list of `paren+1's; used to determine a |
| 2782 | ; good-pos. | 2781 | ; good-pos. |
| 2783 | bra+1 ce+1 ; just after L/R bra-ces. | 2782 | bra+1 ; just after L bra-ce. |
| 2784 | bra+1s ; list of OLD values of bra+1. | 2783 | bra+1s ; list of OLD values of bra+1. |
| 2785 | mstart) ; start of a macro. | 2784 | mstart) ; start of a macro. |
| 2786 | 2785 | ||
| @@ -3392,6 +3391,7 @@ comment at the start of cc-engine.el for more info." | |||
| 3392 | 3391 | ||
| 3393 | (defvar c-parse-state-point nil) | 3392 | (defvar c-parse-state-point nil) |
| 3394 | (defvar c-parse-state-state nil) | 3393 | (defvar c-parse-state-state nil) |
| 3394 | (make-variable-buffer-local 'c-parse-state-state) | ||
| 3395 | (defun c-record-parse-state-state () | 3395 | (defun c-record-parse-state-state () |
| 3396 | (setq c-parse-state-point (point)) | 3396 | (setq c-parse-state-point (point)) |
| 3397 | (setq c-parse-state-state | 3397 | (setq c-parse-state-state |
| @@ -4166,7 +4166,7 @@ comment at the start of cc-engine.el for more info." | |||
| 4166 | ;; Use `parse-partial-sexp' from a safe position down to the point to check | 4166 | ;; Use `parse-partial-sexp' from a safe position down to the point to check |
| 4167 | ;; if it's outside comments and strings. | 4167 | ;; if it's outside comments and strings. |
| 4168 | (save-excursion | 4168 | (save-excursion |
| 4169 | (let ((pos (point)) safe-pos state pps-end-pos) | 4169 | (let ((pos (point)) safe-pos state) |
| 4170 | ;; Pick a safe position as close to the point as possible. | 4170 | ;; Pick a safe position as close to the point as possible. |
| 4171 | ;; | 4171 | ;; |
| 4172 | ;; FIXME: Consult `syntax-ppss' here if our cache doesn't give a good | 4172 | ;; FIXME: Consult `syntax-ppss' here if our cache doesn't give a good |
| @@ -4860,14 +4860,17 @@ comment at the start of cc-engine.el for more info." | |||
| 4860 | ;; it should return non-nil to ensure that the next search will find them. | 4860 | ;; it should return non-nil to ensure that the next search will find them. |
| 4861 | ;; | 4861 | ;; |
| 4862 | ;; Such a spot is: | 4862 | ;; Such a spot is: |
| 4863 | ;; o The first token after bob. | 4863 | ;; o The first token after bob. |
| 4864 | ;; o The first token after the end of submatch 1 in | 4864 | ;; o The first token after the end of submatch 1 in |
| 4865 | ;; `c-decl-prefix-or-start-re' when that submatch matches. | 4865 | ;; `c-decl-prefix-or-start-re' when that submatch matches. This |
| 4866 | ;; o The start of each `c-decl-prefix-or-start-re' match when | 4866 | ;; submatch is typically a (L or R) brace or paren, a ;, or a ,. |
| 4867 | ;; submatch 1 doesn't match. | 4867 | ;; o The start of each `c-decl-prefix-or-start-re' match when |
| 4868 | ;; o The first token after the end of each occurrence of the | 4868 | ;; submatch 1 doesn't match. This is, for example, the keyword |
| 4869 | ;; `c-type' text property with the value `c-decl-end', provided | 4869 | ;; "class" in Pike. |
| 4870 | ;; `c-type-decl-end-used' is set. | 4870 | ;; o The start of a previously recognized declaration; "recognized" |
| 4871 | ;; means that the last char of the previous token has a `c-type' | ||
| 4872 | ;; text property with the value `c-decl-end'; this only holds | ||
| 4873 | ;; when `c-type-decl-end-used' is set. | ||
| 4871 | ;; | 4874 | ;; |
| 4872 | ;; Only a spot that match CFD-DECL-RE and whose face is in the | 4875 | ;; Only a spot that match CFD-DECL-RE and whose face is in the |
| 4873 | ;; CFD-FACE-CHECKLIST list causes CFD-FUN to be called. The face | 4876 | ;; CFD-FACE-CHECKLIST list causes CFD-FUN to be called. The face |
| @@ -4899,7 +4902,7 @@ comment at the start of cc-engine.el for more info." | |||
| 4899 | ;; | 4902 | ;; |
| 4900 | ;; This function might do hidden buffer changes. | 4903 | ;; This function might do hidden buffer changes. |
| 4901 | 4904 | ||
| 4902 | (let ((cfd-start-pos (point)) | 4905 | (let ((cfd-start-pos (point)) ; never changed |
| 4903 | (cfd-buffer-end (point-max)) | 4906 | (cfd-buffer-end (point-max)) |
| 4904 | ;; The end of the token preceding the decl spot last found | 4907 | ;; The end of the token preceding the decl spot last found |
| 4905 | ;; with `c-decl-prefix-or-start-re'. `cfd-limit' if there's | 4908 | ;; with `c-decl-prefix-or-start-re'. `cfd-limit' if there's |
| @@ -4938,10 +4941,20 @@ comment at the start of cc-engine.el for more info." | |||
| 4938 | ;; statement or declaration, which is earlier than the first | 4941 | ;; statement or declaration, which is earlier than the first |
| 4939 | ;; returned match. | 4942 | ;; returned match. |
| 4940 | 4943 | ||
| 4944 | ;; This `cond' moves back over any literals or macros. It has special | ||
| 4945 | ;; handling for when the region being searched is entirely within a | ||
| 4946 | ;; macro. It sets `cfd-continue-pos' (unless we've reached | ||
| 4947 | ;; `cfd-limit'). | ||
| 4941 | (cond | 4948 | (cond |
| 4942 | ;; First we need to move to a syntactically relevant position. | 4949 | ;; First we need to move to a syntactically relevant position. |
| 4943 | ;; Begin by backing out of comment or string literals. | 4950 | ;; Begin by backing out of comment or string literals. |
| 4951 | ;; | ||
| 4952 | ;; This arm of the cond actually triggers if we're in a literal, | ||
| 4953 | ;; and cfd-limit is at most at BONL. | ||
| 4944 | ((and | 4954 | ((and |
| 4955 | ;; This arm of the `and' moves backwards out of a literal when | ||
| 4956 | ;; the face at point is a literal face. In this case, its value | ||
| 4957 | ;; is always non-nil. | ||
| 4945 | (when (c-got-face-at (point) c-literal-faces) | 4958 | (when (c-got-face-at (point) c-literal-faces) |
| 4946 | ;; Try to use the faces to back up to the start of the | 4959 | ;; Try to use the faces to back up to the start of the |
| 4947 | ;; literal. FIXME: What if the point is on a declaration | 4960 | ;; literal. FIXME: What if the point is on a declaration |
| @@ -4970,7 +4983,7 @@ comment at the start of cc-engine.el for more info." | |||
| 4970 | (let ((range (c-literal-limits))) | 4983 | (let ((range (c-literal-limits))) |
| 4971 | (if range (goto-char (car range))))) | 4984 | (if range (goto-char (car range))))) |
| 4972 | 4985 | ||
| 4973 | (setq start-in-literal (point))) | 4986 | (setq start-in-literal (point))) ; end of `and' arm. |
| 4974 | 4987 | ||
| 4975 | ;; The start is in a literal. If the limit is in the same | 4988 | ;; The start is in a literal. If the limit is in the same |
| 4976 | ;; one we don't have to find a syntactic position etc. We | 4989 | ;; one we don't have to find a syntactic position etc. We |
| @@ -4985,18 +4998,18 @@ comment at the start of cc-engine.el for more info." | |||
| 4985 | (point) 'face nil cfd-limit)) | 4998 | (point) 'face nil cfd-limit)) |
| 4986 | (and (< (point) cfd-limit) | 4999 | (and (< (point) cfd-limit) |
| 4987 | (c-got-face-at (point) c-literal-faces)))) | 5000 | (c-got-face-at (point) c-literal-faces)))) |
| 4988 | (= (point) cfd-limit))) | 5001 | (= (point) cfd-limit))) ; end of `cond' arm condition |
| 4989 | 5002 | ||
| 4990 | ;; Completely inside a literal. Set up variables to trig the | 5003 | ;; Completely inside a literal. Set up variables to trig the |
| 4991 | ;; (< cfd-continue-pos cfd-start-pos) case below and it'll | 5004 | ;; (< cfd-continue-pos cfd-start-pos) case below and it'll |
| 4992 | ;; find a suitable start position. | 5005 | ;; find a suitable start position. |
| 4993 | (setq cfd-continue-pos start-in-literal)) | 5006 | (setq cfd-continue-pos start-in-literal)) ; end of `cond' arm |
| 4994 | 5007 | ||
| 4995 | ;; Check if the region might be completely inside a macro, to | 5008 | ;; Check if the region might be completely inside a macro, to |
| 4996 | ;; optimize that like the completely-inside-literal above. | 5009 | ;; optimize that like the completely-inside-literal above. |
| 4997 | ((save-excursion | 5010 | ((save-excursion |
| 4998 | (and (= (forward-line 1) 0) | 5011 | (and (= (forward-line 1) 0) |
| 4999 | (bolp) ; forward-line has funny behavior at eob. | 5012 | (bolp) ; forward-line has funny behavior at eob. |
| 5000 | (>= (point) cfd-limit) | 5013 | (>= (point) cfd-limit) |
| 5001 | (progn (backward-char) | 5014 | (progn (backward-char) |
| 5002 | (eq (char-before) ?\\)))) | 5015 | (eq (char-before) ?\\)))) |
| @@ -5006,6 +5019,8 @@ comment at the start of cc-engine.el for more info." | |||
| 5006 | (setq cfd-continue-pos (1- cfd-start-pos) | 5019 | (setq cfd-continue-pos (1- cfd-start-pos) |
| 5007 | start-in-macro t)) | 5020 | start-in-macro t)) |
| 5008 | 5021 | ||
| 5022 | ;; The default arm of the `cond' moves back over any macro we're in | ||
| 5023 | ;; and over any syntactic WS. It sets `c-find-decl-syntactic-pos'. | ||
| 5009 | (t | 5024 | (t |
| 5010 | ;; Back out of any macro so we don't miss any declaration | 5025 | ;; Back out of any macro so we don't miss any declaration |
| 5011 | ;; that could follow after it. | 5026 | ;; that could follow after it. |
| @@ -5052,10 +5067,10 @@ comment at the start of cc-engine.el for more info." | |||
| 5052 | (< (point) cfd-limit)) | 5067 | (< (point) cfd-limit)) |
| 5053 | ;; Do an initial search now. In the bob case above it's | 5068 | ;; Do an initial search now. In the bob case above it's |
| 5054 | ;; only done to search for a `c-decl-end' spot. | 5069 | ;; only done to search for a `c-decl-end' spot. |
| 5055 | (c-find-decl-prefix-search)) | 5070 | (c-find-decl-prefix-search)) ; sets cfd-continue-pos |
| 5056 | 5071 | ||
| 5057 | (setq c-find-decl-match-pos (and (< cfd-match-pos cfd-start-pos) | 5072 | (setq c-find-decl-match-pos (and (< cfd-match-pos cfd-start-pos) |
| 5058 | cfd-match-pos))))) | 5073 | cfd-match-pos))))) ; end of `cond' |
| 5059 | 5074 | ||
| 5060 | ;; Advance `cfd-continue-pos' if it's before the start position. | 5075 | ;; Advance `cfd-continue-pos' if it's before the start position. |
| 5061 | ;; The closest continue position that might have effect at or | 5076 | ;; The closest continue position that might have effect at or |
| @@ -5114,7 +5129,7 @@ comment at the start of cc-engine.el for more info." | |||
| 5114 | ;; `cfd-match-pos' so we can continue at the start position. | 5129 | ;; `cfd-match-pos' so we can continue at the start position. |
| 5115 | ;; (Note that we don't get here if the first match is below | 5130 | ;; (Note that we don't get here if the first match is below |
| 5116 | ;; it.) | 5131 | ;; it.) |
| 5117 | (goto-char cfd-start-pos))) | 5132 | (goto-char cfd-start-pos))) ; end of `cond' |
| 5118 | 5133 | ||
| 5119 | ;; Delete found matches if they are before our new continue | 5134 | ;; Delete found matches if they are before our new continue |
| 5120 | ;; position, so that `c-find-decl-prefix-search' won't back up | 5135 | ;; position, so that `c-find-decl-prefix-search' won't back up |
| @@ -5123,7 +5138,7 @@ comment at the start of cc-engine.el for more info." | |||
| 5123 | (when (and cfd-re-match (< cfd-re-match cfd-continue-pos)) | 5138 | (when (and cfd-re-match (< cfd-re-match cfd-continue-pos)) |
| 5124 | (setq cfd-re-match nil)) | 5139 | (setq cfd-re-match nil)) |
| 5125 | (when (and cfd-prop-match (< cfd-prop-match cfd-continue-pos)) | 5140 | (when (and cfd-prop-match (< cfd-prop-match cfd-continue-pos)) |
| 5126 | (setq cfd-prop-match nil))) | 5141 | (setq cfd-prop-match nil))) ; end of `when' |
| 5127 | 5142 | ||
| 5128 | (if syntactic-pos | 5143 | (if syntactic-pos |
| 5129 | ;; This is the normal case and we got a proper syntactic | 5144 | ;; This is the normal case and we got a proper syntactic |
| @@ -5144,9 +5159,10 @@ comment at the start of cc-engine.el for more info." | |||
| 5144 | ;; good start position for the search, so do it. | 5159 | ;; good start position for the search, so do it. |
| 5145 | (c-find-decl-prefix-search))) | 5160 | (c-find-decl-prefix-search))) |
| 5146 | 5161 | ||
| 5147 | ;; Now loop. Round what? (ACM, 2006/7/5). We already got the first match. | 5162 | ;; Now loop, one decl spot per iteration. We already have the first |
| 5148 | 5163 | ;; match in `cfd-match-pos'. | |
| 5149 | (while (progn | 5164 | (while (progn |
| 5165 | ;; Go foward over "false matches", one per iteration. | ||
| 5150 | (while (and | 5166 | (while (and |
| 5151 | (< cfd-match-pos cfd-limit) | 5167 | (< cfd-match-pos cfd-limit) |
| 5152 | 5168 | ||
| @@ -5187,10 +5203,10 @@ comment at the start of cc-engine.el for more info." | |||
| 5187 | (goto-char cfd-continue-pos) | 5203 | (goto-char cfd-continue-pos) |
| 5188 | t))) | 5204 | t))) |
| 5189 | 5205 | ||
| 5190 | (< (point) cfd-limit)) | 5206 | (< (point) cfd-limit)) ; end of "false matches" condition |
| 5191 | (c-find-decl-prefix-search)) | 5207 | (c-find-decl-prefix-search)) ; end of "false matches" loop |
| 5192 | 5208 | ||
| 5193 | (< (point) cfd-limit)) | 5209 | (< (point) cfd-limit)) ; end of condition for "decl-spot" while |
| 5194 | 5210 | ||
| 5195 | (when (and | 5211 | (when (and |
| 5196 | (>= (point) cfd-start-pos) | 5212 | (>= (point) cfd-start-pos) |
| @@ -5218,7 +5234,7 @@ comment at the start of cc-engine.el for more info." | |||
| 5218 | ;; The matched token was the last thing in the macro, | 5234 | ;; The matched token was the last thing in the macro, |
| 5219 | ;; so the whole match is bogus. | 5235 | ;; so the whole match is bogus. |
| 5220 | (setq cfd-macro-end 0) | 5236 | (setq cfd-macro-end 0) |
| 5221 | nil)))) | 5237 | nil)))) ; end of when condition |
| 5222 | 5238 | ||
| 5223 | (c-debug-put-decl-spot-faces cfd-match-pos (point)) | 5239 | (c-debug-put-decl-spot-faces cfd-match-pos (point)) |
| 5224 | (if (funcall cfd-fun cfd-match-pos (/= cfd-macro-end 0)) | 5240 | (if (funcall cfd-fun cfd-match-pos (/= cfd-macro-end 0)) |
| @@ -5531,8 +5547,6 @@ comment at the start of cc-engine.el for more info." | |||
| 5531 | (when need-new-end | 5547 | (when need-new-end |
| 5532 | (and (> new-end c-new-END) (setq c-new-END new-end)))))) | 5548 | (and (> new-end c-new-END) (setq c-new-END new-end)))))) |
| 5533 | 5549 | ||
| 5534 | |||
| 5535 | |||
| 5536 | (defun c-after-change-check-<>-operators (beg end) | 5550 | (defun c-after-change-check-<>-operators (beg end) |
| 5537 | ;; This is called from `after-change-functions' when | 5551 | ;; This is called from `after-change-functions' when |
| 5538 | ;; c-recognize-<>-arglists' is set. It ensures that no "<" or ">" | 5552 | ;; c-recognize-<>-arglists' is set. It ensures that no "<" or ">" |
| @@ -5867,7 +5881,6 @@ comment at the start of cc-engine.el for more info." | |||
| 5867 | ;; Recursive part of `c-forward-<>-arglist'. | 5881 | ;; Recursive part of `c-forward-<>-arglist'. |
| 5868 | ;; | 5882 | ;; |
| 5869 | ;; This function might do hidden buffer changes. | 5883 | ;; This function might do hidden buffer changes. |
| 5870 | |||
| 5871 | (let ((start (point)) res pos tmp | 5884 | (let ((start (point)) res pos tmp |
| 5872 | ;; Cover this so that any recorded found type ranges are | 5885 | ;; Cover this so that any recorded found type ranges are |
| 5873 | ;; automatically lost if it turns out to not be an angle | 5886 | ;; automatically lost if it turns out to not be an angle |
| @@ -5993,7 +6006,6 @@ comment at the start of cc-engine.el for more info." | |||
| 5993 | (c-keyword-member | 6006 | (c-keyword-member |
| 5994 | (c-keyword-sym (match-string 1)) | 6007 | (c-keyword-sym (match-string 1)) |
| 5995 | 'c-<>-type-kwds))))))) | 6008 | 'c-<>-type-kwds))))))) |
| 5996 | |||
| 5997 | ;; It was an angle bracket arglist. | 6009 | ;; It was an angle bracket arglist. |
| 5998 | (setq c-record-found-types subres) | 6010 | (setq c-record-found-types subres) |
| 5999 | 6011 | ||
| @@ -7100,36 +7112,35 @@ comment at the start of cc-engine.el for more info." | |||
| 7100 | (catch 'at-decl-or-cast | 7112 | (catch 'at-decl-or-cast |
| 7101 | 7113 | ||
| 7102 | ;; CASE 1 | 7114 | ;; CASE 1 |
| 7103 | (when (> paren-depth 0) | 7115 | (when (> paren-depth 0) |
| 7104 | ;; Encountered something inside parens that isn't matched by | 7116 | ;; Encountered something inside parens that isn't matched by |
| 7105 | ;; the `c-type-decl-*' regexps, so it's not a type decl | 7117 | ;; the `c-type-decl-*' regexps, so it's not a type decl |
| 7106 | ;; expression. Try to skip out to the same paren depth to | 7118 | ;; expression. Try to skip out to the same paren depth to |
| 7107 | ;; not confuse the cast check below. | 7119 | ;; not confuse the cast check below. |
| 7108 | (c-safe (goto-char (scan-lists (point) 1 paren-depth))) | 7120 | (c-safe (goto-char (scan-lists (point) 1 paren-depth))) |
| 7109 | ;; If we've found a specifier keyword then it's a | 7121 | ;; If we've found a specifier keyword then it's a |
| 7110 | ;; declaration regardless. | 7122 | ;; declaration regardless. |
| 7111 | (throw 'at-decl-or-cast (eq at-decl-or-cast t))) | 7123 | (throw 'at-decl-or-cast (eq at-decl-or-cast t))) |
| 7112 | 7124 | ||
| 7113 | (setq at-decl-end | 7125 | (setq at-decl-end |
| 7114 | (looking-at (cond ((eq context '<>) "[,>]") | 7126 | (looking-at (cond ((eq context '<>) "[,>]") |
| 7115 | (context "[,\)]") | 7127 | (context "[,\)]") |
| 7116 | (t "[,;]")))) | 7128 | (t "[,;]")))) |
| 7117 | 7129 | ||
| 7118 | ;; Now we've collected info about various characteristics of | 7130 | ;; Now we've collected info about various characteristics of |
| 7119 | ;; the construct we're looking at. Below follows a decision | 7131 | ;; the construct we're looking at. Below follows a decision |
| 7120 | ;; tree based on that. It's ordered to check more certain | 7132 | ;; tree based on that. It's ordered to check more certain |
| 7121 | ;; signs before less certain ones. | 7133 | ;; signs before less certain ones. |
| 7122 | 7134 | ||
| 7123 | (if got-identifier | 7135 | (if got-identifier |
| 7124 | (progn | 7136 | (progn |
| 7125 | |||
| 7126 | ;; CASE 2 | ||
| 7127 | (when (and (or at-type maybe-typeless) | ||
| 7128 | (not (or got-prefix got-parens))) | ||
| 7129 | ;; Got another identifier directly after the type, so it's a | ||
| 7130 | ;; declaration. | ||
| 7131 | (throw 'at-decl-or-cast t)) | ||
| 7132 | 7137 | ||
| 7138 | ;; CASE 2 | ||
| 7139 | (when (and (or at-type maybe-typeless) | ||
| 7140 | (not (or got-prefix got-parens))) | ||
| 7141 | ;; Got another identifier directly after the type, so it's a | ||
| 7142 | ;; declaration. | ||
| 7143 | (throw 'at-decl-or-cast t)) | ||
| 7133 | 7144 | ||
| 7134 | (when (and got-parens | 7145 | (when (and got-parens |
| 7135 | (not got-prefix) | 7146 | (not got-prefix) |
| @@ -7151,9 +7162,9 @@ comment at the start of cc-engine.el for more info." | |||
| 7151 | (c-fdoc-shift-type-backward))) | 7162 | (c-fdoc-shift-type-backward))) |
| 7152 | 7163 | ||
| 7153 | ;; Found no identifier. | 7164 | ;; Found no identifier. |
| 7154 | (if backup-at-type | ||
| 7155 | (progn | ||
| 7156 | 7165 | ||
| 7166 | (if backup-at-type | ||
| 7167 | (progn | ||
| 7157 | 7168 | ||
| 7158 | ;; CASE 3 | 7169 | ;; CASE 3 |
| 7159 | (when (= (point) start) | 7170 | (when (= (point) start) |
| @@ -7176,251 +7187,251 @@ comment at the start of cc-engine.el for more info." | |||
| 7176 | (setq backup-if-not-cast t) | 7187 | (setq backup-if-not-cast t) |
| 7177 | (throw 'at-decl-or-cast t))) | 7188 | (throw 'at-decl-or-cast t))) |
| 7178 | 7189 | ||
| 7179 | ;; CASE 4 | 7190 | ;; CASE 4 |
| 7180 | (when (and got-suffix | 7191 | (when (and got-suffix |
| 7181 | (not got-prefix) | ||
| 7182 | (not got-parens)) | ||
| 7183 | ;; Got a plain list of identifiers followed by some suffix. | ||
| 7184 | ;; If this isn't a cast then the last identifier probably is | ||
| 7185 | ;; the declared one and we should back up to the previous | ||
| 7186 | ;; type. | ||
| 7187 | (setq backup-if-not-cast t) | ||
| 7188 | (throw 'at-decl-or-cast t))) | ||
| 7189 | |||
| 7190 | ;; CASE 5 | ||
| 7191 | (when (eq at-type t) | ||
| 7192 | ;; If the type is known we know that there can't be any | ||
| 7193 | ;; identifier somewhere else, and it's only in declarations in | ||
| 7194 | ;; e.g. function prototypes and in casts that the identifier may | ||
| 7195 | ;; be left out. | ||
| 7196 | (throw 'at-decl-or-cast t)) | ||
| 7197 | |||
| 7198 | (when (= (point) start) | ||
| 7199 | ;; Only got a single identifier (parsed as a type so far). | ||
| 7200 | ;; CASE 6 | ||
| 7201 | (if (and | ||
| 7202 | ;; Check that the identifier isn't at the start of an | ||
| 7203 | ;; expression. | ||
| 7204 | at-decl-end | ||
| 7205 | (cond | ||
| 7206 | ((eq context 'decl) | ||
| 7207 | ;; Inside an arglist that contains declarations. If K&R | ||
| 7208 | ;; style declarations and parenthesis style initializers | ||
| 7209 | ;; aren't allowed then the single identifier must be a | ||
| 7210 | ;; type, else we require that it's known or found | ||
| 7211 | ;; (primitive types are handled above). | ||
| 7212 | (or (and (not c-recognize-knr-p) | ||
| 7213 | (not c-recognize-paren-inits)) | ||
| 7214 | (memq at-type '(known found)))) | ||
| 7215 | ((eq context '<>) | ||
| 7216 | ;; Inside a template arglist. Accept known and found | ||
| 7217 | ;; types; other identifiers could just as well be | ||
| 7218 | ;; constants in C++. | ||
| 7219 | (memq at-type '(known found))))) | ||
| 7220 | (throw 'at-decl-or-cast t) | ||
| 7221 | ;; CASE 7 | ||
| 7222 | ;; Can't be a valid declaration or cast, but if we've found a | ||
| 7223 | ;; specifier it can't be anything else either, so treat it as | ||
| 7224 | ;; an invalid/unfinished declaration or cast. | ||
| 7225 | (throw 'at-decl-or-cast at-decl-or-cast)))) | ||
| 7226 | |||
| 7227 | (if (and got-parens | ||
| 7228 | (not got-prefix) | ||
| 7229 | (not context) | ||
| 7230 | (not (eq at-type t)) | ||
| 7231 | (or backup-at-type | ||
| 7232 | maybe-typeless | ||
| 7233 | backup-maybe-typeless | ||
| 7234 | (when c-recognize-typeless-decls | ||
| 7235 | (or (not got-suffix) | ||
| 7236 | (not (looking-at | ||
| 7237 | c-after-suffixed-type-maybe-decl-key)))))) | ||
| 7238 | ;; Got an empty paren pair and a preceding type that probably | ||
| 7239 | ;; really is the identifier. Shift the type backwards to make | ||
| 7240 | ;; the last one the identifier. This is analogous to the | ||
| 7241 | ;; "backtracking" done inside the `c-type-decl-suffix-key' loop | ||
| 7242 | ;; above. | ||
| 7243 | ;; | ||
| 7244 | ;; Exception: In addition to the conditions in that | ||
| 7245 | ;; "backtracking" code, do not shift backward if we're not | ||
| 7246 | ;; looking at either `c-after-suffixed-type-decl-key' or "[;,]". | ||
| 7247 | ;; Since there's no preceding type, the shift would mean that | ||
| 7248 | ;; the declaration is typeless. But if the regexp doesn't match | ||
| 7249 | ;; then we will simply fall through in the tests below and not | ||
| 7250 | ;; recognize it at all, so it's better to try it as an abstract | ||
| 7251 | ;; declarator instead. | ||
| 7252 | (c-fdoc-shift-type-backward) | ||
| 7253 | |||
| 7254 | ;; Still no identifier. | ||
| 7255 | ;; CASE 8 | ||
| 7256 | (when (and got-prefix (or got-parens got-suffix)) | ||
| 7257 | ;; Require `got-prefix' together with either `got-parens' or | ||
| 7258 | ;; `got-suffix' to recognize it as an abstract declarator: | ||
| 7259 | ;; `got-parens' only is probably an empty function call. | ||
| 7260 | ;; `got-suffix' only can build an ordinary expression together | ||
| 7261 | ;; with the preceding identifier which we've taken as a type. | ||
| 7262 | ;; We could actually accept on `got-prefix' only, but that can | ||
| 7263 | ;; easily occur temporarily while writing an expression so we | ||
| 7264 | ;; avoid that case anyway. We could do a better job if we knew | ||
| 7265 | ;; the point when the fontification was invoked. | ||
| 7266 | (throw 'at-decl-or-cast t)) | ||
| 7267 | |||
| 7268 | ;; CASE 9 | ||
| 7269 | (when (and at-type | ||
| 7270 | (not got-prefix) | ||
| 7271 | (not got-parens) | ||
| 7272 | got-suffix-after-parens | ||
| 7273 | (eq (char-after got-suffix-after-parens) ?\()) | ||
| 7274 | ;; Got a type, no declarator but a paren suffix. I.e. it's a | ||
| 7275 | ;; normal function call after all (or perhaps a C++ style object | ||
| 7276 | ;; instantiation expression). | ||
| 7277 | (throw 'at-decl-or-cast nil)))) | ||
| 7278 | |||
| 7279 | ;; CASE 10 | ||
| 7280 | (when at-decl-or-cast | ||
| 7281 | ;; By now we've located the type in the declaration that we know | ||
| 7282 | ;; we're in. | ||
| 7283 | (throw 'at-decl-or-cast t)) | ||
| 7284 | |||
| 7285 | ;; CASE 11 | ||
| 7286 | (when (and got-identifier | ||
| 7287 | (not context) | ||
| 7288 | (looking-at c-after-suffixed-type-decl-key) | ||
| 7289 | (if (and got-parens | ||
| 7290 | (not got-prefix) | 7192 | (not got-prefix) |
| 7291 | (not got-suffix) | 7193 | (not got-parens)) |
| 7292 | (not (eq at-type t))) | 7194 | ;; Got a plain list of identifiers followed by some suffix. |
| 7293 | ;; Shift the type backward in the case that there's a | 7195 | ;; If this isn't a cast then the last identifier probably is |
| 7294 | ;; single identifier inside parens. That can only | 7196 | ;; the declared one and we should back up to the previous |
| 7295 | ;; occur in K&R style function declarations so it's | 7197 | ;; type. |
| 7296 | ;; more likely that it really is a function call. | 7198 | (setq backup-if-not-cast t) |
| 7297 | ;; Therefore we only do this after | 7199 | (throw 'at-decl-or-cast t))) |
| 7298 | ;; `c-after-suffixed-type-decl-key' has matched. | 7200 | |
| 7299 | (progn (c-fdoc-shift-type-backward) t) | 7201 | ;; CASE 5 |
| 7300 | got-suffix-after-parens)) | 7202 | (when (eq at-type t) |
| 7301 | ;; A declaration according to `c-after-suffixed-type-decl-key'. | 7203 | ;; If the type is known we know that there can't be any |
| 7302 | (throw 'at-decl-or-cast t)) | 7204 | ;; identifier somewhere else, and it's only in declarations in |
| 7303 | 7205 | ;; e.g. function prototypes and in casts that the identifier may | |
| 7304 | ;; CASE 12 | 7206 | ;; be left out. |
| 7305 | (when (and (or got-prefix (not got-parens)) | 7207 | (throw 'at-decl-or-cast t)) |
| 7306 | (memq at-type '(t known))) | 7208 | |
| 7307 | ;; It's a declaration if a known type precedes it and it can't be a | 7209 | (when (= (point) start) |
| 7308 | ;; function call. | 7210 | ;; Only got a single identifier (parsed as a type so far). |
| 7309 | (throw 'at-decl-or-cast t)) | 7211 | ;; CASE 6 |
| 7310 | 7212 | (if (and | |
| 7311 | ;; If we get here we can't tell if this is a type decl or a normal | 7213 | ;; Check that the identifier isn't at the start of an |
| 7312 | ;; expression by looking at it alone. (That's under the assumption | 7214 | ;; expression. |
| 7313 | ;; that normal expressions always can look like type decl expressions, | 7215 | at-decl-end |
| 7314 | ;; which isn't really true but the cases where it doesn't hold are so | 7216 | (cond |
| 7315 | ;; uncommon (e.g. some placements of "const" in C++) it's not worth | 7217 | ((eq context 'decl) |
| 7316 | ;; the effort to look for them.) | 7218 | ;; Inside an arglist that contains declarations. If K&R |
| 7219 | ;; style declarations and parenthesis style initializers | ||
| 7220 | ;; aren't allowed then the single identifier must be a | ||
| 7221 | ;; type, else we require that it's known or found | ||
| 7222 | ;; (primitive types are handled above). | ||
| 7223 | (or (and (not c-recognize-knr-p) | ||
| 7224 | (not c-recognize-paren-inits)) | ||
| 7225 | (memq at-type '(known found)))) | ||
| 7226 | ((eq context '<>) | ||
| 7227 | ;; Inside a template arglist. Accept known and found | ||
| 7228 | ;; types; other identifiers could just as well be | ||
| 7229 | ;; constants in C++. | ||
| 7230 | (memq at-type '(known found))))) | ||
| 7231 | (throw 'at-decl-or-cast t) | ||
| 7232 | ;; CASE 7 | ||
| 7233 | ;; Can't be a valid declaration or cast, but if we've found a | ||
| 7234 | ;; specifier it can't be anything else either, so treat it as | ||
| 7235 | ;; an invalid/unfinished declaration or cast. | ||
| 7236 | (throw 'at-decl-or-cast at-decl-or-cast)))) | ||
| 7237 | |||
| 7238 | (if (and got-parens | ||
| 7239 | (not got-prefix) | ||
| 7240 | (not context) | ||
| 7241 | (not (eq at-type t)) | ||
| 7242 | (or backup-at-type | ||
| 7243 | maybe-typeless | ||
| 7244 | backup-maybe-typeless | ||
| 7245 | (when c-recognize-typeless-decls | ||
| 7246 | (or (not got-suffix) | ||
| 7247 | (not (looking-at | ||
| 7248 | c-after-suffixed-type-maybe-decl-key)))))) | ||
| 7249 | ;; Got an empty paren pair and a preceding type that probably | ||
| 7250 | ;; really is the identifier. Shift the type backwards to make | ||
| 7251 | ;; the last one the identifier. This is analogous to the | ||
| 7252 | ;; "backtracking" done inside the `c-type-decl-suffix-key' loop | ||
| 7253 | ;; above. | ||
| 7254 | ;; | ||
| 7255 | ;; Exception: In addition to the conditions in that | ||
| 7256 | ;; "backtracking" code, do not shift backward if we're not | ||
| 7257 | ;; looking at either `c-after-suffixed-type-decl-key' or "[;,]". | ||
| 7258 | ;; Since there's no preceding type, the shift would mean that | ||
| 7259 | ;; the declaration is typeless. But if the regexp doesn't match | ||
| 7260 | ;; then we will simply fall through in the tests below and not | ||
| 7261 | ;; recognize it at all, so it's better to try it as an abstract | ||
| 7262 | ;; declarator instead. | ||
| 7263 | (c-fdoc-shift-type-backward) | ||
| 7264 | |||
| 7265 | ;; Still no identifier. | ||
| 7266 | ;; CASE 8 | ||
| 7267 | (when (and got-prefix (or got-parens got-suffix)) | ||
| 7268 | ;; Require `got-prefix' together with either `got-parens' or | ||
| 7269 | ;; `got-suffix' to recognize it as an abstract declarator: | ||
| 7270 | ;; `got-parens' only is probably an empty function call. | ||
| 7271 | ;; `got-suffix' only can build an ordinary expression together | ||
| 7272 | ;; with the preceding identifier which we've taken as a type. | ||
| 7273 | ;; We could actually accept on `got-prefix' only, but that can | ||
| 7274 | ;; easily occur temporarily while writing an expression so we | ||
| 7275 | ;; avoid that case anyway. We could do a better job if we knew | ||
| 7276 | ;; the point when the fontification was invoked. | ||
| 7277 | (throw 'at-decl-or-cast t)) | ||
| 7278 | |||
| 7279 | ;; CASE 9 | ||
| 7280 | (when (and at-type | ||
| 7281 | (not got-prefix) | ||
| 7282 | (not got-parens) | ||
| 7283 | got-suffix-after-parens | ||
| 7284 | (eq (char-after got-suffix-after-parens) ?\()) | ||
| 7285 | ;; Got a type, no declarator but a paren suffix. I.e. it's a | ||
| 7286 | ;; normal function call after all (or perhaps a C++ style object | ||
| 7287 | ;; instantiation expression). | ||
| 7288 | (throw 'at-decl-or-cast nil)))) | ||
| 7289 | |||
| 7290 | ;; CASE 10 | ||
| 7291 | (when at-decl-or-cast | ||
| 7292 | ;; By now we've located the type in the declaration that we know | ||
| 7293 | ;; we're in. | ||
| 7294 | (throw 'at-decl-or-cast t)) | ||
| 7295 | |||
| 7296 | ;; CASE 11 | ||
| 7297 | (when (and got-identifier | ||
| 7298 | (not context) | ||
| 7299 | (looking-at c-after-suffixed-type-decl-key) | ||
| 7300 | (if (and got-parens | ||
| 7301 | (not got-prefix) | ||
| 7302 | (not got-suffix) | ||
| 7303 | (not (eq at-type t))) | ||
| 7304 | ;; Shift the type backward in the case that there's a | ||
| 7305 | ;; single identifier inside parens. That can only | ||
| 7306 | ;; occur in K&R style function declarations so it's | ||
| 7307 | ;; more likely that it really is a function call. | ||
| 7308 | ;; Therefore we only do this after | ||
| 7309 | ;; `c-after-suffixed-type-decl-key' has matched. | ||
| 7310 | (progn (c-fdoc-shift-type-backward) t) | ||
| 7311 | got-suffix-after-parens)) | ||
| 7312 | ;; A declaration according to `c-after-suffixed-type-decl-key'. | ||
| 7313 | (throw 'at-decl-or-cast t)) | ||
| 7314 | |||
| 7315 | ;; CASE 12 | ||
| 7316 | (when (and (or got-prefix (not got-parens)) | ||
| 7317 | (memq at-type '(t known))) | ||
| 7318 | ;; It's a declaration if a known type precedes it and it can't be a | ||
| 7319 | ;; function call. | ||
| 7320 | (throw 'at-decl-or-cast t)) | ||
| 7321 | |||
| 7322 | ;; If we get here we can't tell if this is a type decl or a normal | ||
| 7323 | ;; expression by looking at it alone. (That's under the assumption | ||
| 7324 | ;; that normal expressions always can look like type decl expressions, | ||
| 7325 | ;; which isn't really true but the cases where it doesn't hold are so | ||
| 7326 | ;; uncommon (e.g. some placements of "const" in C++) it's not worth | ||
| 7327 | ;; the effort to look for them.) | ||
| 7317 | 7328 | ||
| 7318 | ;;; 2008-04-16: commented out the next form, to allow the function to recognize | 7329 | ;;; 2008-04-16: commented out the next form, to allow the function to recognize |
| 7319 | ;;; "foo (int bar)" in CC (an implicit type (in class foo) without a semicolon) | 7330 | ;;; "foo (int bar)" in CC (an implicit type (in class foo) without a semicolon) |
| 7320 | ;;; as a(n almost complete) declaration, enabling it to be fontified. | 7331 | ;;; as a(n almost complete) declaration, enabling it to be fontified. |
| 7321 | ;; CASE 13 | 7332 | ;; CASE 13 |
| 7322 | ;; (unless (or at-decl-end (looking-at "=[^=]")) | 7333 | ;; (unless (or at-decl-end (looking-at "=[^=]")) |
| 7323 | ;; If this is a declaration it should end here or its initializer(*) | 7334 | ;; If this is a declaration it should end here or its initializer(*) |
| 7324 | ;; should start here, so check for allowed separation tokens. Note | 7335 | ;; should start here, so check for allowed separation tokens. Note |
| 7325 | ;; that this rule doesn't work e.g. with a K&R arglist after a | 7336 | ;; that this rule doesn't work e.g. with a K&R arglist after a |
| 7326 | ;; function header. | 7337 | ;; function header. |
| 7327 | ;; | 7338 | ;; |
| 7328 | ;; *) Don't check for C++ style initializers using parens | 7339 | ;; *) Don't check for C++ style initializers using parens |
| 7329 | ;; since those already have been matched as suffixes. | 7340 | ;; since those already have been matched as suffixes. |
| 7330 | ;; | 7341 | ;; |
| 7331 | ;; If `at-decl-or-cast' is then we've found some other sign that | 7342 | ;; If `at-decl-or-cast' is then we've found some other sign that |
| 7332 | ;; it's a declaration or cast, so then it's probably an | 7343 | ;; it's a declaration or cast, so then it's probably an |
| 7333 | ;; invalid/unfinished one. | 7344 | ;; invalid/unfinished one. |
| 7334 | ;; (throw 'at-decl-or-cast at-decl-or-cast)) | 7345 | ;; (throw 'at-decl-or-cast at-decl-or-cast)) |
| 7335 | 7346 | ||
| 7336 | ;; Below are tests that only should be applied when we're certain to | 7347 | ;; Below are tests that only should be applied when we're certain to |
| 7337 | ;; not have parsed halfway through an expression. | 7348 | ;; not have parsed halfway through an expression. |
| 7338 | 7349 | ||
| 7339 | ;; CASE 14 | 7350 | ;; CASE 14 |
| 7340 | (when (memq at-type '(t known)) | 7351 | (when (memq at-type '(t known)) |
| 7341 | ;; The expression starts with a known type so treat it as a | 7352 | ;; The expression starts with a known type so treat it as a |
| 7342 | ;; declaration. | 7353 | ;; declaration. |
| 7343 | (throw 'at-decl-or-cast t)) | 7354 | (throw 'at-decl-or-cast t)) |
| 7344 | 7355 | ||
| 7345 | ;; CASE 15 | 7356 | ;; CASE 15 |
| 7346 | (when (and (c-major-mode-is 'c++-mode) | 7357 | (when (and (c-major-mode-is 'c++-mode) |
| 7347 | ;; In C++ we check if the identifier is a known type, since | 7358 | ;; In C++ we check if the identifier is a known type, since |
| 7348 | ;; (con|de)structors use the class name as identifier. | 7359 | ;; (con|de)structors use the class name as identifier. |
| 7349 | ;; We've always shifted over the identifier as a type and | 7360 | ;; We've always shifted over the identifier as a type and |
| 7350 | ;; then backed up again in this case. | 7361 | ;; then backed up again in this case. |
| 7351 | identifier-type | 7362 | identifier-type |
| 7352 | (or (memq identifier-type '(found known)) | 7363 | (or (memq identifier-type '(found known)) |
| 7353 | (and (eq (char-after identifier-start) ?~) | 7364 | (and (eq (char-after identifier-start) ?~) |
| 7354 | ;; `at-type' probably won't be 'found for | 7365 | ;; `at-type' probably won't be 'found for |
| 7355 | ;; destructors since the "~" is then part of the | 7366 | ;; destructors since the "~" is then part of the |
| 7356 | ;; type name being checked against the list of | 7367 | ;; type name being checked against the list of |
| 7357 | ;; known types, so do a check without that | 7368 | ;; known types, so do a check without that |
| 7358 | ;; operator. | 7369 | ;; operator. |
| 7359 | (or (save-excursion | 7370 | (or (save-excursion |
| 7360 | (goto-char (1+ identifier-start)) | 7371 | (goto-char (1+ identifier-start)) |
| 7361 | (c-forward-syntactic-ws) | 7372 | (c-forward-syntactic-ws) |
| 7362 | (c-with-syntax-table | 7373 | (c-with-syntax-table |
| 7363 | c-identifier-syntax-table | 7374 | c-identifier-syntax-table |
| 7364 | (looking-at c-known-type-key))) | 7375 | (looking-at c-known-type-key))) |
| 7365 | (save-excursion | 7376 | (save-excursion |
| 7366 | (goto-char (1+ identifier-start)) | 7377 | (goto-char (1+ identifier-start)) |
| 7367 | ;; We have already parsed the type earlier, | 7378 | ;; We have already parsed the type earlier, |
| 7368 | ;; so it'd be possible to cache the end | 7379 | ;; so it'd be possible to cache the end |
| 7369 | ;; position instead of redoing it here, but | 7380 | ;; position instead of redoing it here, but |
| 7370 | ;; then we'd need to keep track of another | 7381 | ;; then we'd need to keep track of another |
| 7371 | ;; position everywhere. | 7382 | ;; position everywhere. |
| 7372 | (c-check-type (point) | 7383 | (c-check-type (point) |
| 7373 | (progn (c-forward-type) | 7384 | (progn (c-forward-type) |
| 7374 | (point)))))))) | 7385 | (point)))))))) |
| 7375 | (throw 'at-decl-or-cast t)) | 7386 | (throw 'at-decl-or-cast t)) |
| 7376 | 7387 | ||
| 7377 | (if got-identifier | 7388 | (if got-identifier |
| 7378 | (progn | 7389 | (progn |
| 7379 | ;; CASE 16 | 7390 | ;; CASE 16 |
| 7380 | (when (and got-prefix-before-parens | 7391 | (when (and got-prefix-before-parens |
| 7381 | at-type | 7392 | at-type |
| 7382 | (or at-decl-end (looking-at "=[^=]")) | 7393 | (or at-decl-end (looking-at "=[^=]")) |
| 7383 | (not context) | 7394 | (not context) |
| 7384 | (not got-suffix)) | 7395 | (not got-suffix)) |
| 7385 | ;; Got something like "foo * bar;". Since we're not inside an | 7396 | ;; Got something like "foo * bar;". Since we're not inside an |
| 7386 | ;; arglist it would be a meaningless expression because the | 7397 | ;; arglist it would be a meaningless expression because the |
| 7387 | ;; result isn't used. We therefore choose to recognize it as | 7398 | ;; result isn't used. We therefore choose to recognize it as |
| 7388 | ;; a declaration. Do not allow a suffix since it could then | 7399 | ;; a declaration. Do not allow a suffix since it could then |
| 7389 | ;; be a function call. | 7400 | ;; be a function call. |
| 7390 | (throw 'at-decl-or-cast t)) | 7401 | (throw 'at-decl-or-cast t)) |
| 7391 | 7402 | ||
| 7392 | ;; CASE 17 | 7403 | ;; CASE 17 |
| 7393 | (when (and (or got-suffix-after-parens | 7404 | (when (and (or got-suffix-after-parens |
| 7394 | (looking-at "=[^=]")) | 7405 | (looking-at "=[^=]")) |
| 7395 | (eq at-type 'found) | 7406 | (eq at-type 'found) |
| 7396 | (not (eq context 'arglist))) | 7407 | (not (eq context 'arglist))) |
| 7397 | ;; Got something like "a (*b) (c);" or "a (b) = c;". It could | 7408 | ;; Got something like "a (*b) (c);" or "a (b) = c;". It could |
| 7398 | ;; be an odd expression or it could be a declaration. Treat | 7409 | ;; be an odd expression or it could be a declaration. Treat |
| 7399 | ;; it as a declaration if "a" has been used as a type | 7410 | ;; it as a declaration if "a" has been used as a type |
| 7400 | ;; somewhere else (if it's a known type we won't get here). | 7411 | ;; somewhere else (if it's a known type we won't get here). |
| 7401 | (throw 'at-decl-or-cast t))) | 7412 | (throw 'at-decl-or-cast t))) |
| 7402 | 7413 | ||
| 7403 | ;; CASE 18 | 7414 | ;; CASE 18 |
| 7404 | (when (and context | 7415 | (when (and context |
| 7405 | (or got-prefix | 7416 | (or got-prefix |
| 7406 | (and (eq context 'decl) | 7417 | (and (eq context 'decl) |
| 7407 | (not c-recognize-paren-inits) | 7418 | (not c-recognize-paren-inits) |
| 7408 | (or got-parens got-suffix)))) | 7419 | (or got-parens got-suffix)))) |
| 7409 | ;; Got a type followed by an abstract declarator. If `got-prefix' | 7420 | ;; Got a type followed by an abstract declarator. If `got-prefix' |
| 7410 | ;; is set it's something like "a *" without anything after it. If | 7421 | ;; is set it's something like "a *" without anything after it. If |
| 7411 | ;; `got-parens' or `got-suffix' is set it's "a()", "a[]", "a()[]", | 7422 | ;; `got-parens' or `got-suffix' is set it's "a()", "a[]", "a()[]", |
| 7412 | ;; or similar, which we accept only if the context rules out | 7423 | ;; or similar, which we accept only if the context rules out |
| 7413 | ;; expressions. | 7424 | ;; expressions. |
| 7414 | (throw 'at-decl-or-cast t))) | 7425 | (throw 'at-decl-or-cast t))) |
| 7415 | 7426 | ||
| 7416 | ;; If we had a complete symbol table here (which rules out | 7427 | ;; If we had a complete symbol table here (which rules out |
| 7417 | ;; `c-found-types') we should return t due to the disambiguation rule | 7428 | ;; `c-found-types') we should return t due to the disambiguation rule |
| 7418 | ;; (in at least C++) that anything that can be parsed as a declaration | 7429 | ;; (in at least C++) that anything that can be parsed as a declaration |
| 7419 | ;; is a declaration. Now we're being more defensive and prefer to | 7430 | ;; is a declaration. Now we're being more defensive and prefer to |
| 7420 | ;; highlight things like "foo (bar);" as a declaration only if we're | 7431 | ;; highlight things like "foo (bar);" as a declaration only if we're |
| 7421 | ;; inside an arglist that contains declarations. | 7432 | ;; inside an arglist that contains declarations. |
| 7422 | ;; CASE 19 | 7433 | ;; CASE 19 |
| 7423 | (eq context 'decl)))) | 7434 | (eq context 'decl)))) |
| 7424 | 7435 | ||
| 7425 | ;; The point is now after the type decl expression. | 7436 | ;; The point is now after the type decl expression. |
| 7426 | 7437 | ||
| @@ -7609,10 +7620,10 @@ comment at the start of cc-engine.el for more info." | |||
| 7609 | (c-put-c-type-property (1- (point)) 'c-decl-end) | 7620 | (c-put-c-type-property (1- (point)) 'c-decl-end) |
| 7610 | t) | 7621 | t) |
| 7611 | 7622 | ||
| 7612 | ;; It's an unfinished label. We consider the keyword enough | 7623 | ;; It's an unfinished label. We consider the keyword enough |
| 7613 | ;; to recognize it as a label, so that it gets fontified. | 7624 | ;; to recognize it as a label, so that it gets fontified. |
| 7614 | ;; Leave the point at the end of it, but don't put any | 7625 | ;; Leave the point at the end of it, but don't put any |
| 7615 | ;; `c-decl-end' marker. | 7626 | ;; `c-decl-end' marker. |
| 7616 | (goto-char kwd-end) | 7627 | (goto-char kwd-end) |
| 7617 | t)))) | 7628 | t)))) |
| 7618 | 7629 | ||
| @@ -7797,69 +7808,69 @@ comment at the start of cc-engine.el for more info." | |||
| 7797 | ;; | 7808 | ;; |
| 7798 | ;; This function might do hidden buffer changes. | 7809 | ;; This function might do hidden buffer changes. |
| 7799 | 7810 | ||
| 7800 | (let ((start (point)) | 7811 | (let ((start (point)) |
| 7801 | start-char | 7812 | start-char |
| 7802 | (c-promote-possible-types t) | 7813 | (c-promote-possible-types t) |
| 7803 | lim | 7814 | lim |
| 7804 | ;; Turn off recognition of angle bracket arglists while parsing | 7815 | ;; Turn off recognition of angle bracket arglists while parsing |
| 7805 | ;; types here since the protocol reference list might then be | 7816 | ;; types here since the protocol reference list might then be |
| 7806 | ;; considered part of the preceding name or superclass-name. | 7817 | ;; considered part of the preceding name or superclass-name. |
| 7807 | c-recognize-<>-arglists) | 7818 | c-recognize-<>-arglists) |
| 7808 | 7819 | ||
| 7809 | (if (or | 7820 | (if (or |
| 7810 | (when (looking-at | 7821 | (when (looking-at |
| 7811 | (eval-when-compile | 7822 | (eval-when-compile |
| 7812 | (c-make-keywords-re t | 7823 | (c-make-keywords-re t |
| 7813 | (append (c-lang-const c-protection-kwds objc) | 7824 | (append (c-lang-const c-protection-kwds objc) |
| 7814 | '("@end")) | 7825 | '("@end")) |
| 7815 | 'objc-mode))) | 7826 | 'objc-mode))) |
| 7816 | (goto-char (match-end 1)) | 7827 | (goto-char (match-end 1)) |
| 7817 | t) | 7828 | t) |
| 7818 | 7829 | ||
| 7819 | (and | 7830 | (and |
| 7820 | (looking-at | 7831 | (looking-at |
| 7821 | (eval-when-compile | 7832 | (eval-when-compile |
| 7822 | (c-make-keywords-re t | 7833 | (c-make-keywords-re t |
| 7823 | '("@interface" "@implementation" "@protocol") | 7834 | '("@interface" "@implementation" "@protocol") |
| 7824 | 'objc-mode))) | 7835 | 'objc-mode))) |
| 7825 | 7836 | ||
| 7826 | ;; Handle the name of the class itself. | 7837 | ;; Handle the name of the class itself. |
| 7827 | (progn | 7838 | (progn |
| 7828 | ; (c-forward-token-2) ; 2006/1/13 This doesn't move if the token's | 7839 | ;; (c-forward-token-2) ; 2006/1/13 This doesn't move if the token's |
| 7829 | ; at EOB. | 7840 | ;; at EOB. |
| 7830 | (goto-char (match-end 0)) | 7841 | (goto-char (match-end 0)) |
| 7831 | (setq lim (point)) | 7842 | (setq lim (point)) |
| 7832 | (c-skip-ws-forward) | 7843 | (c-skip-ws-forward) |
| 7833 | (c-forward-type)) | 7844 | (c-forward-type)) |
| 7834 | 7845 | ||
| 7835 | (catch 'break | 7846 | (catch 'break |
| 7836 | ;; Look for ": superclass-name" or "( category-name )". | 7847 | ;; Look for ": superclass-name" or "( category-name )". |
| 7837 | (when (looking-at "[:\(]") | 7848 | (when (looking-at "[:\(]") |
| 7838 | (setq start-char (char-after)) | 7849 | (setq start-char (char-after)) |
| 7850 | (forward-char) | ||
| 7851 | (c-forward-syntactic-ws) | ||
| 7852 | (unless (c-forward-type) (throw 'break nil)) | ||
| 7853 | (when (eq start-char ?\() | ||
| 7854 | (unless (eq (char-after) ?\)) (throw 'break nil)) | ||
| 7839 | (forward-char) | 7855 | (forward-char) |
| 7840 | (c-forward-syntactic-ws) | 7856 | (c-forward-syntactic-ws))) |
| 7841 | (unless (c-forward-type) (throw 'break nil)) | ||
| 7842 | (when (eq start-char ?\() | ||
| 7843 | (unless (eq (char-after) ?\)) (throw 'break nil)) | ||
| 7844 | (forward-char) | ||
| 7845 | (c-forward-syntactic-ws))) | ||
| 7846 | |||
| 7847 | ;; Look for a protocol reference list. | ||
| 7848 | (if (eq (char-after) ?<) | ||
| 7849 | (let ((c-recognize-<>-arglists t) | ||
| 7850 | (c-parse-and-markup-<>-arglists t) | ||
| 7851 | c-restricted-<>-arglists) | ||
| 7852 | (c-forward-<>-arglist t)) | ||
| 7853 | t)))) | ||
| 7854 | 7857 | ||
| 7855 | (progn | 7858 | ;; Look for a protocol reference list. |
| 7856 | (c-backward-syntactic-ws lim) | 7859 | (if (eq (char-after) ?<) |
| 7857 | (c-clear-c-type-property start (1- (point)) 'c-decl-end) | 7860 | (let ((c-recognize-<>-arglists t) |
| 7858 | (c-put-c-type-property (1- (point)) 'c-decl-end) | 7861 | (c-parse-and-markup-<>-arglists t) |
| 7859 | t) | 7862 | c-restricted-<>-arglists) |
| 7863 | (c-forward-<>-arglist t)) | ||
| 7864 | t)))) | ||
| 7860 | 7865 | ||
| 7861 | (c-clear-c-type-property start (point) 'c-decl-end) | 7866 | (progn |
| 7862 | nil))) | 7867 | (c-backward-syntactic-ws lim) |
| 7868 | (c-clear-c-type-property start (1- (point)) 'c-decl-end) | ||
| 7869 | (c-put-c-type-property (1- (point)) 'c-decl-end) | ||
| 7870 | t) | ||
| 7871 | |||
| 7872 | (c-clear-c-type-property start (point) 'c-decl-end) | ||
| 7873 | nil))) | ||
| 7863 | 7874 | ||
| 7864 | (defun c-beginning-of-inheritance-list (&optional lim) | 7875 | (defun c-beginning-of-inheritance-list (&optional lim) |
| 7865 | ;; Go to the first non-whitespace after the colon that starts a | 7876 | ;; Go to the first non-whitespace after the colon that starts a |
| @@ -7946,7 +7957,7 @@ comment at the start of cc-engine.el for more info." | |||
| 7946 | ;; | 7957 | ;; |
| 7947 | ;; This function might do hidden buffer changes. | 7958 | ;; This function might do hidden buffer changes. |
| 7948 | 7959 | ||
| 7949 | (let ((beg (point)) end id-start) | 7960 | (let ((beg (point)) id-start) |
| 7950 | (and | 7961 | (and |
| 7951 | (eq (c-beginning-of-statement-1 lim) 'same) | 7962 | (eq (c-beginning-of-statement-1 lim) 'same) |
| 7952 | 7963 | ||
| @@ -8036,54 +8047,54 @@ comment at the start of cc-engine.el for more info." | |||
| 8036 | (throw 'knr nil))) | 8047 | (throw 'knr nil))) |
| 8037 | 8048 | ||
| 8038 | (if after-rparen | 8049 | (if after-rparen |
| 8039 | ;; We're inside a paren. Could it be our argument list....? | 8050 | ;; We're inside a paren. Could it be our argument list....? |
| 8040 | (if | 8051 | (if |
| 8041 | (and | 8052 | (and |
| 8042 | (progn | 8053 | (progn |
| 8043 | (goto-char after-rparen) | 8054 | (goto-char after-rparen) |
| 8044 | (unless (c-go-list-backward) (throw 'knr nil)) ; | 8055 | (unless (c-go-list-backward) (throw 'knr nil)) ; |
| 8045 | ;; FIXME!!! What about macros between the parens? 2007/01/20 | 8056 | ;; FIXME!!! What about macros between the parens? 2007/01/20 |
| 8046 | (setq before-lparen (point))) | 8057 | (setq before-lparen (point))) |
| 8047 | 8058 | ||
| 8048 | ;; It can't be the arg list if next token is ; or { | 8059 | ;; It can't be the arg list if next token is ; or { |
| 8049 | (progn (goto-char after-rparen) | 8060 | (progn (goto-char after-rparen) |
| 8050 | (c-forward-syntactic-ws) | 8061 | (c-forward-syntactic-ws) |
| 8051 | (not (memq (char-after) '(?\; ?\{ ?\=)))) | 8062 | (not (memq (char-after) '(?\; ?\{ ?\=)))) |
| 8052 | 8063 | ||
| 8053 | ;; Is the thing preceding the list an identifier (the | 8064 | ;; Is the thing preceding the list an identifier (the |
| 8054 | ;; function name), or a macro expansion? | 8065 | ;; function name), or a macro expansion? |
| 8055 | (progn | 8066 | (progn |
| 8056 | (goto-char before-lparen) | 8067 | (goto-char before-lparen) |
| 8057 | (eq (c-backward-token-2) 0) | 8068 | (eq (c-backward-token-2) 0) |
| 8058 | (or (eq (c-on-identifier) (point)) | 8069 | (or (eq (c-on-identifier) (point)) |
| 8059 | (and (eq (char-after) ?\)) | 8070 | (and (eq (char-after) ?\)) |
| 8060 | (c-go-up-list-backward) | 8071 | (c-go-up-list-backward) |
| 8061 | (eq (c-backward-token-2) 0) | 8072 | (eq (c-backward-token-2) 0) |
| 8062 | (eq (c-on-identifier) (point))))) | 8073 | (eq (c-on-identifier) (point))))) |
| 8063 | 8074 | ||
| 8064 | ;; Have we got a non-empty list of comma-separated | 8075 | ;; Have we got a non-empty list of comma-separated |
| 8065 | ;; identifiers? | 8076 | ;; identifiers? |
| 8066 | (progn | 8077 | (progn |
| 8067 | (goto-char before-lparen) | 8078 | (goto-char before-lparen) |
| 8068 | (c-forward-token-2) ; to first token inside parens | 8079 | (c-forward-token-2) ; to first token inside parens |
| 8069 | (and | 8080 | (and |
| 8070 | (c-on-identifier) | 8081 | (c-on-identifier) |
| 8071 | (c-forward-token-2) | 8082 | (c-forward-token-2) |
| 8072 | (catch 'id-list | 8083 | (catch 'id-list |
| 8073 | (while (eq (char-after) ?\,) | 8084 | (while (eq (char-after) ?\,) |
| 8074 | (c-forward-token-2) | 8085 | (c-forward-token-2) |
| 8075 | (unless (c-on-identifier) (throw 'id-list nil)) | 8086 | (unless (c-on-identifier) (throw 'id-list nil)) |
| 8076 | (c-forward-token-2)) | 8087 | (c-forward-token-2)) |
| 8077 | (eq (char-after) ?\)))))) | 8088 | (eq (char-after) ?\)))))) |
| 8078 | 8089 | ||
| 8079 | ;; ...Yes. We've identified the function's argument list. | 8090 | ;; ...Yes. We've identified the function's argument list. |
| 8080 | (throw 'knr | 8091 | (throw 'knr |
| 8081 | (progn (goto-char after-rparen) | 8092 | (progn (goto-char after-rparen) |
| 8082 | (c-forward-syntactic-ws) | 8093 | (c-forward-syntactic-ws) |
| 8083 | (point))) | 8094 | (point))) |
| 8084 | 8095 | ||
| 8085 | ;; ...No. The current parens aren't the function's arg list. | 8096 | ;; ...No. The current parens aren't the function's arg list. |
| 8086 | (goto-char before-lparen)) | 8097 | (goto-char before-lparen)) |
| 8087 | 8098 | ||
| 8088 | (or (c-go-list-backward) ; backwards over [ .... ] | 8099 | (or (c-go-list-backward) ; backwards over [ .... ] |
| 8089 | (throw 'knr nil))))))))) | 8100 | (throw 'knr nil))))))))) |
| @@ -8289,7 +8300,7 @@ comment at the start of cc-engine.el for more info." | |||
| 8289 | (and | 8300 | (and |
| 8290 | (progn | 8301 | (progn |
| 8291 | (while ; keep going back to "[;={"s until we either find | 8302 | (while ; keep going back to "[;={"s until we either find |
| 8292 | ; no more, or get to one which isn't an "operator =" | 8303 | ; no more, or get to one which isn't an "operator =" |
| 8293 | (and (c-syntactic-re-search-forward "[;={]" start t t t) | 8304 | (and (c-syntactic-re-search-forward "[;={]" start t t t) |
| 8294 | (eq (char-before) ?=) | 8305 | (eq (char-before) ?=) |
| 8295 | c-overloadable-operators-regexp | 8306 | c-overloadable-operators-regexp |
| @@ -8612,86 +8623,86 @@ comment at the start of cc-engine.el for more info." | |||
| 8612 | (while (and (not bufpos) | 8623 | (while (and (not bufpos) |
| 8613 | containing-sexp) | 8624 | containing-sexp) |
| 8614 | (when paren-state | 8625 | (when paren-state |
| 8615 | (if (consp (car paren-state)) | 8626 | (if (consp (car paren-state)) |
| 8616 | (setq lim (cdr (car paren-state)) | 8627 | (setq lim (cdr (car paren-state)) |
| 8617 | paren-state (cdr paren-state)) | 8628 | paren-state (cdr paren-state)) |
| 8618 | (setq lim (car paren-state))) | 8629 | (setq lim (car paren-state))) |
| 8619 | (when paren-state | 8630 | (when paren-state |
| 8620 | (setq next-containing (car paren-state) | 8631 | (setq next-containing (car paren-state) |
| 8621 | paren-state (cdr paren-state)))) | 8632 | paren-state (cdr paren-state)))) |
| 8622 | (goto-char containing-sexp) | 8633 | (goto-char containing-sexp) |
| 8623 | (if (c-looking-at-inexpr-block next-containing next-containing) | 8634 | (if (c-looking-at-inexpr-block next-containing next-containing) |
| 8624 | ;; We're in an in-expression block of some kind. Do not | 8635 | ;; We're in an in-expression block of some kind. Do not |
| 8625 | ;; check nesting. We deliberately set the limit to the | 8636 | ;; check nesting. We deliberately set the limit to the |
| 8626 | ;; containing sexp, so that c-looking-at-inexpr-block | 8637 | ;; containing sexp, so that c-looking-at-inexpr-block |
| 8627 | ;; doesn't check for an identifier before it. | 8638 | ;; doesn't check for an identifier before it. |
| 8628 | (setq containing-sexp nil) | 8639 | (setq containing-sexp nil) |
| 8629 | ;; see if the open brace is preceded by = or [...] in | 8640 | ;; see if the open brace is preceded by = or [...] in |
| 8630 | ;; this statement, but watch out for operator= | 8641 | ;; this statement, but watch out for operator= |
| 8631 | (setq braceassignp 'dontknow) | 8642 | (setq braceassignp 'dontknow) |
| 8632 | (c-backward-token-2 1 t lim) | 8643 | (c-backward-token-2 1 t lim) |
| 8633 | ;; Checks to do only on the first sexp before the brace. | 8644 | ;; Checks to do only on the first sexp before the brace. |
| 8634 | (when (and c-opt-inexpr-brace-list-key | 8645 | (when (and c-opt-inexpr-brace-list-key |
| 8635 | (eq (char-after) ?\[)) | 8646 | (eq (char-after) ?\[)) |
| 8636 | ;; In Java, an initialization brace list may follow | 8647 | ;; In Java, an initialization brace list may follow |
| 8637 | ;; directly after "new Foo[]", so check for a "new" | 8648 | ;; directly after "new Foo[]", so check for a "new" |
| 8638 | ;; earlier. | 8649 | ;; earlier. |
| 8639 | (while (eq braceassignp 'dontknow) | ||
| 8640 | (setq braceassignp | ||
| 8641 | (cond ((/= (c-backward-token-2 1 t lim) 0) nil) | ||
| 8642 | ((looking-at c-opt-inexpr-brace-list-key) t) | ||
| 8643 | ((looking-at "\\sw\\|\\s_\\|[.[]") | ||
| 8644 | ;; Carry on looking if this is an | ||
| 8645 | ;; identifier (may contain "." in Java) | ||
| 8646 | ;; or another "[]" sexp. | ||
| 8647 | 'dontknow) | ||
| 8648 | (t nil))))) | ||
| 8649 | ;; Checks to do on all sexps before the brace, up to the | ||
| 8650 | ;; beginning of the statement. | ||
| 8651 | (while (eq braceassignp 'dontknow) | 8650 | (while (eq braceassignp 'dontknow) |
| 8652 | (cond ((eq (char-after) ?\;) | 8651 | (setq braceassignp |
| 8653 | (setq braceassignp nil)) | 8652 | (cond ((/= (c-backward-token-2 1 t lim) 0) nil) |
| 8654 | ((and class-key | 8653 | ((looking-at c-opt-inexpr-brace-list-key) t) |
| 8655 | (looking-at class-key)) | 8654 | ((looking-at "\\sw\\|\\s_\\|[.[]") |
| 8656 | (setq braceassignp nil)) | 8655 | ;; Carry on looking if this is an |
| 8657 | ((eq (char-after) ?=) | 8656 | ;; identifier (may contain "." in Java) |
| 8658 | ;; We've seen a =, but must check earlier tokens so | 8657 | ;; or another "[]" sexp. |
| 8659 | ;; that it isn't something that should be ignored. | 8658 | 'dontknow) |
| 8660 | (setq braceassignp 'maybe) | 8659 | (t nil))))) |
| 8661 | (while (and (eq braceassignp 'maybe) | 8660 | ;; Checks to do on all sexps before the brace, up to the |
| 8662 | (zerop (c-backward-token-2 1 t lim))) | 8661 | ;; beginning of the statement. |
| 8663 | (setq braceassignp | 8662 | (while (eq braceassignp 'dontknow) |
| 8664 | (cond | 8663 | (cond ((eq (char-after) ?\;) |
| 8665 | ;; Check for operator = | 8664 | (setq braceassignp nil)) |
| 8666 | ((and c-opt-op-identifier-prefix | 8665 | ((and class-key |
| 8667 | (looking-at c-opt-op-identifier-prefix)) | 8666 | (looking-at class-key)) |
| 8668 | nil) | 8667 | (setq braceassignp nil)) |
| 8669 | ;; Check for `<opchar>= in Pike. | 8668 | ((eq (char-after) ?=) |
| 8670 | ((and (c-major-mode-is 'pike-mode) | 8669 | ;; We've seen a =, but must check earlier tokens so |
| 8671 | (or (eq (char-after) ?`) | 8670 | ;; that it isn't something that should be ignored. |
| 8672 | ;; Special case for Pikes | 8671 | (setq braceassignp 'maybe) |
| 8673 | ;; `[]=, since '[' is not in | 8672 | (while (and (eq braceassignp 'maybe) |
| 8674 | ;; the punctuation class. | 8673 | (zerop (c-backward-token-2 1 t lim))) |
| 8675 | (and (eq (char-after) ?\[) | 8674 | (setq braceassignp |
| 8676 | (eq (char-before) ?`)))) | 8675 | (cond |
| 8677 | nil) | 8676 | ;; Check for operator = |
| 8678 | ((looking-at "\\s.") 'maybe) | 8677 | ((and c-opt-op-identifier-prefix |
| 8679 | ;; make sure we're not in a C++ template | 8678 | (looking-at c-opt-op-identifier-prefix)) |
| 8680 | ;; argument assignment | 8679 | nil) |
| 8681 | ((and | 8680 | ;; Check for `<opchar>= in Pike. |
| 8682 | (c-major-mode-is 'c++-mode) | 8681 | ((and (c-major-mode-is 'pike-mode) |
| 8683 | (save-excursion | 8682 | (or (eq (char-after) ?`) |
| 8684 | (let ((here (point)) | 8683 | ;; Special case for Pikes |
| 8685 | (pos< (progn | 8684 | ;; `[]=, since '[' is not in |
| 8686 | (skip-chars-backward "^<>") | 8685 | ;; the punctuation class. |
| 8687 | (point)))) | 8686 | (and (eq (char-after) ?\[) |
| 8688 | (and (eq (char-before) ?<) | 8687 | (eq (char-before) ?`)))) |
| 8689 | (not (c-crosses-statement-barrier-p | 8688 | nil) |
| 8690 | pos< here)) | 8689 | ((looking-at "\\s.") 'maybe) |
| 8691 | (not (c-in-literal)) | 8690 | ;; make sure we're not in a C++ template |
| 8692 | )))) | 8691 | ;; argument assignment |
| 8693 | nil) | 8692 | ((and |
| 8694 | (t t)))))) | 8693 | (c-major-mode-is 'c++-mode) |
| 8694 | (save-excursion | ||
| 8695 | (let ((here (point)) | ||
| 8696 | (pos< (progn | ||
| 8697 | (skip-chars-backward "^<>") | ||
| 8698 | (point)))) | ||
| 8699 | (and (eq (char-before) ?<) | ||
| 8700 | (not (c-crosses-statement-barrier-p | ||
| 8701 | pos< here)) | ||
| 8702 | (not (c-in-literal)) | ||
| 8703 | )))) | ||
| 8704 | nil) | ||
| 8705 | (t t)))))) | ||
| 8695 | (if (and (eq braceassignp 'dontknow) | 8706 | (if (and (eq braceassignp 'dontknow) |
| 8696 | (/= (c-backward-token-2 1 t lim) 0)) | 8707 | (/= (c-backward-token-2 1 t lim) 0)) |
| 8697 | (setq braceassignp nil))) | 8708 | (setq braceassignp nil))) |
| @@ -9214,7 +9225,7 @@ comment at the start of cc-engine.el for more info." | |||
| 9214 | (max (c-point 'boi paren-pos) (point)))) | 9225 | (max (c-point 'boi paren-pos) (point)))) |
| 9215 | (t (c-add-syntax 'defun-block-intro nil)))) | 9226 | (t (c-add-syntax 'defun-block-intro nil)))) |
| 9216 | 9227 | ||
| 9217 | (c-add-syntax 'statement-block-intro nil))) | 9228 | (c-add-syntax 'statement-block-intro nil))) |
| 9218 | 9229 | ||
| 9219 | (if (= paren-pos boi) | 9230 | (if (= paren-pos boi) |
| 9220 | ;; Always done if the open brace was at boi. The | 9231 | ;; Always done if the open brace was at boi. The |
| @@ -10327,7 +10338,6 @@ comment at the start of cc-engine.el for more info." | |||
| 10327 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) | 10338 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) |
| 10328 | )) | 10339 | )) |
| 10329 | 10340 | ||
| 10330 | |||
| 10331 | ;; (CASE 6 has been removed.) | 10341 | ;; (CASE 6 has been removed.) |
| 10332 | 10342 | ||
| 10333 | ;; CASE 7: line is an expression, not a statement. Most | 10343 | ;; CASE 7: line is an expression, not a statement. Most |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index c056091ca46..1c389bc3665 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -366,39 +366,7 @@ | |||
| 366 | (parse-sexp-lookup-properties | 366 | (parse-sexp-lookup-properties |
| 367 | (cc-eval-when-compile | 367 | (cc-eval-when-compile |
| 368 | (boundp 'parse-sexp-lookup-properties)))) | 368 | (boundp 'parse-sexp-lookup-properties)))) |
| 369 | |||
| 370 | ;; (while (re-search-forward ,regexp limit t) | ||
| 371 | ;; (unless (progn | ||
| 372 | ;; (goto-char (match-beginning 0)) | ||
| 373 | ;; (c-skip-comments-and-strings limit)) | ||
| 374 | ;; (goto-char (match-end 0)) | ||
| 375 | ;; ,@(mapcar | ||
| 376 | ;; (lambda (highlight) | ||
| 377 | ;; (if (integerp (car highlight)) | ||
| 378 | ;; (progn | ||
| 379 | ;; (unless (eq (nth 2 highlight) t) | ||
| 380 | ;; (error | ||
| 381 | ;; "The override flag must currently be t in %s" | ||
| 382 | ;; highlight)) | ||
| 383 | ;; (when (nth 3 highlight) | ||
| 384 | ;; (error | ||
| 385 | ;; "The laxmatch flag may currently not be set in %s" | ||
| 386 | ;; highlight)) | ||
| 387 | ;; `(save-match-data | ||
| 388 | ;; (c-put-font-lock-face | ||
| 389 | ;; (match-beginning ,(car highlight)) | ||
| 390 | ;; (match-end ,(car highlight)) | ||
| 391 | ;; ,(elt highlight 1)))) | ||
| 392 | ;; (when (nth 3 highlight) | ||
| 393 | ;; (error "Match highlights currently not supported in %s" | ||
| 394 | ;; highlight)) | ||
| 395 | ;; `(progn | ||
| 396 | ;; ,(nth 1 highlight) | ||
| 397 | ;; (save-match-data ,(car highlight)) | ||
| 398 | ;; ,(nth 2 highlight)))) | ||
| 399 | ;; highlights))) | ||
| 400 | ,(c-make-font-lock-search-form regexp highlights)) | 369 | ,(c-make-font-lock-search-form regexp highlights)) |
| 401 | |||
| 402 | nil))) | 370 | nil))) |
| 403 | 371 | ||
| 404 | (defun c-make-font-lock-BO-decl-search-function (regexp &rest highlights) | 372 | (defun c-make-font-lock-BO-decl-search-function (regexp &rest highlights) |
| @@ -716,7 +684,11 @@ stuff. Used on level 1 and higher." | |||
| 716 | (let ((start (1- (point)))) | 684 | (let ((start (1- (point)))) |
| 717 | (save-excursion | 685 | (save-excursion |
| 718 | (and (eq (elt (parse-partial-sexp start (c-point 'eol)) 8) start) | 686 | (and (eq (elt (parse-partial-sexp start (c-point 'eol)) 8) start) |
| 719 | (if (integerp c-multiline-string-start-char) | 687 | (if (if (eval-when-compile (integerp ?c)) |
| 688 | ;; Emacs | ||
| 689 | (integerp c-multiline-string-start-char) | ||
| 690 | ;; XEmacs | ||
| 691 | (characterp c-multiline-string-start-char)) | ||
| 720 | ;; There's no multiline string start char before the | 692 | ;; There's no multiline string start char before the |
| 721 | ;; string, so newlines aren't allowed. | 693 | ;; string, so newlines aren't allowed. |
| 722 | (not (eq (char-before start) c-multiline-string-start-char)) | 694 | (not (eq (char-before start) c-multiline-string-start-char)) |
| @@ -1151,7 +1123,6 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1151 | (when list | 1123 | (when list |
| 1152 | ;; Jump past any initializer or function prototype to see if | 1124 | ;; Jump past any initializer or function prototype to see if |
| 1153 | ;; there's a ',' to continue at. | 1125 | ;; there's a ',' to continue at. |
| 1154 | |||
| 1155 | (cond ((eq id-face 'font-lock-function-name-face) | 1126 | (cond ((eq id-face 'font-lock-function-name-face) |
| 1156 | ;; Skip a parenthesized initializer (C++) or a function | 1127 | ;; Skip a parenthesized initializer (C++) or a function |
| 1157 | ;; prototype. | 1128 | ;; prototype. |
| @@ -1219,8 +1190,8 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1219 | ;; o - nil, if not in an arglist at all. This includes the | 1190 | ;; o - nil, if not in an arglist at all. This includes the |
| 1220 | ;; parenthesized condition which follows "if", "while", etc. | 1191 | ;; parenthesized condition which follows "if", "while", etc. |
| 1221 | context | 1192 | context |
| 1222 | ;; The position of the next token after the closing paren of | 1193 | ;; A list of starting positions of possible type declarations, or of |
| 1223 | ;; the last detected cast. | 1194 | ;; the typedef preceding one, if any. |
| 1224 | last-cast-end | 1195 | last-cast-end |
| 1225 | ;; The result from `c-forward-decl-or-cast-1'. | 1196 | ;; The result from `c-forward-decl-or-cast-1'. |
| 1226 | decl-or-cast | 1197 | decl-or-cast |
| @@ -1564,9 +1535,7 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1564 | ;; Note that this function won't attempt to fontify beyond the end of the | 1535 | ;; Note that this function won't attempt to fontify beyond the end of the |
| 1565 | ;; current enum block, if any. | 1536 | ;; current enum block, if any. |
| 1566 | (let* ((paren-state (c-parse-state)) | 1537 | (let* ((paren-state (c-parse-state)) |
| 1567 | (encl-pos (c-most-enclosing-brace paren-state)) | 1538 | (encl-pos (c-most-enclosing-brace paren-state))) |
| 1568 | (start (point)) | ||
| 1569 | ) | ||
| 1570 | (when (and | 1539 | (when (and |
| 1571 | encl-pos | 1540 | encl-pos |
| 1572 | (eq (char-after encl-pos) ?\{) | 1541 | (eq (char-after encl-pos) ?\{) |
diff --git a/lisp/progmodes/cc-guess.el b/lisp/progmodes/cc-guess.el index 5424e8d4a61..f46ae0ff426 100644 --- a/lisp/progmodes/cc-guess.el +++ b/lisp/progmodes/cc-guess.el | |||
| @@ -519,7 +519,8 @@ is called with one argument, the guessed style." | |||
| 519 | (goto-char (point-min)) | 519 | (goto-char (point-min)) |
| 520 | (when (search-forward (concat "(" | 520 | (when (search-forward (concat "(" |
| 521 | (symbol-name (car needs-markers)) | 521 | (symbol-name (car needs-markers)) |
| 522 | " ") nil t) | 522 | " ") |
| 523 | nil t) | ||
| 523 | (move-end-of-line 1) | 524 | (move-end-of-line 1) |
| 524 | (comment-dwim nil) | 525 | (comment-dwim nil) |
| 525 | (insert " Guessed value")) | 526 | (insert " Guessed value")) |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index bc3fb66d3e1..16f1dbfc6d6 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -130,9 +130,7 @@ | |||
| 130 | 130 | ||
| 131 | 131 | ||
| 132 | ;; This file is not always loaded. See note above. | 132 | ;; This file is not always loaded. See note above. |
| 133 | ;; Except it is always loaded - see bug#17463. | 133 | (cc-external-require 'cl) |
| 134 | ;;;(cc-external-require 'cl) | ||
| 135 | (require 'cl-lib) | ||
| 136 | 134 | ||
| 137 | 135 | ||
| 138 | ;;; Setup for the `c-lang-defvar' system. | 136 | ;;; Setup for the `c-lang-defvar' system. |
| @@ -253,14 +251,14 @@ the evaluated constant value at compile time." | |||
| 253 | (unless xlate | 251 | (unless xlate |
| 254 | (setq xlate 'identity)) | 252 | (setq xlate 'identity)) |
| 255 | (c-with-syntax-table (c-lang-const c-mode-syntax-table) | 253 | (c-with-syntax-table (c-lang-const c-mode-syntax-table) |
| 256 | (cl-delete-duplicates | 254 | (delete-duplicates |
| 257 | (cl-mapcan (lambda (opgroup) | 255 | (mapcan (lambda (opgroup) |
| 258 | (when (if (symbolp (car opgroup)) | 256 | (when (if (symbolp (car opgroup)) |
| 259 | (when (funcall opgroup-filter (car opgroup)) | 257 | (when (funcall opgroup-filter (car opgroup)) |
| 260 | (setq opgroup (cdr opgroup)) | 258 | (setq opgroup (cdr opgroup)) |
| 261 | t) | 259 | t) |
| 262 | t) | 260 | t) |
| 263 | (cl-mapcan (lambda (op) | 261 | (mapcan (lambda (op) |
| 264 | (when (funcall op-filter op) | 262 | (when (funcall op-filter op) |
| 265 | (let ((res (funcall xlate op))) | 263 | (let ((res (funcall xlate op))) |
| 266 | (if (listp res) res (list res))))) | 264 | (if (listp res) res (list res))))) |
| @@ -301,7 +299,8 @@ the evaluated constant value at compile time." | |||
| 301 | ["Set Style..." c-set-style t] | 299 | ["Set Style..." c-set-style t] |
| 302 | ["Show Current Style Name" (message | 300 | ["Show Current Style Name" (message |
| 303 | "Style Name: %s" | 301 | "Style Name: %s" |
| 304 | c-indentation-style) t] | 302 | c-indentation-style) |
| 303 | t] | ||
| 305 | ["Guess Style from this Buffer" c-guess-buffer-no-install t] | 304 | ["Guess Style from this Buffer" c-guess-buffer-no-install t] |
| 306 | ["Install the Last Guessed Style..." c-guess-install | 305 | ["Install the Last Guessed Style..." c-guess-install |
| 307 | (and c-guess-guessed-offsets-alist | 306 | (and c-guess-guessed-offsets-alist |
| @@ -1155,7 +1154,7 @@ operators." | |||
| 1155 | (c-lang-defconst c-all-op-syntax-tokens | 1154 | (c-lang-defconst c-all-op-syntax-tokens |
| 1156 | ;; List of all tokens in the punctuation and parenthesis syntax | 1155 | ;; List of all tokens in the punctuation and parenthesis syntax |
| 1157 | ;; classes. | 1156 | ;; classes. |
| 1158 | t (cl-delete-duplicates (append (c-lang-const c-other-op-syntax-tokens) | 1157 | t (delete-duplicates (append (c-lang-const c-other-op-syntax-tokens) |
| 1159 | (c-lang-const c-operator-list)) | 1158 | (c-lang-const c-operator-list)) |
| 1160 | :test 'string-equal)) | 1159 | :test 'string-equal)) |
| 1161 | 1160 | ||
| @@ -1587,13 +1586,14 @@ properly." | |||
| 1587 | (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol)) | 1586 | (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol)) |
| 1588 | 1587 | ||
| 1589 | 1588 | ||
| 1590 | ;;; Defun functions | 1589 | ;;; Defun handling. |
| 1591 | 1590 | ||
| 1592 | ;; The Emacs variables beginning-of-defun-function and | 1591 | ;; The Emacs variables beginning-of-defun-function and end-of-defun-function |
| 1593 | ;; end-of-defun-function will be set so that commands like | 1592 | ;; will be set so that commands like `mark-defun' and `narrow-to-defun' work |
| 1594 | ;; `mark-defun' and `narrow-to-defun' work right. The key sequences | 1593 | ;; right. In older Emacsen, the key sequences C-M-a and C-M-e are, however, |
| 1595 | ;; C-M-a and C-M-e are, however, bound directly to the CC Mode | 1594 | ;; bound directly to the CC Mode functions, allowing optimisation for large n. |
| 1596 | ;; functions, allowing optimization for large n. | 1595 | ;; From Emacs 23, this isn't necessary any more, since n is passed to the two |
| 1596 | ;; functions. | ||
| 1597 | (c-lang-defconst beginning-of-defun-function | 1597 | (c-lang-defconst beginning-of-defun-function |
| 1598 | "Function to which beginning-of-defun-function will be set." | 1598 | "Function to which beginning-of-defun-function will be set." |
| 1599 | t 'c-beginning-of-defun | 1599 | t 'c-beginning-of-defun |
| @@ -1754,7 +1754,7 @@ not the type face." | |||
| 1754 | (c-lang-defconst c-type-start-kwds | 1754 | (c-lang-defconst c-type-start-kwds |
| 1755 | ;; All keywords that can start a type (i.e. are either a type prefix | 1755 | ;; All keywords that can start a type (i.e. are either a type prefix |
| 1756 | ;; or a complete type). | 1756 | ;; or a complete type). |
| 1757 | t (cl-delete-duplicates (append (c-lang-const c-primitive-type-kwds) | 1757 | t (delete-duplicates (append (c-lang-const c-primitive-type-kwds) |
| 1758 | (c-lang-const c-type-prefix-kwds) | 1758 | (c-lang-const c-type-prefix-kwds) |
| 1759 | (c-lang-const c-type-modifier-kwds)) | 1759 | (c-lang-const c-type-modifier-kwds)) |
| 1760 | :test 'string-equal)) | 1760 | :test 'string-equal)) |
| @@ -1998,7 +1998,7 @@ one of `c-type-list-kwds', `c-ref-list-kwds', | |||
| 1998 | ;; something is a type or just some sort of macro in front of the | 1998 | ;; something is a type or just some sort of macro in front of the |
| 1999 | ;; declaration. They might be ambiguous with types or type | 1999 | ;; declaration. They might be ambiguous with types or type |
| 2000 | ;; prefixes. | 2000 | ;; prefixes. |
| 2001 | t (cl-delete-duplicates (append (c-lang-const c-class-decl-kwds) | 2001 | t (delete-duplicates (append (c-lang-const c-class-decl-kwds) |
| 2002 | (c-lang-const c-brace-list-decl-kwds) | 2002 | (c-lang-const c-brace-list-decl-kwds) |
| 2003 | (c-lang-const c-other-block-decl-kwds) | 2003 | (c-lang-const c-other-block-decl-kwds) |
| 2004 | (c-lang-const c-typedef-decl-kwds) | 2004 | (c-lang-const c-typedef-decl-kwds) |
| @@ -2192,7 +2192,7 @@ type identifiers separated by arbitrary tokens." | |||
| 2192 | pike '("array" "function" "int" "mapping" "multiset" "object" "program")) | 2192 | pike '("array" "function" "int" "mapping" "multiset" "object" "program")) |
| 2193 | 2193 | ||
| 2194 | (c-lang-defconst c-paren-any-kwds | 2194 | (c-lang-defconst c-paren-any-kwds |
| 2195 | t (cl-delete-duplicates (append (c-lang-const c-paren-nontype-kwds) | 2195 | t (delete-duplicates (append (c-lang-const c-paren-nontype-kwds) |
| 2196 | (c-lang-const c-paren-type-kwds)) | 2196 | (c-lang-const c-paren-type-kwds)) |
| 2197 | :test 'string-equal)) | 2197 | :test 'string-equal)) |
| 2198 | 2198 | ||
| @@ -2218,7 +2218,7 @@ assumed to be set if this isn't nil." | |||
| 2218 | 2218 | ||
| 2219 | (c-lang-defconst c-<>-sexp-kwds | 2219 | (c-lang-defconst c-<>-sexp-kwds |
| 2220 | ;; All keywords that can be followed by an angle bracket sexp. | 2220 | ;; All keywords that can be followed by an angle bracket sexp. |
| 2221 | t (cl-delete-duplicates (append (c-lang-const c-<>-type-kwds) | 2221 | t (delete-duplicates (append (c-lang-const c-<>-type-kwds) |
| 2222 | (c-lang-const c-<>-arglist-kwds)) | 2222 | (c-lang-const c-<>-arglist-kwds)) |
| 2223 | :test 'string-equal)) | 2223 | :test 'string-equal)) |
| 2224 | 2224 | ||
| @@ -2278,7 +2278,7 @@ Keywords here should also be in `c-block-stmt-1-kwds'." | |||
| 2278 | 2278 | ||
| 2279 | (c-lang-defconst c-block-stmt-kwds | 2279 | (c-lang-defconst c-block-stmt-kwds |
| 2280 | ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'. | 2280 | ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'. |
| 2281 | t (cl-delete-duplicates (append (c-lang-const c-block-stmt-1-kwds) | 2281 | t (delete-duplicates (append (c-lang-const c-block-stmt-1-kwds) |
| 2282 | (c-lang-const c-block-stmt-2-kwds)) | 2282 | (c-lang-const c-block-stmt-2-kwds)) |
| 2283 | :test 'string-equal)) | 2283 | :test 'string-equal)) |
| 2284 | 2284 | ||
| @@ -2382,7 +2382,7 @@ This construct is \"<keyword> <expression> :\"." | |||
| 2382 | (c-lang-defconst c-expr-kwds | 2382 | (c-lang-defconst c-expr-kwds |
| 2383 | ;; Keywords that can occur anywhere in expressions. Built from | 2383 | ;; Keywords that can occur anywhere in expressions. Built from |
| 2384 | ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'. | 2384 | ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'. |
| 2385 | t (cl-delete-duplicates | 2385 | t (delete-duplicates |
| 2386 | (append (c-lang-const c-primary-expr-kwds) | 2386 | (append (c-lang-const c-primary-expr-kwds) |
| 2387 | (c-filter-ops (c-lang-const c-operator-list) | 2387 | (c-filter-ops (c-lang-const c-operator-list) |
| 2388 | t | 2388 | t |
| @@ -2486,7 +2486,7 @@ Note that Java specific rules are currently applied to tell this from | |||
| 2486 | 2486 | ||
| 2487 | (c-lang-defconst c-keywords | 2487 | (c-lang-defconst c-keywords |
| 2488 | ;; All keywords as a list. | 2488 | ;; All keywords as a list. |
| 2489 | t (cl-delete-duplicates | 2489 | t (delete-duplicates |
| 2490 | (c-lang-defconst-eval-immediately | 2490 | (c-lang-defconst-eval-immediately |
| 2491 | `(append ,@(mapcar (lambda (kwds-lang-const) | 2491 | `(append ,@(mapcar (lambda (kwds-lang-const) |
| 2492 | `(c-lang-const ,kwds-lang-const)) | 2492 | `(c-lang-const ,kwds-lang-const)) |
| @@ -2826,7 +2826,7 @@ possible for good performance." | |||
| 2826 | (c-lang-defvar c-block-prefix-charset (c-lang-const c-block-prefix-charset)) | 2826 | (c-lang-defvar c-block-prefix-charset (c-lang-const c-block-prefix-charset)) |
| 2827 | 2827 | ||
| 2828 | (c-lang-defconst c-type-decl-prefix-key | 2828 | (c-lang-defconst c-type-decl-prefix-key |
| 2829 | "Regexp matching the declarator operators that might precede the | 2829 | "Regexp matching any declarator operator that might precede the |
| 2830 | identifier in a declaration, e.g. the \"*\" in \"char *argv\". This | 2830 | identifier in a declaration, e.g. the \"*\" in \"char *argv\". This |
| 2831 | regexp should match \"(\" if parentheses are valid in declarators. | 2831 | regexp should match \"(\" if parentheses are valid in declarators. |
| 2832 | The end of the first submatch is taken as the end of the operator. | 2832 | The end of the first submatch is taken as the end of the operator. |
| @@ -3025,7 +3025,8 @@ identifier or one of the keywords on `c-<>-type-kwds' or | |||
| 3025 | expression is considered to be a type." | 3025 | expression is considered to be a type." |
| 3026 | t (or (consp (c-lang-const c-<>-type-kwds)) | 3026 | t (or (consp (c-lang-const c-<>-type-kwds)) |
| 3027 | (consp (c-lang-const c-<>-arglist-kwds))) | 3027 | (consp (c-lang-const c-<>-arglist-kwds))) |
| 3028 | java t) | 3028 | java t) ; 2008-10-19. This is crude. The syntax for java |
| 3029 | ; generics is not yet coded in CC Mode. | ||
| 3029 | (c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists)) | 3030 | (c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists)) |
| 3030 | 3031 | ||
| 3031 | (c-lang-defconst c-enums-contain-decls | 3032 | (c-lang-defconst c-enums-contain-decls |
| @@ -3249,7 +3250,7 @@ accomplish that conveniently." | |||
| 3249 | ;; `c-lang-const' will expand to the evaluated | 3250 | ;; `c-lang-const' will expand to the evaluated |
| 3250 | ;; constant immediately in `macroexpand-all' | 3251 | ;; constant immediately in `macroexpand-all' |
| 3251 | ;; below. | 3252 | ;; below. |
| 3252 | (cl-mapcan | 3253 | (mapcan |
| 3253 | (lambda (init) | 3254 | (lambda (init) |
| 3254 | `(current-var ',(car init) | 3255 | `(current-var ',(car init) |
| 3255 | ,(car init) ,(macroexpand-all | 3256 | ,(car init) ,(macroexpand-all |
diff --git a/lisp/progmodes/cc-menus.el b/lisp/progmodes/cc-menus.el index 67425a0c82c..735c2cbf1ed 100644 --- a/lisp/progmodes/cc-menus.el +++ b/lisp/progmodes/cc-menus.el | |||
| @@ -361,7 +361,7 @@ Example: | |||
| 361 | p (1+ p)) | 361 | p (1+ p)) |
| 362 | (cond | 362 | (cond |
| 363 | ;; Is CHAR part of a objc token? | 363 | ;; Is CHAR part of a objc token? |
| 364 | ((and (not inargvar) ; Ignore if CHAR is part of an argument variable. | 364 | ((and (not inargvar) ; Ignore if CHAR is part of an argument variable. |
| 365 | (eq 0 betweenparen) ; Ignore if CHAR is in parentheses. | 365 | (eq 0 betweenparen) ; Ignore if CHAR is in parentheses. |
| 366 | (or (and (<= ?a char) (<= char ?z)) | 366 | (or (and (<= ?a char) (<= char ?z)) |
| 367 | (and (<= ?A char) (<= char ?Z)) | 367 | (and (<= ?A char) (<= char ?Z)) |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 1ce076734ff..cb138d5f8b6 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -185,8 +185,7 @@ control). See \"cc-mode.el\" for more info." | |||
| 185 | (run-hooks 'c-initialization-hook) | 185 | (run-hooks 'c-initialization-hook) |
| 186 | ;; Fix obsolete variables. | 186 | ;; Fix obsolete variables. |
| 187 | (if (boundp 'c-comment-continuation-stars) | 187 | (if (boundp 'c-comment-continuation-stars) |
| 188 | (setq c-block-comment-prefix | 188 | (setq c-block-comment-prefix c-comment-continuation-stars)) |
| 189 | (symbol-value 'c-comment-continuation-stars))) | ||
| 190 | (add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode) | 189 | (add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode) |
| 191 | (setq c-initialization-ok t) | 190 | (setq c-initialization-ok t) |
| 192 | ;; Connect up with Emacs's electric-indent-mode, for >= Emacs 24.4 | 191 | ;; Connect up with Emacs's electric-indent-mode, for >= Emacs 24.4 |
| @@ -1322,6 +1321,7 @@ This function is called from `c-common-init', once per mode initialization." | |||
| 1322 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.i\\'" . c-mode)) | 1321 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.i\\'" . c-mode)) |
| 1323 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.ii\\'" . c++-mode)) | 1322 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.ii\\'" . c++-mode)) |
| 1324 | 1323 | ||
| 1324 | (unless (fboundp 'prog-mode) (defalias 'prog-mode 'fundamental-mode)) | ||
| 1325 | 1325 | ||
| 1326 | ;;;###autoload | 1326 | ;;;###autoload |
| 1327 | (define-derived-mode c-mode prog-mode "C" | 1327 | (define-derived-mode c-mode prog-mode "C" |
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index a8d627f94d4..ac8dbfc4c45 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el | |||
| @@ -275,13 +275,18 @@ nil." | |||
| 275 | "*Controls the operation of the TAB key. | 275 | "*Controls the operation of the TAB key. |
| 276 | If t, hitting TAB always just indents the current line. If nil, hitting | 276 | If t, hitting TAB always just indents the current line. If nil, hitting |
| 277 | TAB indents the current line if point is at the left margin or in the | 277 | TAB indents the current line if point is at the left margin or in the |
| 278 | line's indentation, otherwise it calls `c-insert-tab-function' to | 278 | line's indentation, otherwise it inserts a `real' tab character \(see |
| 279 | insert a `real' tab character. If some other value (neither nil nor t), | 279 | note\). If some other value (not nil or t), then tab is inserted only |
| 280 | then inserts a tab only within literals (comments and strings), but | 280 | within literals \(comments and strings), but the line is always |
| 281 | always reindents the line. | 281 | reindented. |
| 282 | 282 | ||
| 283 | Note: the variable `c-comment-only-line-offset' also controls the | 283 | Note: The value of `indent-tabs-mode' will determine whether a real |
| 284 | indentation of lines containing only comments." | 284 | tab character will be inserted, or the equivalent number of spaces. |
| 285 | When inserting a tab, actually the function stored in the variable | ||
| 286 | `c-insert-tab-function' is called. | ||
| 287 | |||
| 288 | Note: indentation of lines containing only comments is also controlled | ||
| 289 | by the `c-comment-only-line-offset' variable." | ||
| 285 | :type '(radio | 290 | :type '(radio |
| 286 | (const :tag "TAB key always indents, never inserts TAB" t) | 291 | (const :tag "TAB key always indents, never inserts TAB" t) |
| 287 | (const :tag "TAB key indents in left margin, otherwise inserts TAB" nil) | 292 | (const :tag "TAB key indents in left margin, otherwise inserts TAB" nil) |
| @@ -920,7 +925,7 @@ Only currently supported behavior is `alignleft'." | |||
| 920 | (defcustom c-special-indent-hook nil | 925 | (defcustom c-special-indent-hook nil |
| 921 | "*Hook for user defined special indentation adjustments. | 926 | "*Hook for user defined special indentation adjustments. |
| 922 | This hook gets called after each line is indented by the mode. It is only | 927 | This hook gets called after each line is indented by the mode. It is only |
| 923 | called if `c-syntactic-indentation' is non-nil." | 928 | called when `c-syntactic-indentation' is non-nil." |
| 924 | :type 'hook | 929 | :type 'hook |
| 925 | :group 'c) | 930 | :group 'c) |
| 926 | 931 | ||
| @@ -1689,7 +1694,8 @@ as designated in the variable `c-file-style'.") | |||
| 1689 | ;; It isn't possible to specify a doc-string without specifying an | 1694 | ;; It isn't possible to specify a doc-string without specifying an |
| 1690 | ;; initial value with `defvar', so the following two variables have been | 1695 | ;; initial value with `defvar', so the following two variables have been |
| 1691 | ;; given doc-strings by setting the property `variable-documentation' | 1696 | ;; given doc-strings by setting the property `variable-documentation' |
| 1692 | ;; directly. It's really good not to have an initial value for | 1697 | ;; directly. C-h v will read this documentation only for versions of GNU |
| 1698 | ;; Emacs from 22.1. It's really good not to have an initial value for | ||
| 1693 | ;; variables like these that always should be dynamically bound, so it's | 1699 | ;; variables like these that always should be dynamically bound, so it's |
| 1694 | ;; worth the inconvenience. | 1700 | ;; worth the inconvenience. |
| 1695 | 1701 | ||