diff options
| author | Alan Mackenzie | 2014-09-10 21:38:11 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2014-09-10 21:38:11 +0000 |
| commit | c8b22035d67421b02c69a20d0809b732ab4c7f01 (patch) | |
| tree | 06d52dd69befc22beb64bdd653c8a94561b7be97 | |
| parent | d1bed1f79107c8377ffaea160acd815008fab4f7 (diff) | |
| download | emacs-c8b22035d67421b02c69a20d0809b732ab4c7f01.tar.gz emacs-c8b22035d67421b02c69a20d0809b732ab4c7f01.zip | |
CC Mode: revert recent changes and fix bug 17463 (cc-langs.elc gets
loaded at run-time).
* progmodes/cc-langs.el (c-no-parens-syntax-table): Rename the
c-lang-const to c-make-no-parens-syntax-table and correct the
logic.
(c-no-parens-syntax-table): Correct the logic of the c-lang-defvar.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/progmodes/cc-awk.el | 671 | ||||
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 260 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 10 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 298 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 224 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 20 |
7 files changed, 813 insertions, 680 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 998fa13bbba..82487d66a16 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2014-09-10 Alan Mackenzie <acm@muc.de> | ||
| 2 | |||
| 3 | CC Mode: revert recent changes and fix bug 17463 (cc-langs.elc | ||
| 4 | gets loaded at run-time). | ||
| 5 | * progmodes/cc-langs.el (c-no-parens-syntax-table): Rename the | ||
| 6 | c-lang-const to c-make-no-parens-syntax-table and correct the | ||
| 7 | logic. | ||
| 8 | (c-no-parens-syntax-table): Correct the logic of the | ||
| 9 | c-lang-defvar. | ||
| 10 | |||
| 1 | 2014-09-10 Stefan Monnier <monnier@iro.umontreal.ca> | 11 | 2014-09-10 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 12 | ||
| 3 | CC-mode: Set open-paren-in-column-0-is-defun-start to nil; | 13 | CC-mode: Set open-paren-in-column-0-is-defun-start to nil; |
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el index fbc0b6de420..44d69d7d0f1 100644 --- a/lisp/progmodes/cc-awk.el +++ b/lisp/progmodes/cc-awk.el | |||
| @@ -40,8 +40,28 @@ | |||
| 40 | 40 | ||
| 41 | ;;; Code: | 41 | ;;; Code: |
| 42 | 42 | ||
| 43 | (require 'cc-defs) | 43 | (eval-when-compile |
| 44 | (require 'cc-engine) | 44 | (let ((load-path |
| 45 | (if (and (boundp 'byte-compile-dest-file) | ||
| 46 | (stringp byte-compile-dest-file)) | ||
| 47 | (cons (file-name-directory byte-compile-dest-file) load-path) | ||
| 48 | load-path))) | ||
| 49 | (load "cc-bytecomp" nil t))) | ||
| 50 | |||
| 51 | (cc-require 'cc-defs) | ||
| 52 | |||
| 53 | ;; Silence the byte compiler. | ||
| 54 | (cc-bytecomp-defvar font-lock-mode) ; Checked with boundp before use. | ||
| 55 | (cc-bytecomp-defvar c-new-BEG) | ||
| 56 | (cc-bytecomp-defvar c-new-END) | ||
| 57 | |||
| 58 | ;; Some functions in cc-engine that are used below. There's a cyclic | ||
| 59 | ;; dependency so it can't be required here. (Perhaps some functions | ||
| 60 | ;; could be moved to cc-engine to avoid it.) | ||
| 61 | (cc-bytecomp-defun c-backward-token-1) | ||
| 62 | (cc-bytecomp-defun c-beginning-of-statement-1) | ||
| 63 | (cc-bytecomp-defun c-backward-sws) | ||
| 64 | (cc-bytecomp-defun c-forward-sws) | ||
| 45 | 65 | ||
| 46 | (defvar awk-mode-syntax-table | 66 | (defvar awk-mode-syntax-table |
| 47 | (let ((st (make-syntax-table))) | 67 | (let ((st (make-syntax-table))) |
| @@ -75,111 +95,111 @@ | |||
| 75 | ;; Emacs has in the past used \r to mark hidden lines in some fashion (and | 95 | ;; Emacs has in the past used \r to mark hidden lines in some fashion (and |
| 76 | ;; maybe still does). | 96 | ;; maybe still does). |
| 77 | 97 | ||
| 78 | (defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)" | 98 | (defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)") |
| 79 | "Matches any escaped (with \) character-pair, including an escaped newline.") | 99 | ;; Matches any escaped (with \) character-pair, including an escaped newline. |
| 80 | (defconst c-awk-non-eol-esc-pair-re "\\\\\\(.\\|\\'\\)" | 100 | (defconst c-awk-non-eol-esc-pair-re "\\\\\\(.\\|\\'\\)") |
| 81 | "Matches any escaped (with \) character-pair, apart from an escaped newline.") | 101 | ;; Matches any escaped (with \) character-pair, apart from an escaped newline. |
| 82 | (defconst c-awk-comment-without-nl "#.*" | 102 | (defconst c-awk-comment-without-nl "#.*") |
| 83 | "Matches an AWK comment, not including the terminating NL (if any). | 103 | ;; Matches an AWK comment, not including the terminating NL (if any). Note |
| 84 | Note that the \"enclosing\" (elisp) regexp must ensure the # is real.") | 104 | ;; that the "enclosing" (elisp) regexp must ensure the # is real. |
| 85 | (defconst c-awk-nl-or-eob "\\(\n\\|\r\\|\\'\\)" | 105 | (defconst c-awk-nl-or-eob "\\(\n\\|\r\\|\\'\\)") |
| 86 | "Matches a newline, or the end of buffer.") | 106 | ;; Matches a newline, or the end of buffer. |
| 87 | 107 | ||
| 88 | ;; "Space" regular expressions. | 108 | ;; "Space" regular expressions. |
| 89 | (eval-and-compile | 109 | (eval-and-compile |
| 90 | (defconst c-awk-escaped-nl "\\\\[\n\r]" | 110 | (defconst c-awk-escaped-nl "\\\\[\n\r]")) |
| 91 | "Matches an escaped newline.")) | 111 | ;; Matches an escaped newline. |
| 92 | (eval-and-compile | 112 | (eval-and-compile |
| 93 | (defconst c-awk-escaped-nls* (concat "\\(" c-awk-escaped-nl "\\)*") | 113 | (defconst c-awk-escaped-nls* (concat "\\(" c-awk-escaped-nl "\\)*"))) |
| 94 | "Matches a possibly empty sequence of escaped newlines. | 114 | ;; Matches a possibly empty sequence of escaped newlines. Used in |
| 95 | Used in `awk-font-lock-keywords'.")) | 115 | ;; awk-font-lock-keywords. |
| 96 | ;; (defconst c-awk-escaped-nls*-with-space* | 116 | ;; (defconst c-awk-escaped-nls*-with-space* |
| 97 | ;; (concat "\\(" c-awk-escaped-nls* "\\|" "[ \t]+" "\\)*")) | 117 | ;; (concat "\\(" c-awk-escaped-nls* "\\|" "[ \t]+" "\\)*")) |
| 98 | ;; The above RE was very slow. It's runtime was doubling with each additional | 118 | ;; The above RE was very slow. It's runtime was doubling with each additional |
| 99 | ;; space :-( Reformulate it as below: | 119 | ;; space :-( Reformulate it as below: |
| 100 | (eval-and-compile | 120 | (eval-and-compile |
| 101 | (defconst c-awk-escaped-nls*-with-space* | 121 | (defconst c-awk-escaped-nls*-with-space* |
| 102 | (concat "\\(" c-awk-escaped-nl "\\|" "[ \t]" "\\)*") | 122 | (concat "\\(" c-awk-escaped-nl "\\|" "[ \t]" "\\)*"))) |
| 103 | "Matches a possibly empty sequence of escaped newlines with optional | 123 | ;; Matches a possibly empty sequence of escaped newlines with optional |
| 104 | interspersed spaces and tabs. Used in `awk-font-lock-keywords'.")) | 124 | ;; interspersed spaces and tabs. Used in awk-font-lock-keywords. |
| 105 | (defconst c-awk-blank-or-comment-line-re | 125 | (defconst c-awk-blank-or-comment-line-re |
| 106 | (concat "[ \t]*\\(#\\|\\\\?$\\)") | 126 | (concat "[ \t]*\\(#\\|\\\\?$\\)")) |
| 107 | "Match (the tail of) a line containing at most either a comment or an | 127 | ;; Matche (the tail of) a line containing at most either a comment or an |
| 108 | escaped EOL.") | 128 | ;; escaped EOL. |
| 109 | 129 | ||
| 110 | ;; REGEXPS FOR "HARMLESS" STRINGS/LINES. | 130 | ;; REGEXPS FOR "HARMLESS" STRINGS/LINES. |
| 111 | (defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)" | 131 | (defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)") |
| 112 | "Matches an underline NOT followed by \".") | 132 | ;; Matches an underline NOT followed by ". |
| 113 | (defconst c-awk-harmless-char-re "[^_#/\"{}();\\\\\n\r]" | 133 | (defconst c-awk-harmless-char-re "[^_#/\"{}();\\\\\n\r]") |
| 114 | "Matches any character not significant in the state machine applying | 134 | ;; Matches any character not significant in the state machine applying |
| 115 | syntax-table properties to \"s and /s.") | 135 | ;; syntax-table properties to "s and /s. |
| 116 | (defconst c-awk-harmless-string*-re | 136 | (defconst c-awk-harmless-string*-re |
| 117 | (concat "\\(" c-awk-harmless-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*") | 137 | (concat "\\(" c-awk-harmless-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*")) |
| 118 | "Matches a (possibly empty) sequence of characters insignificant in the | 138 | ;; Matches a (possibly empty) sequence of characters insignificant in the |
| 119 | state machine applying syntax-table properties to \"s and /s.") | 139 | ;; state machine applying syntax-table properties to "s and /s. |
| 120 | (defconst c-awk-harmless-string*-here-re | 140 | (defconst c-awk-harmless-string*-here-re |
| 121 | (concat "\\=" c-awk-harmless-string*-re) | 141 | (concat "\\=" c-awk-harmless-string*-re)) |
| 122 | "Matches the (possibly empty) sequence of \"insignificant\" chars at point.") | 142 | ;; Matches the (possibly empty) sequence of "insignificant" chars at point. |
| 123 | 143 | ||
| 124 | (defconst c-awk-harmless-line-char-re "[^_#/\"\\\\\n\r]" | 144 | (defconst c-awk-harmless-line-char-re "[^_#/\"\\\\\n\r]") |
| 125 | "Matches any character but a _, #, /, \", \\, or newline. N.B. _\" starts a | 145 | ;; Matches any character but a _, #, /, ", \, or newline. N.B. _" starts a |
| 126 | localization string in gawk 3.1.") | 146 | ;; localization string in gawk 3.1 |
| 127 | (defconst c-awk-harmless-line-string*-re | 147 | (defconst c-awk-harmless-line-string*-re |
| 128 | (concat "\\(" c-awk-harmless-line-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*") | 148 | (concat "\\(" c-awk-harmless-line-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*")) |
| 129 | "Matches a (possibly empty) sequence of chars without unescaped /, \", \\, | 149 | ;; Matches a (possibly empty) sequence of chars without unescaped /, ", \, |
| 130 | #, or newlines.") | 150 | ;; #, or newlines. |
| 131 | (defconst c-awk-harmless-line-re | 151 | (defconst c-awk-harmless-line-re |
| 132 | (concat c-awk-harmless-line-string*-re | 152 | (concat c-awk-harmless-line-string*-re |
| 133 | "\\(" c-awk-comment-without-nl "\\)?" c-awk-nl-or-eob) | 153 | "\\(" c-awk-comment-without-nl "\\)?" c-awk-nl-or-eob)) |
| 134 | "Matches (the tail of) an AWK \"logical\" line not containing an unescaped | 154 | ;; Matches (the tail of) an AWK \"logical\" line not containing an unescaped |
| 135 | \" or /. \"logical\" means \"possibly containing escaped newlines\". A comment | 155 | ;; " or /. "logical" means "possibly containing escaped newlines". A comment |
| 136 | is matched as part of the line even if it contains a \" or a /. The End of | 156 | ;; is matched as part of the line even if it contains a " or a /. The End of |
| 137 | buffer is also an end of line.") | 157 | ;; buffer is also an end of line. |
| 138 | (defconst c-awk-harmless-lines+-here-re | 158 | (defconst c-awk-harmless-lines+-here-re |
| 139 | (concat "\\=\\(" c-awk-harmless-line-re "\\)+") | 159 | (concat "\\=\\(" c-awk-harmless-line-re "\\)+")) |
| 140 | "Matches a sequence of (at least one) \"harmless-line\" at point.") | 160 | ;; Matches a sequence of (at least one) \"harmless-line\" at point. |
| 141 | 161 | ||
| 142 | 162 | ||
| 143 | ;; REGEXPS FOR AWK STRINGS. | 163 | ;; REGEXPS FOR AWK STRINGS. |
| 144 | (defconst c-awk-string-ch-re "[^\"\\\n\r]" | 164 | (defconst c-awk-string-ch-re "[^\"\\\n\r]") |
| 145 | "Matches any character which can appear unescaped in a string.") | 165 | ;; Matches any character which can appear unescaped in a string. |
| 146 | (defconst c-awk-string-innards-re | 166 | (defconst c-awk-string-innards-re |
| 147 | (concat "\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*") | 167 | (concat "\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*")) |
| 148 | "Matches the inside of an AWK string (i.e. without the enclosing quotes).") | 168 | ;; Matches the inside of an AWK string (i.e. without the enclosing quotes). |
| 149 | (defconst c-awk-string-without-end-here-re | 169 | (defconst c-awk-string-without-end-here-re |
| 150 | (concat "\\=_?\"" c-awk-string-innards-re) | 170 | (concat "\\=_?\"" c-awk-string-innards-re)) |
| 151 | "Matches an AWK string at point up to, but not including, any terminator. | 171 | ;; Matches an AWK string at point up to, but not including, any terminator. |
| 152 | A gawk 3.1+ string may look like _\"localizable string\".") | 172 | ;; A gawk 3.1+ string may look like _"localizable string". |
| 153 | (defconst c-awk-possibly-open-string-re | 173 | (defconst c-awk-possibly-open-string-re |
| 154 | (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*" | 174 | (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*" |
| 155 | "\\(\"\\|$\\|\\'\\)")) | 175 | "\\(\"\\|$\\|\\'\\)")) |
| 156 | 176 | ||
| 157 | ;; REGEXPS FOR AWK REGEXPS. | 177 | ;; REGEXPS FOR AWK REGEXPS. |
| 158 | (defconst c-awk-regexp-normal-re "[^[/\\\n\r]" | 178 | (defconst c-awk-regexp-normal-re "[^[/\\\n\r]") |
| 159 | "Matches any AWK regexp character which doesn't require special analysis.") | 179 | ;; Matches any AWK regexp character which doesn't require special analysis. |
| 160 | (defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*" | 180 | (defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*") |
| 161 | "Matches a (possibly empty) sequence of escaped newlines.") | 181 | ;; Matches a (possibly empty) sequence of escaped newlines. |
| 162 | 182 | ||
| 163 | ;; NOTE: In what follows, "[asdf]" in a regexp will be called a "character | 183 | ;; NOTE: In what follows, "[asdf]" in a regexp will be called a "character |
| 164 | ;; list", and "[:alpha:]" inside a character list will be known as a | 184 | ;; list", and "[:alpha:]" inside a character list will be known as a |
| 165 | ;; "character class". These terms for these things vary between regexp | 185 | ;; "character class". These terms for these things vary between regexp |
| 166 | ;; descriptions . | 186 | ;; descriptions . |
| 167 | (defconst c-awk-regexp-char-class-re | 187 | (defconst c-awk-regexp-char-class-re |
| 168 | "\\[:[a-z]+:\\]" | 188 | "\\[:[a-z]+:\\]") |
| 169 | "Matches a character class spec (e.g. [:alpha:]).") | 189 | ;; Matches a character class spec (e.g. [:alpha:]). |
| 170 | (defconst c-awk-regexp-char-list-re | 190 | (defconst c-awk-regexp-char-list-re |
| 171 | (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?" | 191 | (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?" |
| 172 | "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re | 192 | "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re |
| 173 | "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)") | 193 | "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)")) |
| 174 | "Matches a regexp char list, up to (but not including) EOL if the ] is | 194 | ;; Matches a regexp char list, up to (but not including) EOL if the ] is |
| 175 | missing.") | 195 | ;; missing. |
| 176 | (defconst c-awk-regexp-innards-re | 196 | (defconst c-awk-regexp-innards-re |
| 177 | (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re | 197 | (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re |
| 178 | "\\|" c-awk-regexp-normal-re "\\)*") | 198 | "\\|" c-awk-regexp-normal-re "\\)*")) |
| 179 | "Matches the inside of an AWK regexp (i.e. without the enclosing /s)") | 199 | ;; Matches the inside of an AWK regexp (i.e. without the enclosing /s) |
| 180 | (defconst c-awk-regexp-without-end-re | 200 | (defconst c-awk-regexp-without-end-re |
| 181 | (concat "/" c-awk-regexp-innards-re) | 201 | (concat "/" c-awk-regexp-innards-re)) |
| 182 | "Matches an AWK regexp up to, but not including, any terminating /.") | 202 | ;; Matches an AWK regexp up to, but not including, any terminating /. |
| 183 | 203 | ||
| 184 | ;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A | 204 | ;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A |
| 185 | ;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant | 205 | ;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant |
| @@ -187,47 +207,47 @@ missing.") | |||
| 187 | ;; division sign. | 207 | ;; division sign. |
| 188 | (defconst c-awk-neutral-re | 208 | (defconst c-awk-neutral-re |
| 189 | ; "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)+") ; changed, 2003/6/7 | 209 | ; "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)+") ; changed, 2003/6/7 |
| 190 | "\\([}@` \t]\\|\\+\\+\\|--\\|\\\\\\(.\\|[\n\r]\\)\\)" | 210 | "\\([}@` \t]\\|\\+\\+\\|--\\|\\\\\\(.\\|[\n\r]\\)\\)") |
| 191 | "A \"neutral\" char(pair). Doesn't change the \"state\" of a subsequent /. | 211 | ;; A "neutral" char(pair). Doesn't change the "state" of a subsequent /. |
| 192 | This is space/tab, close brace, an auto-increment/decrement operator or an | 212 | ;; This is space/tab, close brace, an auto-increment/decrement operator or an |
| 193 | escaped character. Or one of the (invalid) characters @ or `. But NOT an | 213 | ;; escaped character. Or one of the (invalid) characters @ or `. But NOT an |
| 194 | end of line (unless escaped).") | 214 | ;; end of line (unless escaped). |
| 195 | (defconst c-awk-neutrals*-re | 215 | (defconst c-awk-neutrals*-re |
| 196 | (concat "\\(" c-awk-neutral-re "\\)*") | 216 | (concat "\\(" c-awk-neutral-re "\\)*")) |
| 197 | "A (possibly empty) string of neutral characters (or character pairs).") | 217 | ;; A (possibly empty) string of neutral characters (or character pairs). |
| 198 | (defconst c-awk-var-num-ket-re "[]\)0-9a-zA-Z_$.\x80-\xff]+" | 218 | (defconst c-awk-var-num-ket-re "[]\)0-9a-zA-Z_$.\x80-\xff]+") |
| 199 | "Matches a char which is a constituent of a variable or number, or a ket | 219 | ;; Matches a char which is a constituent of a variable or number, or a ket |
| 200 | \(i.e. closing bracKET), round or square. Assume that all characters \\x80 to | 220 | ;; (i.e. closing bracKET), round or square. Assume that all characters \x80 to |
| 201 | \\xff are \"letters\".") | 221 | ;; \xff are "letters". |
| 202 | (defconst c-awk-div-sign-re | 222 | (defconst c-awk-div-sign-re |
| 203 | (concat c-awk-var-num-ket-re c-awk-neutrals*-re "/") | 223 | (concat c-awk-var-num-ket-re c-awk-neutrals*-re "/")) |
| 204 | "Will match a piece of AWK buffer ending in / which is a division sign, in | 224 | ;; Will match a piece of AWK buffer ending in / which is a division sign, in |
| 205 | a context where an immediate / would be a regexp bracket. It follows a | 225 | ;; a context where an immediate / would be a regexp bracket. It follows a |
| 206 | variable or number (with optional intervening \"neutral\" characters). This | 226 | ;; variable or number (with optional intervening "neutral" characters). This |
| 207 | will only work when there won't be a preceding \" or / before the sought / | 227 | ;; will only work when there won't be a preceding " or / before the sought / |
| 208 | to foul things up.") | 228 | ;; to foul things up. |
| 209 | (defconst c-awk-non-arith-op-bra-re | 229 | (defconst c-awk-non-arith-op-bra-re |
| 210 | "[[\({&=:!><,?;'~|]" | 230 | "[[\({&=:!><,?;'~|]") |
| 211 | "Matches an opening BRAcket (of any sort), or any operator character | 231 | ;; Matches an opening BRAcket (of any sort), or any operator character |
| 212 | apart from +,-,/,*,%. For the purpose at hand (detecting a / which is a | 232 | ;; apart from +,-,/,*,%. For the purpose at hand (detecting a / which is a |
| 213 | regexp bracket) these arith ops are unnecessary and a pain, because of \"++\" | 233 | ;; regexp bracket) these arith ops are unnecessary and a pain, because of "++" |
| 214 | and \"--\".") | 234 | ;; and "--". |
| 215 | (defconst c-awk-regexp-sign-re | 235 | (defconst c-awk-regexp-sign-re |
| 216 | (concat c-awk-non-arith-op-bra-re c-awk-neutrals*-re "/") | 236 | (concat c-awk-non-arith-op-bra-re c-awk-neutrals*-re "/")) |
| 217 | "Will match a piece of AWK buffer ending in / which is an opening regexp | 237 | ;; Will match a piece of AWK buffer ending in / which is an opening regexp |
| 218 | bracket, in a context where an immediate / would be a division sign. This | 238 | ;; bracket, in a context where an immediate / would be a division sign. This |
| 219 | will only work when there won't be a preceding \" or / before the sought / | 239 | ;; will only work when there won't be a preceding " or / before the sought / |
| 220 | to foul things up.") | 240 | ;; to foul things up. |
| 221 | (defconst c-awk-pre-exp-alphanum-kwd-re | 241 | (defconst c-awk-pre-exp-alphanum-kwd-re |
| 222 | (concat "\\(^\\|\\=\\|[^_\n\r]\\)\\<" | 242 | (concat "\\(^\\|\\=\\|[^_\n\r]\\)\\<" |
| 223 | (regexp-opt '("print" "return" "case") t) | 243 | (regexp-opt '("print" "return" "case") t) |
| 224 | "\\>\\([^_\n\r]\\|$\\)") | 244 | "\\>\\([^_\n\r]\\|$\\)")) |
| 225 | "Matches all AWK keywords which can precede expressions (including | 245 | ;; Matches all AWK keywords which can precede expressions (including |
| 226 | /regexp/).") | 246 | ;; /regexp/). |
| 227 | (defconst c-awk-kwd-regexp-sign-re | 247 | (defconst c-awk-kwd-regexp-sign-re |
| 228 | (concat c-awk-pre-exp-alphanum-kwd-re c-awk-escaped-nls*-with-space* "/") | 248 | (concat c-awk-pre-exp-alphanum-kwd-re c-awk-escaped-nls*-with-space* "/")) |
| 229 | "Matches a piece of AWK buffer ending in <kwd> /, where <kwd> is a keyword | 249 | ;; Matches a piece of AWK buffer ending in <kwd> /, where <kwd> is a keyword |
| 230 | which can precede an expression.") | 250 | ;; which can precede an expression. |
| 231 | 251 | ||
| 232 | ;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon" | 252 | ;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon" |
| 233 | (defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]") | 253 | (defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]") |
| @@ -239,16 +259,16 @@ which can precede an expression.") | |||
| 239 | c-awk-possibly-open-string-re | 259 | c-awk-possibly-open-string-re |
| 240 | "\\)" | 260 | "\\)" |
| 241 | "\\)*")) | 261 | "\\)*")) |
| 242 | (defconst c-awk-space*-/-re (concat c-awk-escaped-nls*-with-space* "/") | 262 | (defconst c-awk-space*-/-re (concat c-awk-escaped-nls*-with-space* "/")) |
| 243 | "Matches optional whitespace followed by \"/\".") | 263 | ;; Matches optional whitespace followed by "/". |
| 244 | (defconst c-awk-space*-regexp-/-re | 264 | (defconst c-awk-space*-regexp-/-re |
| 245 | (concat c-awk-escaped-nls*-with-space* "\\s\"") | 265 | (concat c-awk-escaped-nls*-with-space* "\\s\"")) |
| 246 | "Matches optional whitespace followed by a \"/\" with string syntax (a matched | 266 | ;; Matches optional whitespace followed by a "/" with string syntax (a matched |
| 247 | regexp delimiter).") | 267 | ;; regexp delimiter). |
| 248 | (defconst c-awk-space*-unclosed-regexp-/-re | 268 | (defconst c-awk-space*-unclosed-regexp-/-re |
| 249 | (concat c-awk-escaped-nls*-with-space* "\\s\|") | 269 | (concat c-awk-escaped-nls*-with-space* "\\s\|")) |
| 250 | "Matches optional whitespace followed by a \"/\" with string fence syntax (an | 270 | ;; Matches optional whitespace followed by a "/" with string fence syntax (an |
| 251 | unmatched regexp delimiter).") | 271 | ;; unmatched regexp delimiter). |
| 252 | 272 | ||
| 253 | 273 | ||
| 254 | ;; ACM, 2002/5/29: | 274 | ;; ACM, 2002/5/29: |
| @@ -303,16 +323,16 @@ unmatched regexp delimiter).") | |||
| 303 | ;; statement of a do-while. | 323 | ;; statement of a do-while. |
| 304 | 324 | ||
| 305 | (defun c-awk-after-if-for-while-condition-p (&optional do-lim) | 325 | (defun c-awk-after-if-for-while-condition-p (&optional do-lim) |
| 306 | "Are we just after the ) in \"if/for/while (<condition>)\"? | 326 | ;; Are we just after the ) in "if/for/while (<condition>)"? |
| 307 | 327 | ;; | |
| 308 | Note that the end of the ) in a do .... while (<condition>) doesn't | 328 | ;; Note that the end of the ) in a do .... while (<condition>) doesn't |
| 309 | count, since the purpose of this routine is essentially to decide | 329 | ;; count, since the purpose of this routine is essentially to decide |
| 310 | whether to indent the next line. | 330 | ;; whether to indent the next line. |
| 311 | 331 | ;; | |
| 312 | DO-LIM sets a limit on how far back we search for the \"do\" of a possible | 332 | ;; DO-LIM sets a limit on how far back we search for the "do" of a possible |
| 313 | do-while. | 333 | ;; do-while. |
| 314 | 334 | ;; | |
| 315 | This function might do hidden buffer changes." | 335 | ;; This function might do hidden buffer changes. |
| 316 | (and | 336 | (and |
| 317 | (eq (char-before) ?\)) | 337 | (eq (char-before) ?\)) |
| 318 | (save-excursion | 338 | (save-excursion |
| @@ -326,9 +346,9 @@ This function might do hidden buffer changes." | |||
| 326 | 'beginning))))))))) | 346 | 'beginning))))))))) |
| 327 | 347 | ||
| 328 | (defun c-awk-after-function-decl-param-list () | 348 | (defun c-awk-after-function-decl-param-list () |
| 329 | "Are we just after the ) in \"function foo (bar)\" ? | 349 | ;; Are we just after the ) in "function foo (bar)" ? |
| 330 | 350 | ;; | |
| 331 | This function might do hidden buffer changes." | 351 | ;; This function might do hidden buffer changes. |
| 332 | (and (eq (char-before) ?\)) | 352 | (and (eq (char-before) ?\)) |
| 333 | (save-excursion | 353 | (save-excursion |
| 334 | (let ((par-pos (c-safe (scan-lists (point) -1 0)))) | 354 | (let ((par-pos (c-safe (scan-lists (point) -1 0)))) |
| @@ -341,10 +361,10 @@ This function might do hidden buffer changes." | |||
| 341 | 361 | ||
| 342 | ;; 2002/11/8: FIXME! Check c-backward-token-1/2 for success (0 return code). | 362 | ;; 2002/11/8: FIXME! Check c-backward-token-1/2 for success (0 return code). |
| 343 | (defun c-awk-after-continue-token () | 363 | (defun c-awk-after-continue-token () |
| 344 | "Are we just after a token which can be continued onto the next line without | 364 | ;; Are we just after a token which can be continued onto the next line without |
| 345 | a backslash? | 365 | ;; a backslash? |
| 346 | 366 | ;; | |
| 347 | This function might do hidden buffer changes." | 367 | ;; This function might do hidden buffer changes. |
| 348 | (save-excursion | 368 | (save-excursion |
| 349 | (c-backward-token-1) ; FIXME 2002/10/27. What if this fails? | 369 | (c-backward-token-1) ; FIXME 2002/10/27. What if this fails? |
| 350 | (if (and (looking-at "[&|]") (not (bobp))) | 370 | (if (and (looking-at "[&|]") (not (bobp))) |
| @@ -352,10 +372,10 @@ This function might do hidden buffer changes." | |||
| 352 | (looking-at "[,{?:]\\|&&\\|||\\|do\\>\\|else\\>"))) | 372 | (looking-at "[,{?:]\\|&&\\|||\\|do\\>\\|else\\>"))) |
| 353 | 373 | ||
| 354 | (defun c-awk-after-rbrace-or-statement-semicolon () | 374 | (defun c-awk-after-rbrace-or-statement-semicolon () |
| 355 | "Are we just after a } or a ; which closes a statement? | 375 | ;; Are we just after a } or a ; which closes a statement? |
| 356 | Be careful about ;s in for loop control bits. They don't count! | 376 | ;; Be careful about ;s in for loop control bits. They don't count! |
| 357 | 377 | ;; | |
| 358 | This function might do hidden buffer changes." | 378 | ;; This function might do hidden buffer changes. |
| 359 | (or (eq (char-before) ?\}) | 379 | (or (eq (char-before) ?\}) |
| 360 | (and | 380 | (and |
| 361 | (eq (char-before) ?\;) | 381 | (eq (char-before) ?\;) |
| @@ -368,22 +388,22 @@ This function might do hidden buffer changes." | |||
| 368 | (looking-at "for\\>"))))))))) | 388 | (looking-at "for\\>"))))))))) |
| 369 | 389 | ||
| 370 | (defun c-awk-back-to-contentful-text-or-NL-prop () | 390 | (defun c-awk-back-to-contentful-text-or-NL-prop () |
| 371 | "Move back to just after the first found of either (i) an EOL which has | 391 | ;; Move back to just after the first found of either (i) an EOL which has |
| 372 | the `c-awk-NL-prop' text-property set; or (ii) non-ws text; or (iii) BOB. | 392 | ;; the c-awk-NL-prop text-property set; or (ii) non-ws text; or (iii) BOB. |
| 373 | We return either the value of `c-awk-NL-prop' (in case (i)) or nil. | 393 | ;; We return either the value of c-awk-NL-prop (in case (i)) or nil. |
| 374 | Calling functions can best distinguish cases (ii) and (iii) with `bolp'. | 394 | ;; Calling functions can best distinguish cases (ii) and (iii) with (bolp). |
| 375 | 395 | ;; | |
| 376 | Note that an escaped eol counts as whitespace here. | 396 | ;; Note that an escaped eol counts as whitespace here. |
| 377 | 397 | ;; | |
| 378 | Kludge: If `c-backward-syntactic-ws' gets stuck at a BOL, it is likely | 398 | ;; Kludge: If c-backward-syntactic-ws gets stuck at a BOL, it is likely |
| 379 | that the previous line contains an unterminated string (without \\). In | 399 | ;; that the previous line contains an unterminated string (without \). In |
| 380 | this case, assume that the previous line's `c-awk-NL-prop' is a $. | 400 | ;; this case, assume that the previous line's c-awk-NL-prop is a $. |
| 381 | 401 | ;; | |
| 382 | POINT MUST BE AT THE START OF A LINE when calling this function. This | 402 | ;; POINT MUST BE AT THE START OF A LINE when calling this function. This |
| 383 | is to ensure that the various backward-comment functions will work | 403 | ;; is to ensure that the various backward-comment functions will work |
| 384 | properly. | 404 | ;; properly. |
| 385 | 405 | ;; | |
| 386 | This function might do hidden buffer changes." | 406 | ;; This function might do hidden buffer changes. |
| 387 | (let ((nl-prop nil) | 407 | (let ((nl-prop nil) |
| 388 | bol-pos bsws-pos) ; starting pos for a backward-syntactic-ws call. | 408 | bol-pos bsws-pos) ; starting pos for a backward-syntactic-ws call. |
| 389 | (while ;; We are at a BOL here. Go back one line each iteration. | 409 | (while ;; We are at a BOL here. Go back one line each iteration. |
| @@ -418,19 +438,19 @@ This function might do hidden buffer changes." | |||
| 418 | nl-prop)) | 438 | nl-prop)) |
| 419 | 439 | ||
| 420 | (defun c-awk-calculate-NL-prop-prev-line (&optional do-lim) | 440 | (defun c-awk-calculate-NL-prop-prev-line (&optional do-lim) |
| 421 | "Calculate and set the value of the `c-awk-NL-prop' on the immediately | 441 | ;; Calculate and set the value of the c-awk-NL-prop on the immediately |
| 422 | preceding EOL. This may also involve doing the same for several | 442 | ;; preceding EOL. This may also involve doing the same for several |
| 423 | preceding EOLs. | 443 | ;; preceding EOLs. |
| 424 | 444 | ;; | |
| 425 | NOTE that if the property was already set, we return it without | 445 | ;; NOTE that if the property was already set, we return it without |
| 426 | recalculation. (This is by accident rather than design.) | 446 | ;; recalculation. (This is by accident rather than design.) |
| 427 | 447 | ;; | |
| 428 | Return the property which got set (or was already set) on the previous | 448 | ;; Return the property which got set (or was already set) on the previous |
| 429 | line. Return nil if we hit BOB. | 449 | ;; line. Return nil if we hit BOB. |
| 430 | 450 | ;; | |
| 431 | See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM. | 451 | ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
| 432 | 452 | ;; | |
| 433 | This function might do hidden buffer changes." | 453 | ;; This function might do hidden buffer changes. |
| 434 | (save-excursion | 454 | (save-excursion |
| 435 | (save-match-data | 455 | (save-match-data |
| 436 | (beginning-of-line) | 456 | (beginning-of-line) |
| @@ -473,25 +493,25 @@ This function might do hidden buffer changes." | |||
| 473 | nl-prop)))) | 493 | nl-prop)))) |
| 474 | 494 | ||
| 475 | (defun c-awk-get-NL-prop-prev-line (&optional do-lim) | 495 | (defun c-awk-get-NL-prop-prev-line (&optional do-lim) |
| 476 | "Get the `c-awk-NL-prop' text-property from the previous line, calculating | 496 | ;; Get the c-awk-NL-prop text-property from the previous line, calculating |
| 477 | it if necessary. Return nil if we're already at BOB. | 497 | ;; it if necessary. Return nil if we're already at BOB. |
| 478 | See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM. | 498 | ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
| 479 | 499 | ;; | |
| 480 | This function might do hidden buffer changes." | 500 | ;; This function might do hidden buffer changes. |
| 481 | (if (bobp) | 501 | (if (bobp) |
| 482 | nil | 502 | nil |
| 483 | (or (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop) | 503 | (or (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop) |
| 484 | (c-awk-calculate-NL-prop-prev-line do-lim)))) | 504 | (c-awk-calculate-NL-prop-prev-line do-lim)))) |
| 485 | 505 | ||
| 486 | (defun c-awk-get-NL-prop-cur-line (&optional do-lim) | 506 | (defun c-awk-get-NL-prop-cur-line (&optional do-lim) |
| 487 | "Get the `c-awk-NL-prop' text-property from the current line, calculating it | 507 | ;; Get the c-awk-NL-prop text-property from the current line, calculating it |
| 488 | if necessary. (As a special case, the property doesn't get set on an | 508 | ;; if necessary. (As a special case, the property doesn't get set on an |
| 489 | empty line at EOB (there's no position to set the property on), but the | 509 | ;; empty line at EOB (there's no position to set the property on), but the |
| 490 | function returns the property value an EOL would have got.) | 510 | ;; function returns the property value an EOL would have got.) |
| 491 | 511 | ;; | |
| 492 | See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM. | 512 | ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
| 493 | 513 | ;; | |
| 494 | This function might do hidden buffer changes." | 514 | ;; This function might do hidden buffer changes. |
| 495 | (save-excursion | 515 | (save-excursion |
| 496 | (let ((extra-nl nil)) | 516 | (let ((extra-nl nil)) |
| 497 | (end-of-line) ; Necessary for the following test to work. | 517 | (end-of-line) ; Necessary for the following test to work. |
| @@ -502,17 +522,17 @@ This function might do hidden buffer changes." | |||
| 502 | (if extra-nl (delete-char -1)))))) | 522 | (if extra-nl (delete-char -1)))))) |
| 503 | 523 | ||
| 504 | (defsubst c-awk-prev-line-incomplete-p (&optional do-lim) | 524 | (defsubst c-awk-prev-line-incomplete-p (&optional do-lim) |
| 505 | "Is there an incomplete statement at the end of the previous line? | 525 | ;; Is there an incomplete statement at the end of the previous line? |
| 506 | See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM. | 526 | ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
| 507 | 527 | ;; | |
| 508 | This function might do hidden buffer changes." | 528 | ;; This function might do hidden buffer changes. |
| 509 | (memq (c-awk-get-NL-prop-prev-line do-lim) '(?\\ ?\{))) | 529 | (memq (c-awk-get-NL-prop-prev-line do-lim) '(?\\ ?\{))) |
| 510 | 530 | ||
| 511 | (defsubst c-awk-cur-line-incomplete-p (&optional do-lim) | 531 | (defsubst c-awk-cur-line-incomplete-p (&optional do-lim) |
| 512 | "Is there an incomplete statement at the end of the current line? | 532 | ;; Is there an incomplete statement at the end of the current line? |
| 513 | See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM. | 533 | ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
| 514 | 534 | ;; | |
| 515 | This function might do hidden buffer changes." | 535 | ;; This function might do hidden buffer changes. |
| 516 | (memq (c-awk-get-NL-prop-cur-line do-lim) '(?\\ ?\{))) | 536 | (memq (c-awk-get-NL-prop-cur-line do-lim) '(?\\ ?\{))) |
| 517 | 537 | ||
| 518 | ;; NOTES ON "VIRTUAL SEMICOLONS" | 538 | ;; NOTES ON "VIRTUAL SEMICOLONS" |
| @@ -525,7 +545,7 @@ This function might do hidden buffer changes." | |||
| 525 | ;; never counts as a virtual one. | 545 | ;; never counts as a virtual one. |
| 526 | 546 | ||
| 527 | (defun c-awk-at-vsemi-p (&optional pos) | 547 | (defun c-awk-at-vsemi-p (&optional pos) |
| 528 | "Is there a virtual semicolon at POS (or POINT)?" | 548 | ;; Is there a virtual semicolon at POS (or POINT)? |
| 529 | (save-excursion | 549 | (save-excursion |
| 530 | (let* (nl-prop | 550 | (let* (nl-prop |
| 531 | (pos-or-point (progn (if pos (goto-char pos)) (point))) | 551 | (pos-or-point (progn (if pos (goto-char pos)) (point))) |
| @@ -565,29 +585,29 @@ This function might do hidden buffer changes." | |||
| 565 | (eq nl-prop ?\$)))))) | 585 | (eq nl-prop ?\$)))))) |
| 566 | 586 | ||
| 567 | (defun c-awk-vsemi-status-unknown-p () | 587 | (defun c-awk-vsemi-status-unknown-p () |
| 568 | "Are we unsure whether there is a virtual semicolon on the current line? | 588 | ;; Are we unsure whether there is a virtual semicolon on the current line? |
| 569 | DO NOT under any circumstances attempt to calculate this; that would | 589 | ;; DO NOT under any circumstances attempt to calculate this; that would |
| 570 | defeat the (admittedly kludgy) purpose of this function, which is to | 590 | ;; defeat the (admittedly kludgy) purpose of this function, which is to |
| 571 | prevent an infinite recursion in `c-beginning-of-statement-1' when point | 591 | ;; prevent an infinite recursion in c-beginning-of-statement-1 when point |
| 572 | starts at a `while' token." | 592 | ;; starts at a `while' token. |
| 573 | (not (c-get-char-property (c-point 'eol) 'c-awk-NL-prop))) | 593 | (not (c-get-char-property (c-point 'eol) 'c-awk-NL-prop))) |
| 574 | 594 | ||
| 575 | (defun c-awk-clear-NL-props (beg end) | 595 | (defun c-awk-clear-NL-props (beg end) |
| 576 | "This function is run from `before-change-hooks.' It clears the | 596 | ;; This function is run from before-change-hooks. It clears the |
| 577 | `c-awk-NL-prop' text property from beg to the end of the buffer (The END | 597 | ;; c-awk-NL-prop text property from beg to the end of the buffer (The END |
| 578 | parameter is ignored). This ensures that the indentation engine will | 598 | ;; parameter is ignored). This ensures that the indentation engine will |
| 579 | never use stale values for this property. | 599 | ;; never use stale values for this property. |
| 580 | 600 | ;; | |
| 581 | This function might do hidden buffer changes." | 601 | ;; This function might do hidden buffer changes. |
| 582 | (save-restriction | 602 | (save-restriction |
| 583 | (widen) | 603 | (widen) |
| 584 | (c-clear-char-properties beg (point-max) 'c-awk-NL-prop))) | 604 | (c-clear-char-properties beg (point-max) 'c-awk-NL-prop))) |
| 585 | 605 | ||
| 586 | (defun c-awk-unstick-NL-prop () | 606 | (defun c-awk-unstick-NL-prop () |
| 587 | "Ensure that the text property `c-awk-NL-prop' is \"non-sticky\". | 607 | ;; Ensure that the text property c-awk-NL-prop is "non-sticky". Without |
| 588 | Without this, a new newline inserted after an old newline (e.g. by C-j) would | 608 | ;; this, a new newline inserted after an old newline (e.g. by C-j) would |
| 589 | inherit any `c-awk-NL-prop' from the old newline. This would be a Bad | 609 | ;; inherit any c-awk-NL-prop from the old newline. This would be a Bad |
| 590 | Thing. This function's action is required by `c-put-char-property'." | 610 | ;; Thing. This function's action is required by c-put-char-property. |
| 591 | (if (and (boundp 'text-property-default-nonsticky) ; doesn't exist in XEmacs | 611 | (if (and (boundp 'text-property-default-nonsticky) ; doesn't exist in XEmacs |
| 592 | (not (assoc 'c-awk-NL-prop text-property-default-nonsticky))) | 612 | (not (assoc 'c-awk-NL-prop text-property-default-nonsticky))) |
| 593 | (setq text-property-default-nonsticky | 613 | (setq text-property-default-nonsticky |
| @@ -630,15 +650,15 @@ Thing. This function's action is required by `c-put-char-property'." | |||
| 630 | ;; to allow this. | 650 | ;; to allow this. |
| 631 | 651 | ||
| 632 | (defun c-awk-beginning-of-logical-line (&optional pos) | 652 | (defun c-awk-beginning-of-logical-line (&optional pos) |
| 633 | "Go back to the start of the (apparent) current line (or the start of the | 653 | ;; Go back to the start of the (apparent) current line (or the start of the |
| 634 | line containing POS), returning the buffer position of that point. I.e., | 654 | ;; line containing POS), returning the buffer position of that point. I.e., |
| 635 | go back to the last line which doesn't have an escaped EOL before it. | 655 | ;; go back to the last line which doesn't have an escaped EOL before it. |
| 636 | 656 | ;; | |
| 637 | This is guaranteed to be \"safe\" for syntactic analysis, i.e. outwith any | 657 | ;; This is guaranteed to be "safe" for syntactic analysis, i.e. outwith any |
| 638 | comment, string or regexp. IT MAY WELL BE that this function should not be | 658 | ;; comment, string or regexp. IT MAY WELL BE that this function should not be |
| 639 | executed on a narrowed buffer. | 659 | ;; executed on a narrowed buffer. |
| 640 | 660 | ;; | |
| 641 | This function might do hidden buffer changes." | 661 | ;; This function might do hidden buffer changes. |
| 642 | (if pos (goto-char pos)) | 662 | (if pos (goto-char pos)) |
| 643 | (forward-line 0) | 663 | (forward-line 0) |
| 644 | (while (and (> (point) (point-min)) | 664 | (while (and (> (point) (point-min)) |
| @@ -647,15 +667,15 @@ This function might do hidden buffer changes." | |||
| 647 | (point)) | 667 | (point)) |
| 648 | 668 | ||
| 649 | (defun c-awk-beyond-logical-line (&optional pos) | 669 | (defun c-awk-beyond-logical-line (&optional pos) |
| 650 | "Return the position just beyond the (apparent) current logical line, or the | 670 | ;; Return the position just beyond the (apparent) current logical line, or the |
| 651 | one containing POS. This is usually the beginning of the next line which | 671 | ;; one containing POS. This is usually the beginning of the next line which |
| 652 | doesn't follow an escaped EOL. At EOB, this will be EOB. | 672 | ;; doesn't follow an escaped EOL. At EOB, this will be EOB. |
| 653 | 673 | ;; | |
| 654 | Point is unchanged. | 674 | ;; Point is unchanged. |
| 655 | 675 | ;; | |
| 656 | This is guaranteed to be \"safe\" for syntactic analysis, i.e. outwith any | 676 | ;; This is guaranteed to be "safe" for syntactic analysis, i.e. outwith any |
| 657 | comment, string or regexp. IT MAY WELL BE that this function should not be | 677 | ;; comment, string or regexp. IT MAY WELL BE that this function should not be |
| 658 | executed on a narrowed buffer." | 678 | ;; executed on a narrowed buffer. |
| 659 | (save-excursion | 679 | (save-excursion |
| 660 | (if pos (goto-char pos)) | 680 | (if pos (goto-char pos)) |
| 661 | (end-of-line) | 681 | (end-of-line) |
| @@ -673,19 +693,19 @@ executed on a narrowed buffer." | |||
| 673 | ;; or comment. | 693 | ;; or comment. |
| 674 | 694 | ||
| 675 | (defun c-awk-set-string-regexp-syntax-table-properties (beg end) | 695 | (defun c-awk-set-string-regexp-syntax-table-properties (beg end) |
| 676 | "BEG and END bracket a (possibly unterminated) string or regexp. The | 696 | ;; BEG and END bracket a (possibly unterminated) string or regexp. The |
| 677 | opening delimiter is after BEG, and the closing delimiter, IF ANY, is AFTER | 697 | ;; opening delimiter is after BEG, and the closing delimiter, IF ANY, is AFTER |
| 678 | END. Set the appropriate syntax-table properties on the delimiters and | 698 | ;; END. Set the appropriate syntax-table properties on the delimiters and |
| 679 | contents of this string/regex. | 699 | ;; contents of this string/regex. |
| 680 | 700 | ;; | |
| 681 | \"String\" here can also mean a gawk 3.1 \"localizable\" string which starts | 701 | ;; "String" here can also mean a gawk 3.1 "localizable" string which starts |
| 682 | with _\". In this case, we step over the _ and ignore it; It will get it's | 702 | ;; with _". In this case, we step over the _ and ignore it; It will get it's |
| 683 | font from an entry in `awk-font-lock-keywords'. | 703 | ;; font from an entry in awk-font-lock-keywords. |
| 684 | 704 | ;; | |
| 685 | If the closing delimiter is missing (i.e., there is an EOL there) set the | 705 | ;; If the closing delimiter is missing (i.e., there is an EOL there) set the |
| 686 | STRING-FENCE property on the opening \" or / and closing EOL. | 706 | ;; STRING-FENCE property on the opening " or / and closing EOL. |
| 687 | 707 | ;; | |
| 688 | This function does hidden buffer changes." | 708 | ;; This function does hidden buffer changes. |
| 689 | (if (eq (char-after beg) ?_) (setq beg (1+ beg))) | 709 | (if (eq (char-after beg) ?_) (setq beg (1+ beg))) |
| 690 | 710 | ||
| 691 | ;; First put the properties on the delimiters. | 711 | ;; First put the properties on the delimiters. |
| @@ -706,13 +726,13 @@ This function does hidden buffer changes." | |||
| 706 | (c-put-char-property (1- (point)) 'syntax-table '(1)))))) | 726 | (c-put-char-property (1- (point)) 'syntax-table '(1)))))) |
| 707 | 727 | ||
| 708 | (defun c-awk-syntax-tablify-string () | 728 | (defun c-awk-syntax-tablify-string () |
| 709 | "Point is at the opening \" or _\" of a string. Set the syntax-table | 729 | ;; Point is at the opening " or _" of a string. Set the syntax-table |
| 710 | properties on this string, leaving point just after the string. | 730 | ;; properties on this string, leaving point just after the string. |
| 711 | 731 | ;; | |
| 712 | The result is nil if a / immediately after the string would be a regexp | 732 | ;; The result is nil if a / immediately after the string would be a regexp |
| 713 | opener, t if it would be a division sign. | 733 | ;; opener, t if it would be a division sign. |
| 714 | 734 | ;; | |
| 715 | This function does hidden buffer changes." | 735 | ;; This function does hidden buffer changes. |
| 716 | (search-forward-regexp c-awk-string-without-end-here-re nil t) ; a (possibly unterminated) string | 736 | (search-forward-regexp c-awk-string-without-end-here-re nil t) ; a (possibly unterminated) string |
| 717 | (c-awk-set-string-regexp-syntax-table-properties | 737 | (c-awk-set-string-regexp-syntax-table-properties |
| 718 | (match-beginning 0) (match-end 0)) | 738 | (match-beginning 0) (match-end 0)) |
| @@ -725,19 +745,19 @@ This function does hidden buffer changes." | |||
| 725 | (t nil))) ; Unterminated string at EOB | 745 | (t nil))) ; Unterminated string at EOB |
| 726 | 746 | ||
| 727 | (defun c-awk-syntax-tablify-/ (anchor anchor-state-/div) | 747 | (defun c-awk-syntax-tablify-/ (anchor anchor-state-/div) |
| 728 | "Point is at a /. Determine whether this is a division sign or a regexp | 748 | ;; Point is at a /. Determine whether this is a division sign or a regexp |
| 729 | opener, and if the latter, apply syntax-table properties to the entire | 749 | ;; opener, and if the latter, apply syntax-table properties to the entire |
| 730 | regexp. Point is left immediately after the division sign or regexp, as | 750 | ;; regexp. Point is left immediately after the division sign or regexp, as |
| 731 | the case may be. | 751 | ;; the case may be. |
| 732 | 752 | ;; | |
| 733 | ANCHOR-STATE-/DIV identifies whether a / at ANCHOR would have been a | 753 | ;; ANCHOR-STATE-/DIV identifies whether a / at ANCHOR would have been a |
| 734 | division sign (value t) or a regexp opener (value nil). The idea is that | 754 | ;; division sign (value t) or a regexp opener (value nil). The idea is that |
| 735 | we analyze the line from ANCHOR up till point to determine what the / at | 755 | ;; we analyze the line from ANCHOR up till point to determine what the / at |
| 736 | point is. | 756 | ;; point is. |
| 737 | 757 | ;; | |
| 738 | The result is what ANCHOR-STATE-/DIV (see above) is where point is left. | 758 | ;; The result is what ANCHOR-STATE-/DIV (see above) is where point is left. |
| 739 | 759 | ;; | |
| 740 | This function does hidden buffer changes." | 760 | ;; This function does hidden buffer changes. |
| 741 | (let ((/point (point))) | 761 | (let ((/point (point))) |
| 742 | (goto-char anchor) | 762 | (goto-char anchor) |
| 743 | ;; Analyze the line to find out what the / is. | 763 | ;; Analyze the line to find out what the / is. |
| @@ -762,30 +782,30 @@ This function does hidden buffer changes." | |||
| 762 | (t nil))))) ; Unterminated regexp at EOB | 782 | (t nil))))) ; Unterminated regexp at EOB |
| 763 | 783 | ||
| 764 | (defun c-awk-set-syntax-table-properties (lim) | 784 | (defun c-awk-set-syntax-table-properties (lim) |
| 765 | "Scan the buffer text between point and LIM, setting (and clearing) the | 785 | ;; Scan the buffer text between point and LIM, setting (and clearing) the |
| 766 | syntax-table property where necessary. | 786 | ;; syntax-table property where necessary. |
| 767 | 787 | ;; | |
| 768 | This function is designed to be called as the FUNCTION in a MATCHER in | 788 | ;; This function is designed to be called as the FUNCTION in a MATCHER in |
| 769 | font-lock-syntactic-keywords, and it always returns NIL (to inhibit | 789 | ;; font-lock-syntactic-keywords, and it always returns NIL (to inhibit |
| 770 | repeated calls from font-lock: See elisp info page \"Search-based | 790 | ;; repeated calls from font-lock: See elisp info page "Search-based |
| 771 | Fontification\"). It also gets called, with a bit of glue, from | 791 | ;; Fontification"). It also gets called, with a bit of glue, from |
| 772 | after-change-functions when font-lock isn't active. Point is left | 792 | ;; after-change-functions when font-lock isn't active. Point is left |
| 773 | \"undefined\" after this function exits. THE BUFFER SHOULD HAVE BEEN | 793 | ;; "undefined" after this function exits. THE BUFFER SHOULD HAVE BEEN |
| 774 | WIDENED, AND ANY PRECIOUS MATCH-DATA SAVED BEFORE CALLING THIS ROUTINE. | 794 | ;; WIDENED, AND ANY PRECIOUS MATCH-DATA SAVED BEFORE CALLING THIS ROUTINE. |
| 775 | 795 | ;; | |
| 776 | We need to set/clear the syntax-table property on: | 796 | ;; We need to set/clear the syntax-table property on: |
| 777 | \(i) / - It is set to \"string\" on a / which is the opening or closing | 797 | ;; (i) / - It is set to "string" on a / which is the opening or closing |
| 778 | delimiter of the properly terminated regexp (and left unset on a | 798 | ;; delimiter of the properly terminated regexp (and left unset on a |
| 779 | division sign). | 799 | ;; division sign). |
| 780 | \(ii) the opener of an unterminated string/regexp, we set the property | 800 | ;; (ii) the opener of an unterminated string/regexp, we set the property |
| 781 | \"generic string delimiter\" on both the opening \" or / and the end of the | 801 | ;; "generic string delimiter" on both the opening " or / and the end of the |
| 782 | line where the closing delimiter is missing. | 802 | ;; line where the closing delimiter is missing. |
| 783 | \(iii) \"s inside strings/regexps (these will all be escaped \"s). They are | 803 | ;; (iii) "s inside strings/regexps (these will all be escaped "s). They are |
| 784 | given the property \"punctuation\". This will later allow other routines | 804 | ;; given the property "punctuation". This will later allow other routines |
| 785 | to use the regexp \"\\\\S\\\"*\" to skip over the string innards. | 805 | ;; to use the regexp "\\S\"*" to skip over the string innards. |
| 786 | \(iv) Inside a comment, all syntax-table properties are cleared. | 806 | ;; (iv) Inside a comment, all syntax-table properties are cleared. |
| 787 | 807 | ;; | |
| 788 | This function does hidden buffer changes." | 808 | ;; This function does hidden buffer changes. |
| 789 | (let (anchor | 809 | (let (anchor |
| 790 | (anchor-state-/div nil)) ; t means a following / would be a div sign. | 810 | (anchor-state-/div nil)) ; t means a following / would be a div sign. |
| 791 | (c-awk-beginning-of-logical-line) ; ACM 2002/7/21. This is probably redundant. | 811 | (c-awk-beginning-of-logical-line) ; ACM 2002/7/21. This is probably redundant. |
| @@ -825,26 +845,26 @@ This function does hidden buffer changes." | |||
| 825 | ;; Set in c-awk-record-region-clear-NL and used in c-awk-after-change. | 845 | ;; Set in c-awk-record-region-clear-NL and used in c-awk-after-change. |
| 826 | 846 | ||
| 827 | (defun c-awk-record-region-clear-NL (beg end) | 847 | (defun c-awk-record-region-clear-NL (beg end) |
| 828 | "This function is called exclusively from the `before-change-functions' hook. | 848 | ;; This function is called exclusively from the before-change-functions hook. |
| 829 | It does two things: Finds the end of the (logical) line on which END lies, | 849 | ;; It does two things: Finds the end of the (logical) line on which END lies, |
| 830 | and clears `c-awk-NL-prop' text properties from this point onwards. BEG is | 850 | ;; and clears c-awk-NL-prop text properties from this point onwards. BEG is |
| 831 | ignored. | 851 | ;; ignored. |
| 832 | 852 | ;; | |
| 833 | On entry, the buffer will have been widened and match-data will have been | 853 | ;; On entry, the buffer will have been widened and match-data will have been |
| 834 | saved; point is undefined on both entry and exit; the return value is | 854 | ;; saved; point is undefined on both entry and exit; the return value is |
| 835 | ignored. | 855 | ;; ignored. |
| 836 | 856 | ;; | |
| 837 | This function does hidden buffer changes." | 857 | ;; This function does hidden buffer changes. |
| 838 | (c-save-buffer-state () | 858 | (c-save-buffer-state () |
| 839 | (setq c-awk-old-ByLL (c-awk-beyond-logical-line end)) | 859 | (setq c-awk-old-ByLL (c-awk-beyond-logical-line end)) |
| 840 | (c-save-buffer-state nil | 860 | (c-save-buffer-state nil |
| 841 | (c-awk-clear-NL-props end (point-max))))) | 861 | (c-awk-clear-NL-props end (point-max))))) |
| 842 | 862 | ||
| 843 | (defun c-awk-end-of-change-region (beg end old-len) | 863 | (defun c-awk-end-of-change-region (beg end old-len) |
| 844 | "Find the end of the region which needs to be font-locked after a change. | 864 | ;; Find the end of the region which needs to be font-locked after a change. |
| 845 | This is the end of the logical line on which the change happened, either | 865 | ;; This is the end of the logical line on which the change happened, either |
| 846 | as it was before the change, or as it is now, whichever is later. | 866 | ;; as it was before the change, or as it is now, whichever is later. |
| 847 | N.B. point is left undefined." | 867 | ;; N.B. point is left undefined. |
| 848 | (max (+ (- c-awk-old-ByLL old-len) (- end beg)) | 868 | (max (+ (- c-awk-old-ByLL old-len) (- end beg)) |
| 849 | (c-awk-beyond-logical-line end))) | 869 | (c-awk-beyond-logical-line end))) |
| 850 | 870 | ||
| @@ -855,25 +875,22 @@ N.B. point is left undefined." | |||
| 855 | ;; Don't overlook the possibility of the buffer change being the "recapturing" | 875 | ;; Don't overlook the possibility of the buffer change being the "recapturing" |
| 856 | ;; of a previously escaped newline. | 876 | ;; of a previously escaped newline. |
| 857 | 877 | ||
| 858 | (defvar c-new-BEG) | ||
| 859 | (defvar c-new-END) | ||
| 860 | |||
| 861 | ;; ACM 2008-02-05: | 878 | ;; ACM 2008-02-05: |
| 862 | (defun c-awk-extend-and-syntax-tablify-region (beg end old-len) | 879 | (defun c-awk-extend-and-syntax-tablify-region (beg end old-len) |
| 863 | "Expand the region (BEG END) as needed to (c-new-BEG c-new-END) then put | 880 | ;; Expand the region (BEG END) as needed to (c-new-BEG c-new-END) then put |
| 864 | `syntax-table' properties on this region. | 881 | ;; `syntax-table' properties on this region. |
| 865 | 882 | ;; | |
| 866 | This function is called from an after-change function, BEG END and | 883 | ;; This function is called from an after-change function, BEG END and |
| 867 | OLD-LEN being the standard parameters. | 884 | ;; OLD-LEN being the standard parameters. |
| 868 | 885 | ;; | |
| 869 | Point is undefined both before and after this function call, the buffer | 886 | ;; Point is undefined both before and after this function call, the buffer |
| 870 | has been widened, and match-data saved. The return value is ignored. | 887 | ;; has been widened, and match-data saved. The return value is ignored. |
| 871 | 888 | ;; | |
| 872 | It prepares the buffer for font | 889 | ;; It prepares the buffer for font |
| 873 | locking, hence must get called before `font-lock-after-change-function'. | 890 | ;; locking, hence must get called before `font-lock-after-change-function'. |
| 874 | 891 | ;; | |
| 875 | This function is the AWK value of `c-before-font-lock-function'. | 892 | ;; This function is the AWK value of `c-before-font-lock-function'. |
| 876 | It does hidden buffer changes." | 893 | ;; It does hidden buffer changes. |
| 877 | (c-save-buffer-state () | 894 | (c-save-buffer-state () |
| 878 | (setq c-new-END (c-awk-end-of-change-region beg end old-len)) | 895 | (setq c-new-END (c-awk-end-of-change-region beg end old-len)) |
| 879 | (setq c-new-BEG (c-awk-beginning-of-logical-line beg)) | 896 | (setq c-new-BEG (c-awk-beginning-of-logical-line beg)) |
| @@ -945,8 +962,7 @@ std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\ | |||
| 945 | "match" "mktime" "or" "print" "printf" "rand" "rshift" | 962 | "match" "mktime" "or" "print" "printf" "rand" "rshift" |
| 946 | "sin" "split" "sprintf" "sqrt" "srand" "stopme" | 963 | "sin" "split" "sprintf" "sqrt" "srand" "stopme" |
| 947 | "strftime" "strtonum" "sub" "substr" "system" | 964 | "strftime" "strtonum" "sub" "substr" "system" |
| 948 | "systime" "tolower" "toupper" "xor") | 965 | "systime" "tolower" "toupper" "xor") t) |
| 949 | t) | ||
| 950 | "\\>") | 966 | "\\>") |
| 951 | 0 c-preprocessor-face-name)) | 967 | 0 c-preprocessor-face-name)) |
| 952 | 968 | ||
| @@ -977,21 +993,21 @@ std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\ | |||
| 977 | ;; The following three regexps differ from those earlier on in cc-awk.el in | 993 | ;; The following three regexps differ from those earlier on in cc-awk.el in |
| 978 | ;; that they assume the syntax-table properties have been set. They are thus | 994 | ;; that they assume the syntax-table properties have been set. They are thus |
| 979 | ;; not useful for code which sets these properties. | 995 | ;; not useful for code which sets these properties. |
| 980 | (defconst c-awk-terminated-regexp-or-string-here-re "\\=\\s\"\\S\"*\\s\"" | 996 | (defconst c-awk-terminated-regexp-or-string-here-re "\\=\\s\"\\S\"*\\s\"") |
| 981 | "Matches a terminated string/regexp.") | 997 | ;; Matches a terminated string/regexp. |
| 982 | 998 | ||
| 983 | (defconst c-awk-unterminated-regexp-or-string-here-re "\\=\\s|\\S|*$" | 999 | (defconst c-awk-unterminated-regexp-or-string-here-re "\\=\\s|\\S|*$") |
| 984 | "Matches an unterminated string/regexp, NOT including the eol at the end.") | 1000 | ;; Matches an unterminated string/regexp, NOT including the eol at the end. |
| 985 | 1001 | ||
| 986 | (defconst c-awk-harmless-pattern-characters* | 1002 | (defconst c-awk-harmless-pattern-characters* |
| 987 | (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*") | 1003 | (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*")) |
| 988 | "Matches any \"harmless\" character in a pattern or an escaped character pair.") | 1004 | ;; Matches any "harmless" character in a pattern or an escaped character pair. |
| 989 | 1005 | ||
| 990 | (defun c-awk-at-statement-end-p () | 1006 | (defun c-awk-at-statement-end-p () |
| 991 | "Point is not inside a comment or string. Is it AT the end of a | 1007 | ;; Point is not inside a comment or string. Is it AT the end of a |
| 992 | statement? This means immediately after the last non-ws character of the | 1008 | ;; statement? This means immediately after the last non-ws character of the |
| 993 | statement. The caller is responsible for widening the buffer, if | 1009 | ;; statement. The caller is responsible for widening the buffer, if |
| 994 | appropriate." | 1010 | ;; appropriate. |
| 995 | (and (not (bobp)) | 1011 | (and (not (bobp)) |
| 996 | (save-excursion | 1012 | (save-excursion |
| 997 | (backward-char) | 1013 | (backward-char) |
| @@ -1041,13 +1057,13 @@ comment at the start of cc-engine.el for more info." | |||
| 1041 | (eq arg 0))))) | 1057 | (eq arg 0))))) |
| 1042 | 1058 | ||
| 1043 | (defun c-awk-forward-awk-pattern () | 1059 | (defun c-awk-forward-awk-pattern () |
| 1044 | "Point is at the start of an AWK pattern (which may be null) or function | 1060 | ;; Point is at the start of an AWK pattern (which may be null) or function |
| 1045 | declaration. Move to the pattern's end, and past any trailing space or | 1061 | ;; declaration. Move to the pattern's end, and past any trailing space or |
| 1046 | comment. Typically, we stop at the { which denotes the corresponding AWK | 1062 | ;; comment. Typically, we stop at the { which denotes the corresponding AWK |
| 1047 | action/function body. Otherwise we stop at the EOL (or ;) marking the | 1063 | ;; action/function body. Otherwise we stop at the EOL (or ;) marking the |
| 1048 | absence of an explicit action. | 1064 | ;; absence of an explicit action. |
| 1049 | 1065 | ;; | |
| 1050 | This function might do hidden buffer changes." | 1066 | ;; This function might do hidden buffer changes. |
| 1051 | (while | 1067 | (while |
| 1052 | (progn | 1068 | (progn |
| 1053 | (search-forward-regexp c-awk-harmless-pattern-characters*) | 1069 | (search-forward-regexp c-awk-harmless-pattern-characters*) |
| @@ -1064,9 +1080,9 @@ This function might do hidden buffer changes." | |||
| 1064 | ((looking-at "/") (forward-char) t))))) ; division sign. | 1080 | ((looking-at "/") (forward-char) t))))) ; division sign. |
| 1065 | 1081 | ||
| 1066 | (defun c-awk-end-of-defun1 () | 1082 | (defun c-awk-end-of-defun1 () |
| 1067 | "Point is at the start of a \"defun\". Move to its end. Return end position. | 1083 | ;; point is at the start of a "defun". Move to its end. Return end position. |
| 1068 | 1084 | ;; | |
| 1069 | This function might do hidden buffer changes." | 1085 | ;; This function might do hidden buffer changes. |
| 1070 | (c-awk-forward-awk-pattern) | 1086 | (c-awk-forward-awk-pattern) |
| 1071 | (cond | 1087 | (cond |
| 1072 | ((looking-at "{") (goto-char (scan-sexps (point) 1))) | 1088 | ((looking-at "{") (goto-char (scan-sexps (point) 1))) |
| @@ -1076,10 +1092,10 @@ This function might do hidden buffer changes." | |||
| 1076 | (point)) | 1092 | (point)) |
| 1077 | 1093 | ||
| 1078 | (defun c-awk-beginning-of-defun-p () | 1094 | (defun c-awk-beginning-of-defun-p () |
| 1079 | "Are we already at the beginning of a defun? (i.e. at code in column 0 | 1095 | ;; Are we already at the beginning of a defun? (i.e. at code in column 0 |
| 1080 | which isn't a }, and isn't a continuation line of any sort. | 1096 | ;; which isn't a }, and isn't a continuation line of any sort. |
| 1081 | 1097 | ;; | |
| 1082 | This function might do hidden buffer changes." | 1098 | ;; This function might do hidden buffer changes. |
| 1083 | (and (looking-at "^[^#} \t\n\r]") | 1099 | (and (looking-at "^[^#} \t\n\r]") |
| 1084 | (not (c-awk-prev-line-incomplete-p)))) | 1100 | (not (c-awk-prev-line-incomplete-p)))) |
| 1085 | 1101 | ||
| @@ -1129,5 +1145,6 @@ comment at the start of cc-engine.el for more info." | |||
| 1129 | (goto-char (min start-point end-point))))))) | 1145 | (goto-char (min start-point end-point))))))) |
| 1130 | 1146 | ||
| 1131 | 1147 | ||
| 1132 | (provide 'cc-awk) | 1148 | (cc-provide 'cc-awk) ; Changed from 'awk-mode, ACM 2002/5/21 |
| 1133 | ;;; cc-awk.el ends here | 1149 | |
| 1150 | ;;; awk-mode.el ends here | ||
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 91c5773ebb4..5d528caabb2 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -195,7 +195,7 @@ If the referenced position doesn't exist, the closest accessible point | |||
| 195 | to it is returned. This function does not modify the point or the mark." | 195 | to it is returned. This function does not modify the point or the mark." |
| 196 | 196 | ||
| 197 | (if (eq (car-safe position) 'quote) | 197 | (if (eq (car-safe position) 'quote) |
| 198 | (let ((position (nth 1 position))) | 198 | (let ((position (eval position))) |
| 199 | (cond | 199 | (cond |
| 200 | 200 | ||
| 201 | ((eq position 'bol) | 201 | ((eq position 'bol) |
| @@ -885,7 +885,7 @@ MODE is either a mode symbol or a list of mode symbols." | |||
| 885 | `(c-lang-major-mode-is ,mode) | 885 | `(c-lang-major-mode-is ,mode) |
| 886 | 886 | ||
| 887 | (if (eq (car-safe mode) 'quote) | 887 | (if (eq (car-safe mode) 'quote) |
| 888 | (let ((mode (nth 1 mode))) | 888 | (let ((mode (eval mode))) |
| 889 | (if (listp mode) | 889 | (if (listp mode) |
| 890 | `(memq c-buffer-is-cc-mode ',mode) | 890 | `(memq c-buffer-is-cc-mode ',mode) |
| 891 | `(eq c-buffer-is-cc-mode ',mode))) | 891 | `(eq c-buffer-is-cc-mode ',mode))) |
| @@ -900,10 +900,26 @@ MODE is either a mode symbol or a list of mode symbols." | |||
| 900 | ;; properties set on a single character and that never spread to any | 900 | ;; properties set on a single character and that never spread to any |
| 901 | ;; other characters. | 901 | ;; other characters. |
| 902 | 902 | ||
| 903 | (eval-and-compile | ||
| 904 | ;; Constant used at compile time to decide whether or not to use | ||
| 905 | ;; XEmacs extents. Check all the extent functions we'll use since | ||
| 906 | ;; some packages might add compatibility aliases for some of them in | ||
| 907 | ;; Emacs. | ||
| 908 | (defconst c-use-extents (and (cc-bytecomp-fboundp 'extent-at) | ||
| 909 | (cc-bytecomp-fboundp 'set-extent-property) | ||
| 910 | (cc-bytecomp-fboundp 'set-extent-properties) | ||
| 911 | (cc-bytecomp-fboundp 'make-extent) | ||
| 912 | (cc-bytecomp-fboundp 'extent-property) | ||
| 913 | (cc-bytecomp-fboundp 'delete-extent) | ||
| 914 | (cc-bytecomp-fboundp 'map-extents)))) | ||
| 915 | |||
| 903 | ;; `c-put-char-property' is complex enough in XEmacs and Emacs < 21 to | 916 | ;; `c-put-char-property' is complex enough in XEmacs and Emacs < 21 to |
| 904 | ;; make it a function. | 917 | ;; make it a function. |
| 905 | (defalias 'c-put-char-property-fun | 918 | (defalias 'c-put-char-property-fun |
| 906 | (cond ((featurep 'xemacs) | 919 | (cc-eval-when-compile |
| 920 | (cond (c-use-extents | ||
| 921 | ;; XEmacs. | ||
| 922 | (byte-compile | ||
| 907 | (lambda (pos property value) | 923 | (lambda (pos property value) |
| 908 | (let ((ext (extent-at pos nil property))) | 924 | (let ((ext (extent-at pos nil property))) |
| 909 | (if ext | 925 | (if ext |
| @@ -912,19 +928,20 @@ MODE is either a mode symbol or a list of mode symbols." | |||
| 912 | (cons property | 928 | (cons property |
| 913 | (cons value | 929 | (cons value |
| 914 | '(start-open t | 930 | '(start-open t |
| 915 | end-open t)))))))) | 931 | end-open t))))))))) |
| 916 | 932 | ||
| 917 | ((not (cc-bytecomp-boundp 'text-property-default-nonsticky)) | 933 | ((not (cc-bytecomp-boundp 'text-property-default-nonsticky)) |
| 918 | ;; In Emacs < 21 we have to mess with the `rear-nonsticky' property. | 934 | ;; In Emacs < 21 we have to mess with the `rear-nonsticky' property. |
| 935 | (byte-compile | ||
| 919 | (lambda (pos property value) | 936 | (lambda (pos property value) |
| 920 | (put-text-property pos (1+ pos) property value) | 937 | (put-text-property pos (1+ pos) property value) |
| 921 | (let ((prop (get-text-property pos 'rear-nonsticky))) | 938 | (let ((prop (get-text-property pos 'rear-nonsticky))) |
| 922 | (or (memq property prop) | 939 | (or (memq property prop) |
| 923 | (put-text-property pos (1+ pos) | 940 | (put-text-property pos (1+ pos) |
| 924 | 'rear-nonsticky | 941 | 'rear-nonsticky |
| 925 | (cons property prop)))))) | 942 | (cons property prop))))))) |
| 926 | ;; This won't be used for anything. | 943 | ;; This won't be used for anything. |
| 927 | (t #'ignore))) | 944 | (t 'ignore)))) |
| 928 | (cc-bytecomp-defun c-put-char-property-fun) ; Make it known below. | 945 | (cc-bytecomp-defun c-put-char-property-fun) ; Make it known below. |
| 929 | 946 | ||
| 930 | (defmacro c-put-char-property (pos property value) | 947 | (defmacro c-put-char-property (pos property value) |
| @@ -939,38 +956,42 @@ MODE is either a mode symbol or a list of mode symbols." | |||
| 939 | ;; 21) then it's assumed that the property is present on it. | 956 | ;; 21) then it's assumed that the property is present on it. |
| 940 | ;; | 957 | ;; |
| 941 | ;; This macro does a hidden buffer change. | 958 | ;; This macro does a hidden buffer change. |
| 942 | (if (or (featurep 'xemacs) | 959 | (setq property (eval property)) |
| 960 | (if (or c-use-extents | ||
| 943 | (not (cc-bytecomp-boundp 'text-property-default-nonsticky))) | 961 | (not (cc-bytecomp-boundp 'text-property-default-nonsticky))) |
| 944 | ;; XEmacs and Emacs < 21. | 962 | ;; XEmacs and Emacs < 21. |
| 945 | `(c-put-char-property-fun ,pos ,property ,value) | 963 | `(c-put-char-property-fun ,pos ',property ,value) |
| 946 | ;; In Emacs 21 we got the `rear-nonsticky' property covered | 964 | ;; In Emacs 21 we got the `rear-nonsticky' property covered |
| 947 | ;; by `text-property-default-nonsticky'. | 965 | ;; by `text-property-default-nonsticky'. |
| 948 | `(let ((-pos- ,pos)) | 966 | `(let ((-pos- ,pos)) |
| 949 | (put-text-property -pos- (1+ -pos-) ,property ,value)))) | 967 | (put-text-property -pos- (1+ -pos-) ',property ,value)))) |
| 950 | 968 | ||
| 951 | (defmacro c-get-char-property (pos property) | 969 | (defmacro c-get-char-property (pos property) |
| 952 | ;; Get the value of the given property on the character at POS if | 970 | ;; Get the value of the given property on the character at POS if |
| 953 | ;; it's been put there by `c-put-char-property'. PROPERTY is | 971 | ;; it's been put there by `c-put-char-property'. PROPERTY is |
| 954 | ;; assumed to be constant. | 972 | ;; assumed to be constant. |
| 955 | (if (featurep 'xemacs) | 973 | (setq property (eval property)) |
| 974 | (if c-use-extents | ||
| 956 | ;; XEmacs. | 975 | ;; XEmacs. |
| 957 | `(let ((ext (extent-at ,pos nil ,property))) | 976 | `(let ((ext (extent-at ,pos nil ',property))) |
| 958 | (if ext (extent-property ext ,property))) | 977 | (if ext (extent-property ext ',property))) |
| 959 | ;; Emacs. | 978 | ;; Emacs. |
| 960 | `(get-text-property ,pos ,property))) | 979 | `(get-text-property ,pos ',property))) |
| 961 | 980 | ||
| 962 | ;; `c-clear-char-property' is complex enough in Emacs < 21 to make it | 981 | ;; `c-clear-char-property' is complex enough in Emacs < 21 to make it |
| 963 | ;; a function, since we have to mess with the `rear-nonsticky' property. | 982 | ;; a function, since we have to mess with the `rear-nonsticky' property. |
| 964 | (defalias 'c-clear-char-property-fun | 983 | (defalias 'c-clear-char-property-fun |
| 965 | (unless (or (featurep 'xemacs) | 984 | (cc-eval-when-compile |
| 985 | (unless (or c-use-extents | ||
| 966 | (cc-bytecomp-boundp 'text-property-default-nonsticky)) | 986 | (cc-bytecomp-boundp 'text-property-default-nonsticky)) |
| 987 | (byte-compile | ||
| 967 | (lambda (pos property) | 988 | (lambda (pos property) |
| 968 | (when (get-text-property pos property) | 989 | (when (get-text-property pos property) |
| 969 | (remove-text-properties pos (1+ pos) (list property nil)) | 990 | (remove-text-properties pos (1+ pos) (list property nil)) |
| 970 | (put-text-property pos (1+ pos) | 991 | (put-text-property pos (1+ pos) |
| 971 | 'rear-nonsticky | 992 | 'rear-nonsticky |
| 972 | (delq property (get-text-property | 993 | (delq property (get-text-property |
| 973 | pos 'rear-nonsticky))))))) | 994 | pos 'rear-nonsticky))))))))) |
| 974 | (cc-bytecomp-defun c-clear-char-property-fun) ; Make it known below. | 995 | (cc-bytecomp-defun c-clear-char-property-fun) ; Make it known below. |
| 975 | 996 | ||
| 976 | (defmacro c-clear-char-property (pos property) | 997 | (defmacro c-clear-char-property (pos property) |
| @@ -979,10 +1000,8 @@ MODE is either a mode symbol or a list of mode symbols." | |||
| 979 | ;; constant. | 1000 | ;; constant. |
| 980 | ;; | 1001 | ;; |
| 981 | ;; This macro does a hidden buffer change. | 1002 | ;; This macro does a hidden buffer change. |
| 982 | (if (eq 'quote (car-safe property)) | 1003 | (setq property (eval property)) |
| 983 | (setq property (nth 1 property)) | 1004 | (cond (c-use-extents |
| 984 | (error "`property' should be a quoted constant")) | ||
| 985 | (cond ((featurep 'xemacs) | ||
| 986 | ;; XEmacs. | 1005 | ;; XEmacs. |
| 987 | `(let ((ext (extent-at ,pos nil ',property))) | 1006 | `(let ((ext (extent-at ,pos nil ',property))) |
| 988 | (if ext (delete-extent ext)))) | 1007 | (if ext (delete-extent ext)))) |
| @@ -1007,10 +1026,8 @@ MODE is either a mode symbol or a list of mode symbols." | |||
| 1007 | ;; `syntax-table'. | 1026 | ;; `syntax-table'. |
| 1008 | ;; | 1027 | ;; |
| 1009 | ;; This macro does hidden buffer changes. | 1028 | ;; This macro does hidden buffer changes. |
| 1010 | (if (eq 'quote (car-safe property)) | 1029 | (setq property (eval property)) |
| 1011 | (setq property (nth 1 property)) | 1030 | (if c-use-extents |
| 1012 | (error "`property' should be a quoted constant")) | ||
| 1013 | (if (featurep 'xemacs) | ||
| 1014 | ;; XEmacs. | 1031 | ;; XEmacs. |
| 1015 | `(map-extents (lambda (ext ignored) | 1032 | `(map-extents (lambda (ext ignored) |
| 1016 | (delete-extent ext)) | 1033 | (delete-extent ext)) |
| @@ -1080,7 +1097,7 @@ been put there by c-put-char-property. POINT remains unchanged." | |||
| 1080 | which have the value VALUE, as tested by `equal'. These | 1097 | which have the value VALUE, as tested by `equal'. These |
| 1081 | properties are assumed to be over individual characters, having | 1098 | properties are assumed to be over individual characters, having |
| 1082 | been put there by c-put-char-property. POINT remains unchanged." | 1099 | been put there by c-put-char-property. POINT remains unchanged." |
| 1083 | (if (featurep 'xemacs) | 1100 | (if c-use-extents |
| 1084 | ;; XEmacs | 1101 | ;; XEmacs |
| 1085 | `(let ((-property- ,property)) | 1102 | `(let ((-property- ,property)) |
| 1086 | (map-extents (lambda (ext val) | 1103 | (map-extents (lambda (ext val) |
| @@ -1544,6 +1561,32 @@ non-nil, a caret is prepended to invert the set." | |||
| 1544 | (defconst c-emacs-features | 1561 | (defconst c-emacs-features |
| 1545 | (let (list) | 1562 | (let (list) |
| 1546 | 1563 | ||
| 1564 | (if (boundp 'infodock-version) | ||
| 1565 | ;; I've no idea what this actually is, but it's legacy. /mast | ||
| 1566 | (setq list (cons 'infodock list))) | ||
| 1567 | |||
| 1568 | ;; XEmacs uses 8-bit modify-syntax-entry flags. | ||
| 1569 | ;; Emacs uses a 1-bit flag. We will have to set up our | ||
| 1570 | ;; syntax tables differently to handle this. | ||
| 1571 | (let ((table (copy-syntax-table)) | ||
| 1572 | entry) | ||
| 1573 | (modify-syntax-entry ?a ". 12345678" table) | ||
| 1574 | (cond | ||
| 1575 | ;; Emacs | ||
| 1576 | ((arrayp table) | ||
| 1577 | (setq entry (aref table ?a)) | ||
| 1578 | ;; In Emacs, table entries are cons cells | ||
| 1579 | (if (consp entry) (setq entry (car entry)))) | ||
| 1580 | ;; XEmacs | ||
| 1581 | ((fboundp 'get-char-table) | ||
| 1582 | (setq entry (get-char-table ?a table))) | ||
| 1583 | ;; incompatible | ||
| 1584 | (t (error "CC Mode is incompatible with this version of Emacs"))) | ||
| 1585 | (setq list (cons (if (= (logand (lsh entry -16) 255) 255) | ||
| 1586 | '8-bit | ||
| 1587 | '1-bit) | ||
| 1588 | list))) | ||
| 1589 | |||
| 1547 | ;; Check whether beginning/end-of-defun call | 1590 | ;; Check whether beginning/end-of-defun call |
| 1548 | ;; beginning/end-of-defun-function nicely, passing through the | 1591 | ;; beginning/end-of-defun-function nicely, passing through the |
| 1549 | ;; argument and respecting the return code. | 1592 | ;; argument and respecting the return code. |
| @@ -1566,12 +1609,35 @@ non-nil, a caret is prepended to invert the set." | |||
| 1566 | (not (end-of-defun)))) | 1609 | (not (end-of-defun)))) |
| 1567 | (setq list (cons 'argumentative-bod-function list)))) | 1610 | (setq list (cons 'argumentative-bod-function list)))) |
| 1568 | 1611 | ||
| 1569 | (with-temp-buffer | 1612 | (let ((buf (generate-new-buffer " test")) |
| 1570 | (let ((parse-sexp-lookup-properties t) | 1613 | parse-sexp-lookup-properties |
| 1571 | (parse-sexp-ignore-comments t) | 1614 | parse-sexp-ignore-comments |
| 1572 | (lookup-syntax-properties t)) ; XEmacs | 1615 | lookup-syntax-properties) ; XEmacs |
| 1616 | (with-current-buffer buf | ||
| 1573 | (set-syntax-table (make-syntax-table)) | 1617 | (set-syntax-table (make-syntax-table)) |
| 1574 | 1618 | ||
| 1619 | ;; For some reason we have to set some of these after the | ||
| 1620 | ;; buffer has been made current. (Specifically, | ||
| 1621 | ;; `parse-sexp-ignore-comments' in Emacs 21.) | ||
| 1622 | (setq parse-sexp-lookup-properties t | ||
| 1623 | parse-sexp-ignore-comments t | ||
| 1624 | lookup-syntax-properties t) | ||
| 1625 | |||
| 1626 | ;; Find out if the `syntax-table' text property works. | ||
| 1627 | (modify-syntax-entry ?< ".") | ||
| 1628 | (modify-syntax-entry ?> ".") | ||
| 1629 | (insert "<()>") | ||
| 1630 | (c-mark-<-as-paren (point-min)) | ||
| 1631 | (c-mark->-as-paren (+ 3 (point-min))) | ||
| 1632 | (goto-char (point-min)) | ||
| 1633 | (c-forward-sexp) | ||
| 1634 | (if (= (point) (+ 4 (point-min))) | ||
| 1635 | (setq list (cons 'syntax-properties list)) | ||
| 1636 | (error (concat | ||
| 1637 | "CC Mode is incompatible with this version of Emacs - " | ||
| 1638 | "support for the `syntax-table' text property " | ||
| 1639 | "is required."))) | ||
| 1640 | |||
| 1575 | ;; Find out if generic comment delimiters work. | 1641 | ;; Find out if generic comment delimiters work. |
| 1576 | (c-safe | 1642 | (c-safe |
| 1577 | (modify-syntax-entry ?x "!") | 1643 | (modify-syntax-entry ?x "!") |
| @@ -1608,11 +1674,11 @@ non-nil, a caret is prepended to invert the set." | |||
| 1608 | (cond | 1674 | (cond |
| 1609 | ;; XEmacs. Afaik this is currently an Emacs-only | 1675 | ;; XEmacs. Afaik this is currently an Emacs-only |
| 1610 | ;; feature, but it's good to be prepared. | 1676 | ;; feature, but it's good to be prepared. |
| 1611 | ((featurep 'xemacs) | 1677 | ((memq '8-bit list) |
| 1612 | (modify-syntax-entry ?/ ". 1456") | 1678 | (modify-syntax-entry ?/ ". 1456") |
| 1613 | (modify-syntax-entry ?* ". 23")) | 1679 | (modify-syntax-entry ?* ". 23")) |
| 1614 | ;; Emacs | 1680 | ;; Emacs |
| 1615 | (t | 1681 | ((memq '1-bit list) |
| 1616 | (modify-syntax-entry ?/ ". 124b") | 1682 | (modify-syntax-entry ?/ ". 124b") |
| 1617 | (modify-syntax-entry ?* ". 23"))) | 1683 | (modify-syntax-entry ?* ". 23"))) |
| 1618 | (modify-syntax-entry ?\n "> b") | 1684 | (modify-syntax-entry ?\n "> b") |
| @@ -1621,7 +1687,16 @@ non-nil, a caret is prepended to invert the set." | |||
| 1621 | (if (bobp) | 1687 | (if (bobp) |
| 1622 | (setq list (cons 'col-0-paren list))))) | 1688 | (setq list (cons 'col-0-paren list))))) |
| 1623 | 1689 | ||
| 1624 | (set-buffer-modified-p nil))) | 1690 | (set-buffer-modified-p nil)) |
| 1691 | (kill-buffer buf)) | ||
| 1692 | |||
| 1693 | ;; See if `parse-partial-sexp' returns the eighth element. | ||
| 1694 | (if (c-safe (>= (length (save-excursion (parse-partial-sexp (point) (point)))) | ||
| 1695 | 10)) | ||
| 1696 | (setq list (cons 'pps-extended-state list)) | ||
| 1697 | (error (concat | ||
| 1698 | "CC Mode is incompatible with this version of Emacs - " | ||
| 1699 | "`parse-partial-sexp' has to return at least 10 elements."))) | ||
| 1625 | 1700 | ||
| 1626 | ;;(message "c-emacs-features: %S" list) | 1701 | ;;(message "c-emacs-features: %S" list) |
| 1627 | list) | 1702 | list) |
| @@ -1630,16 +1705,29 @@ There are many flavors of Emacs out there, each with different | |||
| 1630 | features supporting those needed by CC Mode. The following values | 1705 | features supporting those needed by CC Mode. The following values |
| 1631 | might be present: | 1706 | might be present: |
| 1632 | 1707 | ||
| 1633 | `argumentative-bod-function' `beginning-of-defun' passes ARG through | 1708 | '8-bit 8 bit syntax entry flags (XEmacs style). |
| 1634 | to a non-null `beginning-of-defun-function.' It is assumed | 1709 | '1-bit 1 bit syntax entry flags (Emacs style). |
| 1635 | that `end-of-defun' does the same thing. | 1710 | 'argumentative-bod-function beginning-of-defun passes ARG through |
| 1636 | `gen-comment-delim' Generic comment delimiters work | 1711 | to a non-null beginning-of-defun-function. It is assumed |
| 1712 | the end-of-defun does the same thing. | ||
| 1713 | 'syntax-properties It works to override the syntax for specific characters | ||
| 1714 | in the buffer with the 'syntax-table property. It's | ||
| 1715 | always set - CC Mode no longer works in emacsen without | ||
| 1716 | this feature. | ||
| 1717 | 'gen-comment-delim Generic comment delimiters work | ||
| 1637 | (i.e. the syntax class `!'). | 1718 | (i.e. the syntax class `!'). |
| 1638 | `gen-string-delim' Generic string delimiters work | 1719 | 'gen-string-delim Generic string delimiters work |
| 1639 | (i.e. the syntax class `|'). | 1720 | (i.e. the syntax class `|'). |
| 1640 | `posix-char-classes' The regexp engine understands POSIX character classes. | 1721 | 'pps-extended-state `parse-partial-sexp' returns a list with at least 10 |
| 1641 | `col-0-paren' It's possible to turn off the ad-hoc rule that a paren | 1722 | elements, i.e. it contains the position of the start of |
| 1642 | in column zero is the start of a defun.") | 1723 | the last comment or string. It's always set - CC Mode |
| 1724 | no longer works in emacsen without this feature. | ||
| 1725 | 'posix-char-classes The regexp engine understands POSIX character classes. | ||
| 1726 | 'col-0-paren It's possible to turn off the ad-hoc rule that a paren | ||
| 1727 | in column zero is the start of a defun. | ||
| 1728 | 'infodock This is Infodock (based on XEmacs). | ||
| 1729 | |||
| 1730 | '8-bit and '1-bit are mutually exclusive.") | ||
| 1643 | 1731 | ||
| 1644 | 1732 | ||
| 1645 | ;;; Some helper constants. | 1733 | ;;; Some helper constants. |
| @@ -1935,6 +2023,11 @@ LANG is the name of the language, i.e. the mode name without the | |||
| 1935 | language. NAME and LANG are not evaluated so they should not be | 2023 | language. NAME and LANG are not evaluated so they should not be |
| 1936 | quoted." | 2024 | quoted." |
| 1937 | 2025 | ||
| 2026 | (or (symbolp name) | ||
| 2027 | (error "Not a symbol: %S" name)) | ||
| 2028 | (or (symbolp lang) | ||
| 2029 | (error "Not a symbol: %S" lang)) | ||
| 2030 | |||
| 1938 | (let ((sym (intern (symbol-name name) c-lang-constants)) | 2031 | (let ((sym (intern (symbol-name name) c-lang-constants)) |
| 1939 | (mode (when lang (intern (concat (symbol-name lang) "-mode"))))) | 2032 | (mode (when lang (intern (concat (symbol-name lang) "-mode"))))) |
| 1940 | 2033 | ||
| @@ -2095,56 +2188,57 @@ fallback definition for all modes, to break the cycle).") | |||
| 2095 | value)))) | 2188 | value)))) |
| 2096 | 2189 | ||
| 2097 | (defun c-find-assignment-for-mode (source-pos mode match-any-lang _name) | 2190 | (defun c-find-assignment-for-mode (source-pos mode match-any-lang _name) |
| 2098 | "Find the first assignment entry that applies to MODE at or after | 2191 | ;; Find the first assignment entry that applies to MODE at or after |
| 2099 | SOURCE-POS. If MATCH-ANY-LANG is non-nil, entries with `t' as | 2192 | ;; SOURCE-POS. If MATCH-ANY-LANG is non-nil, entries with `t' as |
| 2100 | the language list are considered to match, otherwise they don't. | 2193 | ;; the language list are considered to match, otherwise they don't. |
| 2101 | On return SOURCE-POS is updated to point to the next assignment | 2194 | ;; On return SOURCE-POS is updated to point to the next assignment |
| 2102 | after the returned one. If no assignment is found, | 2195 | ;; after the returned one. If no assignment is found, |
| 2103 | `c-lang--novalue' is returned as a magic value. | 2196 | ;; `c-lang--novalue' is returned as a magic value. |
| 2104 | 2197 | ;; | |
| 2105 | SOURCE-POS is a vector that points out a specific assignment in | 2198 | ;; SOURCE-POS is a vector that points out a specific assignment in |
| 2106 | the double alist that's used in the `source' property. The first | 2199 | ;; the double alist that's used in the `source' property. The first |
| 2107 | element is the position in the top alist which is indexed with | 2200 | ;; element is the position in the top alist which is indexed with |
| 2108 | the source files, and the second element is the position in the | 2201 | ;; the source files, and the second element is the position in the |
| 2109 | nested bindings alist. | 2202 | ;; nested bindings alist. |
| 2110 | 2203 | ;; | |
| 2111 | NAME is only used for error messages." | 2204 | ;; NAME is only used for error messages. |
| 2112 | 2205 | ||
| 2113 | (catch 'found | 2206 | (catch 'found |
| 2114 | (let ((file-entry (elt source-pos 0)) | 2207 | (let ((file-entry (elt source-pos 0)) |
| 2115 | (assignment-entry (elt source-pos 1)) | 2208 | (assignment-entry (elt source-pos 1)) |
| 2116 | assignment) | 2209 | assignment) |
| 2117 | 2210 | ||
| 2118 | (while (or assignment-entry | 2211 | (while (if assignment-entry |
| 2119 | ;; Handled the last assignment from one file, begin on the | 2212 | t |
| 2120 | ;; next. Due to the check in `c-lang-defconst', we know | 2213 | ;; Handled the last assignment from one file, begin on the |
| 2121 | ;; there's at least one. | 2214 | ;; next. Due to the check in `c-lang-defconst', we know |
| 2122 | (when file-entry | 2215 | ;; there's at least one. |
| 2123 | 2216 | (when file-entry | |
| 2124 | (unless (aset source-pos 1 | 2217 | |
| 2125 | (setq assignment-entry (cdar file-entry))) | 2218 | (unless (aset source-pos 1 |
| 2126 | ;; The file containing the source definitions has not | 2219 | (setq assignment-entry (cdar file-entry))) |
| 2127 | ;; been loaded. | 2220 | ;; The file containing the source definitions has not |
| 2128 | (let ((file (symbol-name (caar file-entry))) | 2221 | ;; been loaded. |
| 2129 | (c-lang-constants-under-evaluation nil)) | 2222 | (let ((file (symbol-name (caar file-entry))) |
| 2130 | ;;(message (concat "Loading %s to get the source " | 2223 | (c-lang-constants-under-evaluation nil)) |
| 2131 | ;; "value for language constant %s") | 2224 | ;;(message (concat "Loading %s to get the source " |
| 2132 | ;; file name) | 2225 | ;; "value for language constant %s") |
| 2133 | (load file nil t)) | 2226 | ;; file name) |
| 2134 | 2227 | (load file nil t)) | |
| 2135 | (unless (setq assignment-entry (cdar file-entry)) | 2228 | |
| 2136 | ;; The load didn't fill in the source for the | 2229 | (unless (setq assignment-entry (cdar file-entry)) |
| 2137 | ;; constant as expected. The situation is | 2230 | ;; The load didn't fill in the source for the |
| 2138 | ;; probably that a derived mode was written for | 2231 | ;; constant as expected. The situation is |
| 2139 | ;; and compiled with another version of CC Mode, | 2232 | ;; probably that a derived mode was written for |
| 2140 | ;; and the requested constant isn't in the | 2233 | ;; and compiled with another version of CC Mode, |
| 2141 | ;; currently loaded one. Put in a dummy | 2234 | ;; and the requested constant isn't in the |
| 2142 | ;; assignment that matches no language. | 2235 | ;; currently loaded one. Put in a dummy |
| 2143 | (setcdr (car file-entry) | 2236 | ;; assignment that matches no language. |
| 2144 | (setq assignment-entry (list (list nil)))))) | 2237 | (setcdr (car file-entry) |
| 2145 | 2238 | (setq assignment-entry (list (list nil)))))) | |
| 2146 | (aset source-pos 0 (setq file-entry (cdr file-entry))) | 2239 | |
| 2147 | t)) | 2240 | (aset source-pos 0 (setq file-entry (cdr file-entry))) |
| 2241 | t)) | ||
| 2148 | 2242 | ||
| 2149 | (setq assignment (car assignment-entry)) | 2243 | (setq assignment (car assignment-entry)) |
| 2150 | (aset source-pos 1 | 2244 | (aset source-pos 1 |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index ce7797b411a..9eb95f69c48 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -2222,8 +2222,6 @@ comment at the start of cc-engine.el for more info." | |||
| 2222 | ((and (not not-in-delimiter) ; inside a comment starter | 2222 | ((and (not not-in-delimiter) ; inside a comment starter |
| 2223 | (not (bobp)) | 2223 | (not (bobp)) |
| 2224 | (progn (backward-char) | 2224 | (progn (backward-char) |
| 2225 | ;; FIXME: We never add category-properties to | ||
| 2226 | ;; c-emacs-features! | ||
| 2227 | (and (not (and (memq 'category-properties c-emacs-features) | 2225 | (and (not (and (memq 'category-properties c-emacs-features) |
| 2228 | (looking-at "\\s!"))) | 2226 | (looking-at "\\s!"))) |
| 2229 | (looking-at c-comment-start-regexp)))) | 2227 | (looking-at c-comment-start-regexp)))) |
| @@ -4121,10 +4119,10 @@ comment at the start of cc-engine.el for more info." | |||
| 4121 | (c-end-of-current-token last-token-end-pos)) | 4119 | (c-end-of-current-token last-token-end-pos)) |
| 4122 | (setq last-token-end-pos (point)))))) | 4120 | (setq last-token-end-pos (point)))))) |
| 4123 | ;; Inside a token. | 4121 | ;; Inside a token. |
| 4124 | (goto-char (if lookbehind-submatch | 4122 | (if lookbehind-submatch |
| 4125 | ;; See the NOTE above. | 4123 | ;; See the NOTE above. |
| 4126 | state-pos | 4124 | (goto-char state-pos) |
| 4127 | (min last-token-end-pos bound)))) | 4125 | (goto-char (min last-token-end-pos bound)))) |
| 4128 | 4126 | ||
| 4129 | (t | 4127 | (t |
| 4130 | ;; A real match. | 4128 | ;; A real match. |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 329e274e912..c056091ca46 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -201,18 +201,17 @@ | |||
| 201 | :version "24.1" | 201 | :version "24.1" |
| 202 | :group 'c) | 202 | :group 'c) |
| 203 | 203 | ||
| 204 | ;; This indicates the "font locking context", and is set just before | ||
| 205 | ;; fontification is done. If non-nil, it says, e.g., point starts | ||
| 206 | ;; from within a #if preprocessor construct. | ||
| 207 | (defvar c-font-lock-context nil) | ||
| 208 | (make-variable-buffer-local 'c-font-lock-context) | ||
| 209 | (cc-bytecomp-defvar c-font-lock-context) | ||
| 210 | |||
| 211 | (eval-and-compile | 204 | (eval-and-compile |
| 212 | ;; We need the following definitions during compilation since they're | 205 | ;; We need the following definitions during compilation since they're |
| 213 | ;; used when the `c-lang-defconst' initializers are evaluated. Define | 206 | ;; used when the `c-lang-defconst' initializers are evaluated. Define |
| 214 | ;; them at runtime too for the sake of derived modes. | 207 | ;; them at runtime too for the sake of derived modes. |
| 215 | 208 | ||
| 209 | ;; This indicates the "font locking context", and is set just before | ||
| 210 | ;; fontification is done. If non-nil, it says, e.g., point starts | ||
| 211 | ;; from within a #if preprocessor construct. | ||
| 212 | (defvar c-font-lock-context nil) | ||
| 213 | (make-variable-buffer-local 'c-font-lock-context) | ||
| 214 | |||
| 216 | (defmacro c-put-font-lock-face (from to face) | 215 | (defmacro c-put-font-lock-face (from to face) |
| 217 | ;; Put a face on a region (overriding any existing face) in the way | 216 | ;; Put a face on a region (overriding any existing face) in the way |
| 218 | ;; font-lock would do it. In XEmacs that means putting an | 217 | ;; font-lock would do it. In XEmacs that means putting an |
| @@ -273,29 +272,18 @@ | |||
| 273 | (c-got-face-at (point) c-literal-faces)))) | 272 | (c-got-face-at (point) c-literal-faces)))) |
| 274 | t)) | 273 | t)) |
| 275 | 274 | ||
| 276 | (defvar c-font-byte-compile t | ||
| 277 | "If non-nil, byte-compile the dynamically-generated functions.") | ||
| 278 | |||
| 279 | (defun c--compile (exp) | ||
| 280 | (cond | ||
| 281 | ((byte-code-function-p exp) (error "Already byte-compiled: %S" exp)) | ||
| 282 | ((not (eq (car-safe exp) 'lambda)) | ||
| 283 | (error "Expected a (lambda ..): %S" exp)) | ||
| 284 | (c-font-byte-compile (byte-compile exp)) | ||
| 285 | (t (eval (macroexpand-all exp))))) | ||
| 286 | |||
| 287 | (defun c-make-syntactic-matcher (regexp) | 275 | (defun c-make-syntactic-matcher (regexp) |
| 288 | "Return a function suitable for use in place of a | 276 | ;; Returns a byte compiled function suitable for use in place of a |
| 289 | regexp string in a `font-lock-keywords' matcher, except that | 277 | ;; regexp string in a `font-lock-keywords' matcher, except that |
| 290 | only matches outside comments and string literals count. | 278 | ;; only matches outside comments and string literals count. |
| 291 | 279 | ;; | |
| 292 | This function does not do any hidden buffer changes, but the | 280 | ;; This function does not do any hidden buffer changes, but the |
| 293 | generated functions will. (They are however used in places | 281 | ;; generated functions will. (They are however used in places |
| 294 | covered by the font-lock context.)" | 282 | ;; covered by the font-lock context.) |
| 295 | (c--compile | 283 | (byte-compile |
| 296 | `(lambda (limit) | 284 | `(lambda (limit) |
| 297 | (let (res) | 285 | (let (res) |
| 298 | (while (and (setq res (re-search-forward ,regexp limit t)) | 286 | (while (and (setq res (re-search-forward ,regexp limit t)) |
| 299 | (progn | 287 | (progn |
| 300 | (goto-char (match-beginning 0)) | 288 | (goto-char (match-beginning 0)) |
| 301 | (or (c-skip-comments-and-strings limit) | 289 | (or (c-skip-comments-and-strings limit) |
| @@ -344,34 +332,34 @@ covered by the font-lock context.)" | |||
| 344 | highlights)))) | 332 | highlights)))) |
| 345 | 333 | ||
| 346 | (defun c-make-font-lock-search-function (regexp &rest highlights) | 334 | (defun c-make-font-lock-search-function (regexp &rest highlights) |
| 347 | "This function makes a byte compiled function that works much like | 335 | ;; This function makes a byte compiled function that works much like |
| 348 | a matcher element in `font-lock-keywords'. It cuts out a little | 336 | ;; a matcher element in `font-lock-keywords'. It cuts out a little |
| 349 | bit of the overhead compared to a real matcher. The main reason | 337 | ;; bit of the overhead compared to a real matcher. The main reason |
| 350 | is however to pass the real search limit to the anchored | 338 | ;; is however to pass the real search limit to the anchored |
| 351 | matcher(s), since most (if not all) font-lock implementations | 339 | ;; matcher(s), since most (if not all) font-lock implementations |
| 352 | arbitrarily limit anchored matchers to the same line, and also | 340 | ;; arbitrarily limit anchored matchers to the same line, and also |
| 353 | to insulate against various other irritating differences between | 341 | ;; to insulate against various other irritating differences between |
| 354 | the different (X)Emacs font-lock packages. | 342 | ;; the different (X)Emacs font-lock packages. |
| 355 | 343 | ;; | |
| 356 | REGEXP is the matcher, which must be a regexp. Only matches | 344 | ;; REGEXP is the matcher, which must be a regexp. Only matches |
| 357 | where the beginning is outside any comment or string literal are | 345 | ;; where the beginning is outside any comment or string literal are |
| 358 | significant. | 346 | ;; significant. |
| 359 | 347 | ;; | |
| 360 | HIGHLIGHTS is a list of highlight specs, just like in | 348 | ;; HIGHLIGHTS is a list of highlight specs, just like in |
| 361 | `font-lock-keywords', with these limitations: The face is always | 349 | ;; `font-lock-keywords', with these limitations: The face is always |
| 362 | overridden (no big disadvantage, since hits in comments etc are | 350 | ;; overridden (no big disadvantage, since hits in comments etc are |
| 363 | filtered anyway), there is no \"laxmatch\", and an anchored matcher | 351 | ;; filtered anyway), there is no "laxmatch", and an anchored matcher |
| 364 | is always a form which must do all the fontification directly. | 352 | ;; is always a form which must do all the fontification directly. |
| 365 | `limit' is a variable bound to the real limit in the context of | 353 | ;; `limit' is a variable bound to the real limit in the context of |
| 366 | the anchored matcher forms. | 354 | ;; the anchored matcher forms. |
| 367 | 355 | ;; | |
| 368 | This function does not do any hidden buffer changes, but the | 356 | ;; This function does not do any hidden buffer changes, but the |
| 369 | generated functions will. (They are however used in places | 357 | ;; generated functions will. (They are however used in places |
| 370 | covered by the font-lock context.)" | 358 | ;; covered by the font-lock context.) |
| 371 | 359 | ||
| 372 | ;; Note: Set c-font-byte-compile to nil to debug the generated | 360 | ;; Note: Replace `byte-compile' with `eval' to debug the generated |
| 373 | ;; lambda more easily. | 361 | ;; lambda more easily. |
| 374 | (c--compile | 362 | (byte-compile |
| 375 | `(lambda (limit) | 363 | `(lambda (limit) |
| 376 | (let ( ;; The font-lock package in Emacs is known to clobber | 364 | (let ( ;; The font-lock package in Emacs is known to clobber |
| 377 | ;; `parse-sexp-lookup-properties' (when it exists). | 365 | ;; `parse-sexp-lookup-properties' (when it exists). |
| @@ -414,44 +402,44 @@ covered by the font-lock context.)" | |||
| 414 | nil))) | 402 | nil))) |
| 415 | 403 | ||
| 416 | (defun c-make-font-lock-BO-decl-search-function (regexp &rest highlights) | 404 | (defun c-make-font-lock-BO-decl-search-function (regexp &rest highlights) |
| 417 | "This function makes a byte compiled function that first moves back | 405 | ;; This function makes a byte compiled function that first moves back |
| 418 | to the beginning of the current declaration (if any), then searches | 406 | ;; to the beginning of the current declaration (if any), then searches |
| 419 | forward for matcher elements (as in `font-lock-keywords') and | 407 | ;; forward for matcher elements (as in `font-lock-keywords') and |
| 420 | fontifies them. | 408 | ;; fontifies them. |
| 421 | 409 | ;; | |
| 422 | The motivation for moving back to the declaration start is to | 410 | ;; The motivation for moving back to the declaration start is to |
| 423 | establish a context for the current text when, e.g., a character | 411 | ;; establish a context for the current text when, e.g., a character |
| 424 | is typed on a C++ inheritance continuation line, or a jit-lock | 412 | ;; is typed on a C++ inheritance continuation line, or a jit-lock |
| 425 | chunk starts there. | 413 | ;; chunk starts there. |
| 426 | 414 | ;; | |
| 427 | The new function works much like a matcher element in | 415 | ;; The new function works much like a matcher element in |
| 428 | `font-lock-keywords'. It cuts out a little bit of the overhead | 416 | ;; `font-lock-keywords'. It cuts out a little bit of the overhead |
| 429 | compared to a real matcher. The main reason is however to pass the | 417 | ;; compared to a real matcher. The main reason is however to pass the |
| 430 | real search limit to the anchored matcher(s), since most (if not | 418 | ;; real search limit to the anchored matcher(s), since most (if not |
| 431 | all) font-lock implementations arbitrarily limit anchored matchers | 419 | ;; all) font-lock implementations arbitrarily limit anchored matchers |
| 432 | to the same line, and also to insulate against various other | 420 | ;; to the same line, and also to insulate against various other |
| 433 | irritating differences between the different (X)Emacs font-lock | 421 | ;; irritating differences between the different (X)Emacs font-lock |
| 434 | packages. | 422 | ;; packages. |
| 435 | 423 | ;; | |
| 436 | REGEXP is the matcher, which must be a regexp. Only matches | 424 | ;; REGEXP is the matcher, which must be a regexp. Only matches |
| 437 | where the beginning is outside any comment or string literal are | 425 | ;; where the beginning is outside any comment or string literal are |
| 438 | significant. | 426 | ;; significant. |
| 439 | 427 | ;; | |
| 440 | HIGHLIGHTS is a list of highlight specs, just like in | 428 | ;; HIGHLIGHTS is a list of highlight specs, just like in |
| 441 | `font-lock-keywords', with these limitations: The face is always | 429 | ;; `font-lock-keywords', with these limitations: The face is always |
| 442 | overridden (no big disadvantage, since hits in comments etc are | 430 | ;; overridden (no big disadvantage, since hits in comments etc are |
| 443 | filtered anyway), there is no \"laxmatch\", and an anchored matcher | 431 | ;; filtered anyway), there is no "laxmatch", and an anchored matcher |
| 444 | is always a form which must do all the fontification directly. | 432 | ;; is always a form which must do all the fontification directly. |
| 445 | `limit' is a variable bound to the real limit in the context of | 433 | ;; `limit' is a variable bound to the real limit in the context of |
| 446 | the anchored matcher forms. | 434 | ;; the anchored matcher forms. |
| 447 | 435 | ;; | |
| 448 | This function does not do any hidden buffer changes, but the | 436 | ;; This function does not do any hidden buffer changes, but the |
| 449 | generated functions will. (They are however used in places | 437 | ;; generated functions will. (They are however used in places |
| 450 | covered by the font-lock context.)" | 438 | ;; covered by the font-lock context.) |
| 451 | 439 | ||
| 452 | ;; Note: Set c-font-byte-compile to nil to debug the generated | 440 | ;; Note: Replace `byte-compile' with `eval' to debug the generated |
| 453 | ;; lambda more easily. | 441 | ;; lambda more easily. |
| 454 | (c--compile | 442 | (byte-compile |
| 455 | `(lambda (limit) | 443 | `(lambda (limit) |
| 456 | (let ( ;; The font-lock package in Emacs is known to clobber | 444 | (let ( ;; The font-lock package in Emacs is known to clobber |
| 457 | ;; `parse-sexp-lookup-properties' (when it exists). | 445 | ;; `parse-sexp-lookup-properties' (when it exists). |
| @@ -469,40 +457,40 @@ covered by the font-lock context.)" | |||
| 469 | nil))) | 457 | nil))) |
| 470 | 458 | ||
| 471 | (defun c-make-font-lock-context-search-function (normal &rest state-stanzas) | 459 | (defun c-make-font-lock-context-search-function (normal &rest state-stanzas) |
| 472 | "This function makes a byte compiled function that works much like | 460 | ;; This function makes a byte compiled function that works much like |
| 473 | a matcher element in `font-lock-keywords', with the following | 461 | ;; a matcher element in `font-lock-keywords', with the following |
| 474 | enhancement: the generated function will test for particular \"font | 462 | ;; enhancement: the generated function will test for particular "font |
| 475 | lock contexts\" at the start of the region, i.e. is this point in | 463 | ;; lock contexts" at the start of the region, i.e. is this point in |
| 476 | the middle of some particular construct? if so the generated | 464 | ;; the middle of some particular construct? if so the generated |
| 477 | function will first fontify the tail of the construct, before | 465 | ;; function will first fontify the tail of the construct, before |
| 478 | going into the main loop and fontify full constructs up to limit. | 466 | ;; going into the main loop and fontify full constructs up to limit. |
| 479 | 467 | ;; | |
| 480 | The generated function takes one parameter called `limit', and | 468 | ;; The generated function takes one parameter called `limit', and |
| 481 | will fontify the region between POINT and LIMIT. | 469 | ;; will fontify the region between POINT and LIMIT. |
| 482 | 470 | ;; | |
| 483 | NORMAL is a list of the form (REGEXP HIGHLIGHTS .....), and is | 471 | ;; NORMAL is a list of the form (REGEXP HIGHLIGHTS .....), and is |
| 484 | used to fontify the \"regular\" bit of the region. | 472 | ;; used to fontify the "regular" bit of the region. |
| 485 | STATE-STANZAS is list of elements of the form (STATE LIM REGEXP | 473 | ;; STATE-STANZAS is list of elements of the form (STATE LIM REGEXP |
| 486 | HIGHLIGHTS), each element coding one possible font lock context. | 474 | ;; HIGHLIGHTS), each element coding one possible font lock context. |
| 487 | 475 | ||
| 488 | o - REGEXP is a font-lock regular expression (NOT a function), | 476 | ;; o - REGEXP is a font-lock regular expression (NOT a function), |
| 489 | o - HIGHLIGHTS is a list of zero or more highlighters as defined | 477 | ;; o - HIGHLIGHTS is a list of zero or more highlighters as defined |
| 490 | on page \"Search-based Fontification\" in the elisp manual. As | 478 | ;; on page "Search-based Fontification" in the elisp manual. As |
| 491 | yet (2009-06), they must have OVERRIDE set, and may not have | 479 | ;; yet (2009-06), they must have OVERRIDE set, and may not have |
| 492 | LAXMATCH set. | 480 | ;; LAXMATCH set. |
| 493 | 481 | ;; | |
| 494 | o - STATE is the \"font lock context\" (e.g. in-cpp-expr) and is | 482 | ;; o - STATE is the "font lock context" (e.g. in-cpp-expr) and is |
| 495 | not quoted. | 483 | ;; not quoted. |
| 496 | o - LIM is a lisp form whose evaluation will yield the limit | 484 | ;; o - LIM is a lisp form whose evaluation will yield the limit |
| 497 | position in the buffer for fontification by this stanza. | 485 | ;; position in the buffer for fontification by this stanza. |
| 498 | 486 | ;; | |
| 499 | This function does not do any hidden buffer changes, but the | 487 | ;; This function does not do any hidden buffer changes, but the |
| 500 | generated functions will. (They are however used in places | 488 | ;; generated functions will. (They are however used in places |
| 501 | covered by the font-lock context.)" | 489 | ;; covered by the font-lock context.) |
| 502 | 490 | ;; | |
| 503 | ;; Note: Set c-font-byte-compile to nil to debug the generated | 491 | ;; Note: Replace `byte-compile' with `eval' to debug the generated |
| 504 | ;; lambda more easily. | 492 | ;; lambda more easily. |
| 505 | (c--compile | 493 | (byte-compile |
| 506 | `(lambda (limit) | 494 | `(lambda (limit) |
| 507 | (let ( ;; The font-lock package in Emacs is known to clobber | 495 | (let ( ;; The font-lock package in Emacs is known to clobber |
| 508 | ;; `parse-sexp-lookup-properties' (when it exists). | 496 | ;; `parse-sexp-lookup-properties' (when it exists). |
| @@ -534,10 +522,10 @@ covered by the font-lock context.)" | |||
| 534 | (form &rest &or ("quote" (&rest form)) ("`" (&rest form)) form)));)) | 522 | (form &rest &or ("quote" (&rest form)) ("`" (&rest form)) form)));)) |
| 535 | 523 | ||
| 536 | (defun c-fontify-recorded-types-and-refs () | 524 | (defun c-fontify-recorded-types-and-refs () |
| 537 | "Convert the ranges recorded on `c-record-type-identifiers' and | 525 | ;; Convert the ranges recorded on `c-record-type-identifiers' and |
| 538 | `c-record-ref-identifiers' to fontification. | 526 | ;; `c-record-ref-identifiers' to fontification. |
| 539 | 527 | ;; | |
| 540 | This function does hidden buffer changes." | 528 | ;; This function does hidden buffer changes. |
| 541 | (let (elem) | 529 | (let (elem) |
| 542 | (while (consp c-record-type-identifiers) | 530 | (while (consp c-record-type-identifiers) |
| 543 | (setq elem (car c-record-type-identifiers) | 531 | (setq elem (car c-record-type-identifiers) |
| @@ -593,7 +581,7 @@ stuff. Used on level 1 and higher." | |||
| 593 | 581 | ||
| 594 | ;; Use an anchored matcher to put paren syntax | 582 | ;; Use an anchored matcher to put paren syntax |
| 595 | ;; on the brackets. | 583 | ;; on the brackets. |
| 596 | (,(c--compile | 584 | (,(byte-compile |
| 597 | `(lambda (limit) | 585 | `(lambda (limit) |
| 598 | (let ((beg (match-beginning | 586 | (let ((beg (match-beginning |
| 599 | ,(+ ncle-depth re-depth sws-depth 1))) | 587 | ,(+ ncle-depth re-depth sws-depth 1))) |
| @@ -695,10 +683,10 @@ stuff. Used on level 1 and higher." | |||
| 695 | "\\)") | 683 | "\\)") |
| 696 | `(,(1+ ncle-depth) c-preprocessor-face-name t))) | 684 | `(,(1+ ncle-depth) c-preprocessor-face-name t))) |
| 697 | 685 | ||
| 698 | (eval . (list ',(c-make-syntactic-matcher | 686 | (eval . (list ,(c-make-syntactic-matcher |
| 699 | (concat noncontinued-line-end | 687 | (concat noncontinued-line-end |
| 700 | (c-lang-const c-opt-cpp-prefix) | 688 | (c-lang-const c-opt-cpp-prefix) |
| 701 | "if\\(n\\)def\\>")) | 689 | "if\\(n\\)def\\>")) |
| 702 | ,(+ ncle-depth 1) | 690 | ,(+ ncle-depth 1) |
| 703 | c-negation-char-face-name | 691 | c-negation-char-face-name |
| 704 | 'append)) | 692 | 'append)) |
| @@ -757,11 +745,11 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 757 | ;; this, but it doesn't give the control we want since any | 745 | ;; this, but it doesn't give the control we want since any |
| 758 | ;; fontification done inside the function will be | 746 | ;; fontification done inside the function will be |
| 759 | ;; unconditionally overridden. | 747 | ;; unconditionally overridden. |
| 760 | (,(c-make-font-lock-search-function | 748 | ,(c-make-font-lock-search-function |
| 761 | ;; Match a char before the string starter to make | 749 | ;; Match a char before the string starter to make |
| 762 | ;; `c-skip-comments-and-strings' work correctly. | 750 | ;; `c-skip-comments-and-strings' work correctly. |
| 763 | (concat ".\\(" c-string-limit-regexp "\\)") | 751 | (concat ".\\(" c-string-limit-regexp "\\)") |
| 764 | '((c-font-lock-invalid-string)))) | 752 | '((c-font-lock-invalid-string))) |
| 765 | 753 | ||
| 766 | ;; Fontify keyword constants. | 754 | ;; Fontify keyword constants. |
| 767 | ,@(when (c-lang-const c-constant-kwds) | 755 | ,@(when (c-lang-const c-constant-kwds) |
| @@ -813,8 +801,7 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 813 | (c-backward-syntactic-ws) | 801 | (c-backward-syntactic-ws) |
| 814 | (setq id-end (point)) | 802 | (setq id-end (point)) |
| 815 | (< (skip-chars-backward | 803 | (< (skip-chars-backward |
| 816 | ,(c-lang-const c-symbol-chars)) | 804 | ,(c-lang-const c-symbol-chars)) 0)) |
| 817 | 0)) | ||
| 818 | (not (get-text-property (point) 'face))) | 805 | (not (get-text-property (point) 'face))) |
| 819 | (c-put-font-lock-face (point) id-end | 806 | (c-put-font-lock-face (point) id-end |
| 820 | c-reference-face-name) | 807 | c-reference-face-name) |
| @@ -822,7 +809,7 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 822 | nil | 809 | nil |
| 823 | (goto-char (match-end 0))))) | 810 | (goto-char (match-end 0))))) |
| 824 | 811 | ||
| 825 | `((,(c--compile | 812 | `((,(byte-compile |
| 826 | ;; Must use a function here since we match longer than | 813 | ;; Must use a function here since we match longer than |
| 827 | ;; we want to move before doing a new search. This is | 814 | ;; we want to move before doing a new search. This is |
| 828 | ;; not necessary for XEmacs since it restarts the | 815 | ;; not necessary for XEmacs since it restarts the |
| @@ -1577,7 +1564,9 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1577 | ;; Note that this function won't attempt to fontify beyond the end of the | 1564 | ;; Note that this function won't attempt to fontify beyond the end of the |
| 1578 | ;; current enum block, if any. | 1565 | ;; current enum block, if any. |
| 1579 | (let* ((paren-state (c-parse-state)) | 1566 | (let* ((paren-state (c-parse-state)) |
| 1580 | (encl-pos (c-most-enclosing-brace paren-state))) | 1567 | (encl-pos (c-most-enclosing-brace paren-state)) |
| 1568 | (start (point)) | ||
| 1569 | ) | ||
| 1581 | (when (and | 1570 | (when (and |
| 1582 | encl-pos | 1571 | encl-pos |
| 1583 | (eq (char-after encl-pos) ?\{) | 1572 | (eq (char-after encl-pos) ?\{) |
| @@ -1628,16 +1617,17 @@ on level 2 only and so aren't combined with `c-complex-decl-matchers'." | |||
| 1628 | t `(;; Objective-C methods. | 1617 | t `(;; Objective-C methods. |
| 1629 | ,@(when (c-major-mode-is 'objc-mode) | 1618 | ,@(when (c-major-mode-is 'objc-mode) |
| 1630 | `((,(c-lang-const c-opt-method-key) | 1619 | `((,(c-lang-const c-opt-method-key) |
| 1631 | (,(lambda (limit) | 1620 | (,(byte-compile |
| 1632 | (let (;; The font-lock package in Emacs is known to clobber | 1621 | (lambda (limit) |
| 1633 | ;; `parse-sexp-lookup-properties' (when it exists). | 1622 | (let (;; The font-lock package in Emacs is known to clobber |
| 1634 | (parse-sexp-lookup-properties | 1623 | ;; `parse-sexp-lookup-properties' (when it exists). |
| 1635 | (cc-eval-when-compile | 1624 | (parse-sexp-lookup-properties |
| 1636 | (boundp 'parse-sexp-lookup-properties)))) | 1625 | (cc-eval-when-compile |
| 1637 | (save-restriction | 1626 | (boundp 'parse-sexp-lookup-properties)))) |
| 1638 | (narrow-to-region (point-min) limit) | 1627 | (save-restriction |
| 1639 | (c-font-lock-objc-method))) | 1628 | (narrow-to-region (point-min) limit) |
| 1640 | nil) | 1629 | (c-font-lock-objc-method))) |
| 1630 | nil)) | ||
| 1641 | (goto-char (match-end 1)))))) | 1631 | (goto-char (match-end 1)))))) |
| 1642 | 1632 | ||
| 1643 | ;; Fontify all type names and the identifiers in the | 1633 | ;; Fontify all type names and the identifiers in the |
| @@ -1752,7 +1742,7 @@ on level 2 only and so aren't combined with `c-complex-decl-matchers'." | |||
| 1752 | 1742 | ||
| 1753 | ;; Fontify types preceded by `c-type-prefix-kwds' (e.g. "struct"). | 1743 | ;; Fontify types preceded by `c-type-prefix-kwds' (e.g. "struct"). |
| 1754 | ,@(when (c-lang-const c-type-prefix-kwds) | 1744 | ,@(when (c-lang-const c-type-prefix-kwds) |
| 1755 | `((,(c--compile | 1745 | `((,(byte-compile |
| 1756 | `(lambda (limit) | 1746 | `(lambda (limit) |
| 1757 | (c-fontify-types-and-refs | 1747 | (c-fontify-types-and-refs |
| 1758 | ((c-promote-possible-types t) | 1748 | ((c-promote-possible-types t) |
| @@ -2305,7 +2295,7 @@ need for `c++-font-lock-extra-types'.") | |||
| 2305 | limit | 2295 | limit |
| 2306 | "[-+]" | 2296 | "[-+]" |
| 2307 | nil | 2297 | nil |
| 2308 | (lambda (_match-pos _inside-macro) | 2298 | (lambda (match-pos inside-macro) |
| 2309 | (forward-char) | 2299 | (forward-char) |
| 2310 | (c-font-lock-objc-method)))) | 2300 | (c-font-lock-objc-method)))) |
| 2311 | nil) | 2301 | nil) |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index daecc45c008..bc3fb66d3e1 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -153,8 +153,8 @@ | |||
| 153 | c-emacs-variable-inits-tail c-emacs-variable-inits)) | 153 | c-emacs-variable-inits-tail c-emacs-variable-inits)) |
| 154 | 154 | ||
| 155 | (defmacro c-lang-defvar (var val &optional doc) | 155 | (defmacro c-lang-defvar (var val &optional doc) |
| 156 | "Declare the buffer local variable VAR to get the value VAL. | 156 | "Declares the buffer local variable VAR to get the value VAL. VAL is |
| 157 | VAL is evaluated and assigned at mode initialization. More precisely, VAL is | 157 | evaluated and assigned at mode initialization. More precisely, VAL is |
| 158 | evaluated and bound to VAR when the result from the macro | 158 | evaluated and bound to VAR when the result from the macro |
| 159 | `c-init-language-vars' is evaluated. | 159 | `c-init-language-vars' is evaluated. |
| 160 | 160 | ||
| @@ -218,54 +218,55 @@ the evaluated constant value at compile time." | |||
| 218 | ;; Some helper functions used when building the language constants. | 218 | ;; Some helper functions used when building the language constants. |
| 219 | 219 | ||
| 220 | (defun c-filter-ops (ops opgroup-filter op-filter &optional xlate) | 220 | (defun c-filter-ops (ops opgroup-filter op-filter &optional xlate) |
| 221 | "Extract a subset of the operators in the list OPS in a DWIM:ey way. | 221 | ;; Extract a subset of the operators in the list OPS in a DWIM:ey |
| 222 | The return value is a plain list of operators: | 222 | ;; way. The return value is a plain list of operators: |
| 223 | 223 | ;; | |
| 224 | OPS either has the structure of `c-operators', is a single | 224 | ;; OPS either has the structure of `c-operators', is a single |
| 225 | group in `c-operators', or is a plain list of operators. | 225 | ;; group in `c-operators', or is a plain list of operators. |
| 226 | 226 | ;; | |
| 227 | OPGROUP-FILTER specifies how to select the operator groups. It | 227 | ;; OPGROUP-FILTER specifies how to select the operator groups. It |
| 228 | can be t to choose all groups, a list of group type symbols | 228 | ;; can be t to choose all groups, a list of group type symbols |
| 229 | \(such as 'prefix) to accept, or a function which will be called | 229 | ;; (such as 'prefix) to accept, or a function which will be called |
| 230 | with the group symbol for each group and should return non-nil | 230 | ;; with the group symbol for each group and should return non-nil |
| 231 | if that group is to be included. | 231 | ;; if that group is to be included. |
| 232 | 232 | ;; | |
| 233 | If XLATE is given, it's a function which is called for each | 233 | ;; If XLATE is given, it's a function which is called for each |
| 234 | matching operator and its return value is collected instead. | 234 | ;; matching operator and its return value is collected instead. |
| 235 | If it returns a list, the elements are spliced directly into | 235 | ;; If it returns a list, the elements are spliced directly into |
| 236 | the final result, which is returned as a list with duplicates | 236 | ;; the final result, which is returned as a list with duplicates |
| 237 | removed using `equal'. | 237 | ;; removed using `equal'. |
| 238 | 238 | ;; | |
| 239 | `c-mode-syntax-table' for the current mode is in effect during | 239 | ;; `c-mode-syntax-table' for the current mode is in effect during |
| 240 | the whole procedure." | 240 | ;; the whole procedure. |
| 241 | (unless (listp (car-safe ops)) | 241 | (unless (listp (car-safe ops)) |
| 242 | (setq ops (list ops))) | 242 | (setq ops (list ops))) |
| 243 | (let ((opgroup-filter | 243 | (cond ((eq opgroup-filter t) |
| 244 | (cond ((eq opgroup-filter t) (lambda (opgroup) t)) | 244 | (setq opgroup-filter (lambda (opgroup) t))) |
| 245 | ((not (functionp opgroup-filter)) | 245 | ((not (functionp opgroup-filter)) |
| 246 | `(lambda (opgroup) (memq opgroup ',opgroup-filter))) | 246 | (setq opgroup-filter `(lambda (opgroup) |
| 247 | (t opgroup-filter))) | 247 | (memq opgroup ',opgroup-filter))))) |
| 248 | (op-filter | 248 | (cond ((eq op-filter t) |
| 249 | (cond ((eq op-filter t) (lambda (op) t)) | 249 | (setq op-filter (lambda (op) t))) |
| 250 | ((stringp op-filter) `(lambda (op) (string-match ,op-filter op))) | 250 | ((stringp op-filter) |
| 251 | (t op-filter)))) | 251 | (setq op-filter `(lambda (op) |
| 252 | (unless xlate | 252 | (string-match ,op-filter op))))) |
| 253 | (setq xlate #'identity)) | 253 | (unless xlate |
| 254 | (c-with-syntax-table (c-lang-const c-mode-syntax-table) | 254 | (setq xlate 'identity)) |
| 255 | (cl-delete-duplicates | 255 | (c-with-syntax-table (c-lang-const c-mode-syntax-table) |
| 256 | (cl-mapcan (lambda (opgroup) | 256 | (cl-delete-duplicates |
| 257 | (when (if (symbolp (car opgroup)) | 257 | (cl-mapcan (lambda (opgroup) |
| 258 | (when (funcall opgroup-filter (car opgroup)) | 258 | (when (if (symbolp (car opgroup)) |
| 259 | (setq opgroup (cdr opgroup)) | 259 | (when (funcall opgroup-filter (car opgroup)) |
| 260 | t) | 260 | (setq opgroup (cdr opgroup)) |
| 261 | t) | 261 | t) |
| 262 | (cl-mapcan (lambda (op) | 262 | t) |
| 263 | (when (funcall op-filter op) | 263 | (cl-mapcan (lambda (op) |
| 264 | (let ((res (funcall xlate op))) | 264 | (when (funcall op-filter op) |
| 265 | (if (listp res) res (list res))))) | 265 | (let ((res (funcall xlate op))) |
| 266 | opgroup))) | 266 | (if (listp res) res (list res))))) |
| 267 | ops) | 267 | opgroup))) |
| 268 | :test #'equal))))) | 268 | ops) |
| 269 | :test 'equal)))) | ||
| 269 | 270 | ||
| 270 | 271 | ||
| 271 | ;;; Various mode specific values that aren't language related. | 272 | ;;; Various mode specific values that aren't language related. |
| @@ -349,12 +350,16 @@ the comment syntax to handle both line style \"//\" and block style | |||
| 349 | ;; all languages now require dual comments, we make this the | 350 | ;; all languages now require dual comments, we make this the |
| 350 | ;; default. | 351 | ;; default. |
| 351 | (cond | 352 | (cond |
| 352 | ((featurep 'xemacs) | 353 | ;; XEmacs |
| 354 | ((memq '8-bit c-emacs-features) | ||
| 353 | (modify-syntax-entry ?/ ". 1456" table) | 355 | (modify-syntax-entry ?/ ". 1456" table) |
| 354 | (modify-syntax-entry ?* ". 23" table)) | 356 | (modify-syntax-entry ?* ". 23" table)) |
| 355 | (t | 357 | ;; Emacs |
| 358 | ((memq '1-bit c-emacs-features) | ||
| 356 | (modify-syntax-entry ?/ ". 124b" table) | 359 | (modify-syntax-entry ?/ ". 124b" table) |
| 357 | (modify-syntax-entry ?* ". 23" table))) | 360 | (modify-syntax-entry ?* ". 23" table)) |
| 361 | ;; incompatible | ||
| 362 | (t (error "CC Mode is incompatible with this version of Emacs"))) | ||
| 358 | 363 | ||
| 359 | (modify-syntax-entry ?\n "> b" table) | 364 | (modify-syntax-entry ?\n "> b" table) |
| 360 | ;; Give CR the same syntax as newline, for selective-display | 365 | ;; Give CR the same syntax as newline, for selective-display |
| @@ -363,19 +368,19 @@ the comment syntax to handle both line style \"//\" and block style | |||
| 363 | (c-lang-defconst c-make-mode-syntax-table | 368 | (c-lang-defconst c-make-mode-syntax-table |
| 364 | "Functions that generates the mode specific syntax tables. | 369 | "Functions that generates the mode specific syntax tables. |
| 365 | The syntax tables aren't stored directly since they're quite large." | 370 | The syntax tables aren't stored directly since they're quite large." |
| 366 | t (lambda () | 371 | t `(lambda () |
| 367 | (let ((table (make-syntax-table))) | 372 | (let ((table (make-syntax-table))) |
| 368 | (c-populate-syntax-table table) | 373 | (c-populate-syntax-table table) |
| 369 | ;; Mode specific syntaxes. | 374 | ;; Mode specific syntaxes. |
| 370 | (cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode)) | 375 | ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode)) |
| 371 | ;; Let '@' be part of symbols in ObjC to cope with | 376 | ;; Let '@' be part of symbols in ObjC to cope with |
| 372 | ;; its compiler directives as single keyword tokens. | 377 | ;; its compiler directives as single keyword tokens. |
| 373 | ;; This is then necessary since it's assumed that | 378 | ;; This is then necessary since it's assumed that |
| 374 | ;; every keyword is a single symbol. | 379 | ;; every keyword is a single symbol. |
| 375 | (modify-syntax-entry ?@ "_" table)) | 380 | `(modify-syntax-entry ?@ "_" table)) |
| 376 | ((c-major-mode-is 'pike-mode) | 381 | ((c-major-mode-is 'pike-mode) |
| 377 | (modify-syntax-entry ?@ "." table))) | 382 | `(modify-syntax-entry ?@ "." table))) |
| 378 | table))) | 383 | table))) |
| 379 | 384 | ||
| 380 | (c-lang-defconst c-mode-syntax-table | 385 | (c-lang-defconst c-mode-syntax-table |
| 381 | ;; The syntax tables in evaluated form. Only used temporarily when | 386 | ;; The syntax tables in evaluated form. Only used temporarily when |
| @@ -393,15 +398,15 @@ The syntax tables aren't stored directly since they're quite large." | |||
| 393 | ;; CALLED!!! | 398 | ;; CALLED!!! |
| 394 | t nil | 399 | t nil |
| 395 | (java c++) `(lambda () | 400 | (java c++) `(lambda () |
| 396 | (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table)))) | 401 | (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table)))) |
| 397 | (modify-syntax-entry ?< "(>" table) | 402 | (modify-syntax-entry ?< "(>" table) |
| 398 | (modify-syntax-entry ?> ")<" table) | 403 | (modify-syntax-entry ?> ")<" table) |
| 399 | table))) | 404 | table))) |
| 400 | (c-lang-defvar c++-template-syntax-table | 405 | (c-lang-defvar c++-template-syntax-table |
| 401 | (and (c-lang-const c++-make-template-syntax-table) | 406 | (and (c-lang-const c++-make-template-syntax-table) |
| 402 | (funcall (c-lang-const c++-make-template-syntax-table)))) | 407 | (funcall (c-lang-const c++-make-template-syntax-table)))) |
| 403 | 408 | ||
| 404 | (c-lang-defconst c-no-parens-syntax-table | 409 | (c-lang-defconst c-make-no-parens-syntax-table |
| 405 | ;; A variant of the standard syntax table which is used to find matching | 410 | ;; A variant of the standard syntax table which is used to find matching |
| 406 | ;; "<"s and ">"s which have been marked as parens using syntax table | 411 | ;; "<"s and ">"s which have been marked as parens using syntax table |
| 407 | ;; properties. The other paren characters (e.g. "{", ")" "]") are given a | 412 | ;; properties. The other paren characters (e.g. "{", ")" "]") are given a |
| @@ -409,18 +414,20 @@ The syntax tables aren't stored directly since they're quite large." | |||
| 409 | ;; even when there's unbalanced other parens inside them. | 414 | ;; even when there's unbalanced other parens inside them. |
| 410 | ;; | 415 | ;; |
| 411 | ;; This variable is nil for languages which don't have template stuff. | 416 | ;; This variable is nil for languages which don't have template stuff. |
| 412 | t `(lambda () | 417 | t (if (c-lang-const c-recognize-<>-arglists) |
| 413 | (if (c-lang-const c-recognize-<>-arglists) | 418 | `(lambda () |
| 414 | (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table)))) | 419 | ;(if (c-lang-const c-recognize-<>-arglists) |
| 415 | (modify-syntax-entry ?\( "." table) | 420 | (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table)))) |
| 416 | (modify-syntax-entry ?\) "." table) | 421 | (modify-syntax-entry ?\( "." table) |
| 417 | (modify-syntax-entry ?\[ "." table) | 422 | (modify-syntax-entry ?\) "." table) |
| 418 | (modify-syntax-entry ?\] "." table) | 423 | (modify-syntax-entry ?\[ "." table) |
| 419 | (modify-syntax-entry ?\{ "." table) | 424 | (modify-syntax-entry ?\] "." table) |
| 420 | (modify-syntax-entry ?\} "." table) | 425 | (modify-syntax-entry ?\{ "." table) |
| 421 | table)))) | 426 | (modify-syntax-entry ?\} "." table) |
| 427 | table)))) | ||
| 422 | (c-lang-defvar c-no-parens-syntax-table | 428 | (c-lang-defvar c-no-parens-syntax-table |
| 423 | (funcall (c-lang-const c-no-parens-syntax-table))) | 429 | (and (c-lang-const c-make-no-parens-syntax-table) |
| 430 | (funcall (c-lang-const c-make-no-parens-syntax-table)))) | ||
| 424 | 431 | ||
| 425 | (c-lang-defconst c-identifier-syntax-modifications | 432 | (c-lang-defconst c-identifier-syntax-modifications |
| 426 | "A list that describes the modifications that should be done to the | 433 | "A list that describes the modifications that should be done to the |
| @@ -1137,8 +1144,7 @@ operators." | |||
| 1137 | c++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:") | 1144 | c++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:") |
| 1138 | (c-lang-const c-other-op-syntax-tokens)) | 1145 | (c-lang-const c-other-op-syntax-tokens)) |
| 1139 | objc (append '("#" "##" ; Used by cpp. | 1146 | objc (append '("#" "##" ; Used by cpp. |
| 1140 | "+" "-") | 1147 | "+" "-") (c-lang-const c-other-op-syntax-tokens)) |
| 1141 | (c-lang-const c-other-op-syntax-tokens)) | ||
| 1142 | idl (append '("#" "##") ; Used by cpp. | 1148 | idl (append '("#" "##") ; Used by cpp. |
| 1143 | (c-lang-const c-other-op-syntax-tokens)) | 1149 | (c-lang-const c-other-op-syntax-tokens)) |
| 1144 | pike (append '("..") | 1150 | pike (append '("..") |
| @@ -2465,24 +2471,27 @@ Note that Java specific rules are currently applied to tell this from | |||
| 2465 | 2471 | ||
| 2466 | ;; Note: No `*-kwds' language constants may be defined below this point. | 2472 | ;; Note: No `*-kwds' language constants may be defined below this point. |
| 2467 | 2473 | ||
| 2468 | (defconst c-kwds-lang-consts | 2474 | (eval-and-compile |
| 2469 | ;; List of all the language constants that contain keyword lists. | 2475 | (defconst c-kwds-lang-consts |
| 2470 | (let (list) | 2476 | ;; List of all the language constants that contain keyword lists. |
| 2471 | (mapatoms (lambda (sym) | 2477 | (let (list) |
| 2472 | (when (and ;; (boundp sym) | 2478 | (mapatoms (lambda (sym) |
| 2473 | (string-match "-kwds\\'" (symbol-name sym))) | 2479 | (when (and (boundp sym) |
| 2474 | ;; Make the list of globally interned symbols | 2480 | (string-match "-kwds\\'" (symbol-name sym))) |
| 2475 | ;; instead of ones interned in `c-lang-constants'. | 2481 | ;; Make the list of globally interned symbols |
| 2476 | (setq list (cons (intern (symbol-name sym)) list)))) | 2482 | ;; instead of ones interned in `c-lang-constants'. |
| 2477 | c-lang-constants) | 2483 | (setq list (cons (intern (symbol-name sym)) list)))) |
| 2478 | list)) | 2484 | c-lang-constants) |
| 2485 | list))) | ||
| 2479 | 2486 | ||
| 2480 | (c-lang-defconst c-keywords | 2487 | (c-lang-defconst c-keywords |
| 2481 | ;; All keywords as a list. | 2488 | ;; All keywords as a list. |
| 2482 | t (cl-delete-duplicates | 2489 | t (cl-delete-duplicates |
| 2483 | (apply #'append (mapcar (lambda (kwds-lang-const) | 2490 | (c-lang-defconst-eval-immediately |
| 2484 | (c-get-lang-constant kwds-lang-const)) | 2491 | `(append ,@(mapcar (lambda (kwds-lang-const) |
| 2485 | c-kwds-lang-consts)) | 2492 | `(c-lang-const ,kwds-lang-const)) |
| 2493 | c-kwds-lang-consts) | ||
| 2494 | nil)) | ||
| 2486 | :test 'string-equal)) | 2495 | :test 'string-equal)) |
| 2487 | 2496 | ||
| 2488 | (c-lang-defconst c-keywords-regexp | 2497 | (c-lang-defconst c-keywords-regexp |
| @@ -2494,10 +2503,18 @@ Note that Java specific rules are currently applied to tell this from | |||
| 2494 | ;; An alist with all the keywords in the cars. The cdr for each | 2503 | ;; An alist with all the keywords in the cars. The cdr for each |
| 2495 | ;; keyword is a list of the symbols for the `*-kwds' lists that | 2504 | ;; keyword is a list of the symbols for the `*-kwds' lists that |
| 2496 | ;; contains it. | 2505 | ;; contains it. |
| 2497 | t (let (kwd-list kwd | 2506 | t (let ((kwd-list-alist |
| 2507 | (c-lang-defconst-eval-immediately | ||
| 2508 | `(list ,@(mapcar (lambda (kwds-lang-const) | ||
| 2509 | `(cons ',kwds-lang-const | ||
| 2510 | (c-lang-const ,kwds-lang-const))) | ||
| 2511 | c-kwds-lang-consts)))) | ||
| 2512 | lang-const kwd-list kwd | ||
| 2498 | result-alist elem) | 2513 | result-alist elem) |
| 2499 | (dolist (lang-const c-kwds-lang-consts) | 2514 | (while kwd-list-alist |
| 2500 | (setq kwd-list (c-get-lang-constant lang-const)) | 2515 | (setq lang-const (caar kwd-list-alist) |
| 2516 | kwd-list (cdar kwd-list-alist) | ||
| 2517 | kwd-list-alist (cdr kwd-list-alist)) | ||
| 2501 | (while kwd-list | 2518 | (while kwd-list |
| 2502 | (setq kwd (car kwd-list) | 2519 | (setq kwd (car kwd-list) |
| 2503 | kwd-list (cdr kwd-list)) | 2520 | kwd-list (cdr kwd-list)) |
| @@ -2583,13 +2600,12 @@ Note that Java specific rules are currently applied to tell this from | |||
| 2583 | right-assoc-sequence) | 2600 | right-assoc-sequence) |
| 2584 | t)) | 2601 | t)) |
| 2585 | 2602 | ||
| 2586 | ;; (unambiguous-prefix-ops (cl-set-difference nonkeyword-prefix-ops | 2603 | (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops |
| 2587 | ;; in-or-postfix-ops | 2604 | in-or-postfix-ops |
| 2588 | ;; :test 'string-equal)) | 2605 | :test 'string-equal)) |
| 2589 | ;; (ambiguous-prefix-ops (cl-intersection nonkeyword-prefix-ops | 2606 | (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops |
| 2590 | ;; in-or-postfix-ops | 2607 | in-or-postfix-ops |
| 2591 | ;; :test 'string-equal)) | 2608 | :test 'string-equal))) |
| 2592 | ) | ||
| 2593 | 2609 | ||
| 2594 | (concat | 2610 | (concat |
| 2595 | "\\(" | 2611 | "\\(" |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 7eca7e562ea..1ce076734ff 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -95,9 +95,14 @@ | |||
| 95 | (cc-require 'cc-menus) | 95 | (cc-require 'cc-menus) |
| 96 | (cc-require 'cc-guess) | 96 | (cc-require 'cc-guess) |
| 97 | 97 | ||
| 98 | ;; Silence the compiler. | ||
| 99 | (cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs | ||
| 100 | (cc-bytecomp-defun run-mode-hooks) ; Emacs 21.1 | ||
| 101 | |||
| 98 | ;; We set these variables during mode init, yet we don't require | 102 | ;; We set these variables during mode init, yet we don't require |
| 99 | ;; font-lock. | 103 | ;; font-lock. |
| 100 | (defvar font-lock-defaults) | 104 | (cc-bytecomp-defvar font-lock-defaults) |
| 105 | (cc-bytecomp-defvar font-lock-syntactic-keywords) | ||
| 101 | 106 | ||
| 102 | ;; Menu support for both XEmacs and Emacs. If you don't have easymenu | 107 | ;; Menu support for both XEmacs and Emacs. If you don't have easymenu |
| 103 | ;; with your version of Emacs, you are incompatible! | 108 | ;; with your version of Emacs, you are incompatible! |
| @@ -547,8 +552,11 @@ that requires a literal mode spec at compile time." | |||
| 547 | ;; heuristic that open parens in column 0 are defun starters. Since | 552 | ;; heuristic that open parens in column 0 are defun starters. Since |
| 548 | ;; we have c-state-cache, that heuristic isn't useful and only causes | 553 | ;; we have c-state-cache, that heuristic isn't useful and only causes |
| 549 | ;; trouble, so turn it off. | 554 | ;; trouble, so turn it off. |
| 550 | (when (memq 'col-0-paren c-emacs-features) | 555 | ;; 2006/12/17: This facility is somewhat confused, and doesn't really seem |
| 551 | (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil)) | 556 | ;; helpful. Comment it out for now. |
| 557 | ;; (when (memq 'col-0-paren c-emacs-features) | ||
| 558 | ;; (make-local-variable 'open-paren-in-column-0-is-defun-start) | ||
| 559 | ;; (setq open-paren-in-column-0-is-defun-start nil)) | ||
| 552 | 560 | ||
| 553 | (c-clear-found-types) | 561 | (c-clear-found-types) |
| 554 | 562 | ||
| @@ -808,7 +816,7 @@ Note that the style variables are always made local to the buffer." | |||
| 808 | (defmacro c-run-mode-hooks (&rest hooks) | 816 | (defmacro c-run-mode-hooks (&rest hooks) |
| 809 | ;; Emacs 21.1 has introduced a system with delayed mode hooks that | 817 | ;; Emacs 21.1 has introduced a system with delayed mode hooks that |
| 810 | ;; requires the use of the new function `run-mode-hooks'. | 818 | ;; requires the use of the new function `run-mode-hooks'. |
| 811 | (if (fboundp 'run-mode-hooks) | 819 | (if (cc-bytecomp-fboundp 'run-mode-hooks) |
| 812 | `(run-mode-hooks ,@hooks) | 820 | `(run-mode-hooks ,@hooks) |
| 813 | `(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks)))) | 821 | `(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks)))) |
| 814 | 822 | ||
| @@ -1224,8 +1232,8 @@ This function is called from `c-common-init', once per mode initialization." | |||
| 1224 | (font-lock-mark-block-function | 1232 | (font-lock-mark-block-function |
| 1225 | . c-mark-function))) | 1233 | . c-mark-function))) |
| 1226 | 1234 | ||
| 1227 | (set (make-local-variable 'font-lock-fontify-region-function) | 1235 | (make-local-variable 'font-lock-fontify-region-function) |
| 1228 | #'c-font-lock-fontify-region) | 1236 | (setq font-lock-fontify-region-function 'c-font-lock-fontify-region) |
| 1229 | 1237 | ||
| 1230 | (if (featurep 'xemacs) | 1238 | (if (featurep 'xemacs) |
| 1231 | (make-local-hook 'font-lock-mode-hook)) | 1239 | (make-local-hook 'font-lock-mode-hook)) |