aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2014-09-09 11:08:08 -0400
committerStefan Monnier2014-09-09 11:08:08 -0400
commit8fe73251b167274c4316e3726b4034dba77a5e88 (patch)
tree25b60c4ca7b2e35c7ef162b96353a96a5c411fa3
parent607dab4681b3fd2567e4660b3605dedaa125086a (diff)
downloademacs-8fe73251b167274c4316e3726b4034dba77a5e88.tar.gz
emacs-8fe73251b167274c4316e3726b4034dba77a5e88.zip
* lisp/progmodes/cc-awk.el: Remove unneeded cc-bytecomp use.
Change doc comments into docstrings. * lisp/Makefile.in: Remove cc-awk dependency.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/Makefile.in2
-rw-r--r--lisp/progmodes/cc-awk.el671
3 files changed, 334 insertions, 345 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6e8b47359b6..ca7e1f7a930 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12014-09-09 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/cc-awk.el: Remove unneeded cc-bytecomp use.
4 Change doc comments into docstrings.
5 * Makefile.in: Remove cc-awk dependency.
6
12014-09-08 Sam Steingold <sds@gnu.org> 72014-09-08 Sam Steingold <sds@gnu.org>
2 8
3 * progmodes/sql.el (sql-send-line-and-next): New command, 9 * progmodes/sql.el (sql-send-line-and-next): New command,
diff --git a/lisp/Makefile.in b/lisp/Makefile.in
index 633551387e6..258cc3b8ae1 100644
--- a/lisp/Makefile.in
+++ b/lisp/Makefile.in
@@ -495,7 +495,7 @@ check-declare:
495# CC Mode uses a compile time macro system which causes a compile time 495# CC Mode uses a compile time macro system which causes a compile time
496# dependency in cc-*.elc files on the macros in other cc-*.el and the 496# dependency in cc-*.elc files on the macros in other cc-*.el and the
497# version string in cc-defs.el. 497# version string in cc-defs.el.
498$(lisp)/progmodes/cc-align.elc $(lisp)/progmodes/cc-awk.elc\ 498$(lisp)/progmodes/cc-align.elc\
499 $(lisp)/progmodes/cc-cmds.elc $(lisp)/progmodes/cc-compat.elc\ 499 $(lisp)/progmodes/cc-cmds.elc $(lisp)/progmodes/cc-compat.elc\
500 $(lisp)/progmodes/cc-engine.elc $(lisp)/progmodes/cc-fonts.elc\ 500 $(lisp)/progmodes/cc-engine.elc $(lisp)/progmodes/cc-fonts.elc\
501 $(lisp)/progmodes/cc-langs.elc $(lisp)/progmodes/cc-menus.elc\ 501 $(lisp)/progmodes/cc-langs.elc $(lisp)/progmodes/cc-menus.elc\
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el
index 44d69d7d0f1..fbc0b6de420 100644
--- a/lisp/progmodes/cc-awk.el
+++ b/lisp/progmodes/cc-awk.el
@@ -40,28 +40,8 @@
40 40
41;;; Code: 41;;; Code:
42 42
43(eval-when-compile 43(require 'cc-defs)
44 (let ((load-path 44(require 'cc-engine)
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)
65 45
66(defvar awk-mode-syntax-table 46(defvar awk-mode-syntax-table
67 (let ((st (make-syntax-table))) 47 (let ((st (make-syntax-table)))
@@ -95,111 +75,111 @@
95;; Emacs has in the past used \r to mark hidden lines in some fashion (and 75;; Emacs has in the past used \r to mark hidden lines in some fashion (and
96;; maybe still does). 76;; maybe still does).
97 77
98(defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)") 78(defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)"
99;; Matches any escaped (with \) character-pair, including an escaped newline. 79 "Matches any escaped (with \) character-pair, including an escaped newline.")
100(defconst c-awk-non-eol-esc-pair-re "\\\\\\(.\\|\\'\\)") 80(defconst c-awk-non-eol-esc-pair-re "\\\\\\(.\\|\\'\\)"
101;; Matches any escaped (with \) character-pair, apart from an escaped newline. 81 "Matches any escaped (with \) character-pair, apart from an escaped newline.")
102(defconst c-awk-comment-without-nl "#.*") 82(defconst c-awk-comment-without-nl "#.*"
103;; Matches an AWK comment, not including the terminating NL (if any). Note 83"Matches an AWK comment, not including the terminating NL (if any).
104;; that the "enclosing" (elisp) regexp must ensure the # is real. 84Note that the \"enclosing\" (elisp) regexp must ensure the # is real.")
105(defconst c-awk-nl-or-eob "\\(\n\\|\r\\|\\'\\)") 85(defconst c-awk-nl-or-eob "\\(\n\\|\r\\|\\'\\)"
106;; Matches a newline, or the end of buffer. 86 "Matches a newline, or the end of buffer.")
107 87
108;; "Space" regular expressions. 88;; "Space" regular expressions.
109(eval-and-compile 89(eval-and-compile
110 (defconst c-awk-escaped-nl "\\\\[\n\r]")) 90 (defconst c-awk-escaped-nl "\\\\[\n\r]"
111;; Matches an escaped newline. 91 "Matches an escaped newline."))
112(eval-and-compile 92(eval-and-compile
113 (defconst c-awk-escaped-nls* (concat "\\(" c-awk-escaped-nl "\\)*"))) 93 (defconst c-awk-escaped-nls* (concat "\\(" c-awk-escaped-nl "\\)*")
114;; Matches a possibly empty sequence of escaped newlines. Used in 94 "Matches a possibly empty sequence of escaped newlines.
115;; awk-font-lock-keywords. 95Used in `awk-font-lock-keywords'."))
116;; (defconst c-awk-escaped-nls*-with-space* 96;; (defconst c-awk-escaped-nls*-with-space*
117;; (concat "\\(" c-awk-escaped-nls* "\\|" "[ \t]+" "\\)*")) 97;; (concat "\\(" c-awk-escaped-nls* "\\|" "[ \t]+" "\\)*"))
118;; The above RE was very slow. It's runtime was doubling with each additional 98;; The above RE was very slow. It's runtime was doubling with each additional
119;; space :-( Reformulate it as below: 99;; space :-( Reformulate it as below:
120(eval-and-compile 100(eval-and-compile
121 (defconst c-awk-escaped-nls*-with-space* 101 (defconst c-awk-escaped-nls*-with-space*
122 (concat "\\(" c-awk-escaped-nl "\\|" "[ \t]" "\\)*"))) 102 (concat "\\(" c-awk-escaped-nl "\\|" "[ \t]" "\\)*")
123;; Matches a possibly empty sequence of escaped newlines with optional 103 "Matches a possibly empty sequence of escaped newlines with optional
124;; interspersed spaces and tabs. Used in awk-font-lock-keywords. 104interspersed spaces and tabs. Used in `awk-font-lock-keywords'."))
125(defconst c-awk-blank-or-comment-line-re 105(defconst c-awk-blank-or-comment-line-re
126 (concat "[ \t]*\\(#\\|\\\\?$\\)")) 106 (concat "[ \t]*\\(#\\|\\\\?$\\)")
127;; Matche (the tail of) a line containing at most either a comment or an 107 "Match (the tail of) a line containing at most either a comment or an
128;; escaped EOL. 108escaped EOL.")
129 109
130;; REGEXPS FOR "HARMLESS" STRINGS/LINES. 110;; REGEXPS FOR "HARMLESS" STRINGS/LINES.
131(defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)") 111(defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)"
132;; Matches an underline NOT followed by ". 112 "Matches an underline NOT followed by \".")
133(defconst c-awk-harmless-char-re "[^_#/\"{}();\\\\\n\r]") 113(defconst c-awk-harmless-char-re "[^_#/\"{}();\\\\\n\r]"
134;; Matches any character not significant in the state machine applying 114 "Matches any character not significant in the state machine applying
135;; syntax-table properties to "s and /s. 115syntax-table properties to \"s and /s.")
136(defconst c-awk-harmless-string*-re 116(defconst c-awk-harmless-string*-re
137 (concat "\\(" c-awk-harmless-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*")) 117 (concat "\\(" c-awk-harmless-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*")
138;; Matches a (possibly empty) sequence of characters insignificant in the 118 "Matches a (possibly empty) sequence of characters insignificant in the
139;; state machine applying syntax-table properties to "s and /s. 119state machine applying syntax-table properties to \"s and /s.")
140(defconst c-awk-harmless-string*-here-re 120(defconst c-awk-harmless-string*-here-re
141 (concat "\\=" c-awk-harmless-string*-re)) 121 (concat "\\=" c-awk-harmless-string*-re)
142;; Matches the (possibly empty) sequence of "insignificant" chars at point. 122"Matches the (possibly empty) sequence of \"insignificant\" chars at point.")
143 123
144(defconst c-awk-harmless-line-char-re "[^_#/\"\\\\\n\r]") 124(defconst c-awk-harmless-line-char-re "[^_#/\"\\\\\n\r]"
145;; Matches any character but a _, #, /, ", \, or newline. N.B. _" starts a 125 "Matches any character but a _, #, /, \", \\, or newline. N.B. _\" starts a
146;; localization string in gawk 3.1 126localization string in gawk 3.1.")
147(defconst c-awk-harmless-line-string*-re 127(defconst c-awk-harmless-line-string*-re
148 (concat "\\(" c-awk-harmless-line-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*")) 128 (concat "\\(" c-awk-harmless-line-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*")
149;; Matches a (possibly empty) sequence of chars without unescaped /, ", \, 129 "Matches a (possibly empty) sequence of chars without unescaped /, \", \\,
150;; #, or newlines. 130#, or newlines.")
151(defconst c-awk-harmless-line-re 131(defconst c-awk-harmless-line-re
152 (concat c-awk-harmless-line-string*-re 132 (concat c-awk-harmless-line-string*-re
153 "\\(" c-awk-comment-without-nl "\\)?" c-awk-nl-or-eob)) 133 "\\(" c-awk-comment-without-nl "\\)?" c-awk-nl-or-eob)
154;; Matches (the tail of) an AWK \"logical\" line not containing an unescaped 134 "Matches (the tail of) an AWK \"logical\" line not containing an unescaped
155;; " or /. "logical" means "possibly containing escaped newlines". A comment 135\" or /. \"logical\" means \"possibly containing escaped newlines\". A comment
156;; is matched as part of the line even if it contains a " or a /. The End of 136is matched as part of the line even if it contains a \" or a /. The End of
157;; buffer is also an end of line. 137buffer is also an end of line.")
158(defconst c-awk-harmless-lines+-here-re 138(defconst c-awk-harmless-lines+-here-re
159 (concat "\\=\\(" c-awk-harmless-line-re "\\)+")) 139 (concat "\\=\\(" c-awk-harmless-line-re "\\)+")
160;; Matches a sequence of (at least one) \"harmless-line\" at point. 140 "Matches a sequence of (at least one) \"harmless-line\" at point.")
161 141
162 142
163;; REGEXPS FOR AWK STRINGS. 143;; REGEXPS FOR AWK STRINGS.
164(defconst c-awk-string-ch-re "[^\"\\\n\r]") 144(defconst c-awk-string-ch-re "[^\"\\\n\r]"
165;; Matches any character which can appear unescaped in a string. 145 "Matches any character which can appear unescaped in a string.")
166(defconst c-awk-string-innards-re 146(defconst c-awk-string-innards-re
167 (concat "\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*")) 147 (concat "\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*")
168;; Matches the inside of an AWK string (i.e. without the enclosing quotes). 148 "Matches the inside of an AWK string (i.e. without the enclosing quotes).")
169(defconst c-awk-string-without-end-here-re 149(defconst c-awk-string-without-end-here-re
170 (concat "\\=_?\"" c-awk-string-innards-re)) 150 (concat "\\=_?\"" c-awk-string-innards-re)
171;; Matches an AWK string at point up to, but not including, any terminator. 151 "Matches an AWK string at point up to, but not including, any terminator.
172;; A gawk 3.1+ string may look like _"localizable string". 152A gawk 3.1+ string may look like _\"localizable string\".")
173(defconst c-awk-possibly-open-string-re 153(defconst c-awk-possibly-open-string-re
174 (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*" 154 (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*"
175 "\\(\"\\|$\\|\\'\\)")) 155 "\\(\"\\|$\\|\\'\\)"))
176 156
177;; REGEXPS FOR AWK REGEXPS. 157;; REGEXPS FOR AWK REGEXPS.
178(defconst c-awk-regexp-normal-re "[^[/\\\n\r]") 158(defconst c-awk-regexp-normal-re "[^[/\\\n\r]"
179;; Matches any AWK regexp character which doesn't require special analysis. 159 "Matches any AWK regexp character which doesn't require special analysis.")
180(defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*") 160(defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*"
181;; Matches a (possibly empty) sequence of escaped newlines. 161 "Matches a (possibly empty) sequence of escaped newlines.")
182 162
183;; NOTE: In what follows, "[asdf]" in a regexp will be called a "character 163;; NOTE: In what follows, "[asdf]" in a regexp will be called a "character
184;; list", and "[:alpha:]" inside a character list will be known as a 164;; list", and "[:alpha:]" inside a character list will be known as a
185;; "character class". These terms for these things vary between regexp 165;; "character class". These terms for these things vary between regexp
186;; descriptions . 166;; descriptions .
187(defconst c-awk-regexp-char-class-re 167(defconst c-awk-regexp-char-class-re
188 "\\[:[a-z]+:\\]") 168 "\\[:[a-z]+:\\]"
189 ;; Matches a character class spec (e.g. [:alpha:]). 169 "Matches a character class spec (e.g. [:alpha:]).")
190(defconst c-awk-regexp-char-list-re 170(defconst c-awk-regexp-char-list-re
191 (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?" 171 (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?"
192 "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re 172 "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re
193 "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)")) 173 "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)")
194;; Matches a regexp char list, up to (but not including) EOL if the ] is 174 "Matches a regexp char list, up to (but not including) EOL if the ] is
195;; missing. 175missing.")
196(defconst c-awk-regexp-innards-re 176(defconst c-awk-regexp-innards-re
197 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re 177 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re
198 "\\|" c-awk-regexp-normal-re "\\)*")) 178 "\\|" c-awk-regexp-normal-re "\\)*")
199;; Matches the inside of an AWK regexp (i.e. without the enclosing /s) 179 "Matches the inside of an AWK regexp (i.e. without the enclosing /s)")
200(defconst c-awk-regexp-without-end-re 180(defconst c-awk-regexp-without-end-re
201 (concat "/" c-awk-regexp-innards-re)) 181 (concat "/" c-awk-regexp-innards-re)
202;; Matches an AWK regexp up to, but not including, any terminating /. 182 "Matches an AWK regexp up to, but not including, any terminating /.")
203 183
204;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A 184;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A
205;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant 185;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant
@@ -207,47 +187,47 @@
207;; division sign. 187;; division sign.
208(defconst c-awk-neutral-re 188(defconst c-awk-neutral-re
209; "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)+") ; changed, 2003/6/7 189; "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)+") ; changed, 2003/6/7
210 "\\([}@` \t]\\|\\+\\+\\|--\\|\\\\\\(.\\|[\n\r]\\)\\)") 190 "\\([}@` \t]\\|\\+\\+\\|--\\|\\\\\\(.\\|[\n\r]\\)\\)"
211;; A "neutral" char(pair). Doesn't change the "state" of a subsequent /. 191 "A \"neutral\" char(pair). Doesn't change the \"state\" of a subsequent /.
212;; This is space/tab, close brace, an auto-increment/decrement operator or an 192This is space/tab, close brace, an auto-increment/decrement operator or an
213;; escaped character. Or one of the (invalid) characters @ or `. But NOT an 193escaped character. Or one of the (invalid) characters @ or `. But NOT an
214;; end of line (unless escaped). 194end of line (unless escaped).")
215(defconst c-awk-neutrals*-re 195(defconst c-awk-neutrals*-re
216 (concat "\\(" c-awk-neutral-re "\\)*")) 196 (concat "\\(" c-awk-neutral-re "\\)*")
217;; A (possibly empty) string of neutral characters (or character pairs). 197 "A (possibly empty) string of neutral characters (or character pairs).")
218(defconst c-awk-var-num-ket-re "[]\)0-9a-zA-Z_$.\x80-\xff]+") 198(defconst c-awk-var-num-ket-re "[]\)0-9a-zA-Z_$.\x80-\xff]+"
219;; Matches a char which is a constituent of a variable or number, or a ket 199 "Matches a char which is a constituent of a variable or number, or a ket
220;; (i.e. closing bracKET), round or square. Assume that all characters \x80 to 200\(i.e. closing bracKET), round or square. Assume that all characters \\x80 to
221;; \xff are "letters". 201\\xff are \"letters\".")
222(defconst c-awk-div-sign-re 202(defconst c-awk-div-sign-re
223 (concat c-awk-var-num-ket-re c-awk-neutrals*-re "/")) 203 (concat c-awk-var-num-ket-re c-awk-neutrals*-re "/")
224;; Will match a piece of AWK buffer ending in / which is a division sign, in 204 "Will match a piece of AWK buffer ending in / which is a division sign, in
225;; a context where an immediate / would be a regexp bracket. It follows a 205a context where an immediate / would be a regexp bracket. It follows a
226;; variable or number (with optional intervening "neutral" characters). This 206variable or number (with optional intervening \"neutral\" characters). This
227;; will only work when there won't be a preceding " or / before the sought / 207will only work when there won't be a preceding \" or / before the sought /
228;; to foul things up. 208to foul things up.")
229(defconst c-awk-non-arith-op-bra-re 209(defconst c-awk-non-arith-op-bra-re
230 "[[\({&=:!><,?;'~|]") 210 "[[\({&=:!><,?;'~|]"
231;; Matches an opening BRAcket (of any sort), or any operator character 211 "Matches an opening BRAcket (of any sort), or any operator character
232;; apart from +,-,/,*,%. For the purpose at hand (detecting a / which is a 212apart from +,-,/,*,%. For the purpose at hand (detecting a / which is a
233;; regexp bracket) these arith ops are unnecessary and a pain, because of "++" 213regexp bracket) these arith ops are unnecessary and a pain, because of \"++\"
234;; and "--". 214and \"--\".")
235(defconst c-awk-regexp-sign-re 215(defconst c-awk-regexp-sign-re
236 (concat c-awk-non-arith-op-bra-re c-awk-neutrals*-re "/")) 216 (concat c-awk-non-arith-op-bra-re c-awk-neutrals*-re "/")
237;; Will match a piece of AWK buffer ending in / which is an opening regexp 217 "Will match a piece of AWK buffer ending in / which is an opening regexp
238;; bracket, in a context where an immediate / would be a division sign. This 218bracket, in a context where an immediate / would be a division sign. This
239;; will only work when there won't be a preceding " or / before the sought / 219will only work when there won't be a preceding \" or / before the sought /
240;; to foul things up. 220to foul things up.")
241(defconst c-awk-pre-exp-alphanum-kwd-re 221(defconst c-awk-pre-exp-alphanum-kwd-re
242 (concat "\\(^\\|\\=\\|[^_\n\r]\\)\\<" 222 (concat "\\(^\\|\\=\\|[^_\n\r]\\)\\<"
243 (regexp-opt '("print" "return" "case") t) 223 (regexp-opt '("print" "return" "case") t)
244 "\\>\\([^_\n\r]\\|$\\)")) 224 "\\>\\([^_\n\r]\\|$\\)")
245;; Matches all AWK keywords which can precede expressions (including 225 "Matches all AWK keywords which can precede expressions (including
246;; /regexp/). 226/regexp/).")
247(defconst c-awk-kwd-regexp-sign-re 227(defconst c-awk-kwd-regexp-sign-re
248 (concat c-awk-pre-exp-alphanum-kwd-re c-awk-escaped-nls*-with-space* "/")) 228 (concat c-awk-pre-exp-alphanum-kwd-re c-awk-escaped-nls*-with-space* "/")
249;; Matches a piece of AWK buffer ending in <kwd> /, where <kwd> is a keyword 229 "Matches a piece of AWK buffer ending in <kwd> /, where <kwd> is a keyword
250;; which can precede an expression. 230which can precede an expression.")
251 231
252;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon" 232;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon"
253(defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]") 233(defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]")
@@ -259,16 +239,16 @@
259 c-awk-possibly-open-string-re 239 c-awk-possibly-open-string-re
260 "\\)" 240 "\\)"
261 "\\)*")) 241 "\\)*"))
262(defconst c-awk-space*-/-re (concat c-awk-escaped-nls*-with-space* "/")) 242(defconst c-awk-space*-/-re (concat c-awk-escaped-nls*-with-space* "/")
263;; Matches optional whitespace followed by "/". 243 "Matches optional whitespace followed by \"/\".")
264(defconst c-awk-space*-regexp-/-re 244(defconst c-awk-space*-regexp-/-re
265 (concat c-awk-escaped-nls*-with-space* "\\s\"")) 245 (concat c-awk-escaped-nls*-with-space* "\\s\"")
266;; Matches optional whitespace followed by a "/" with string syntax (a matched 246 "Matches optional whitespace followed by a \"/\" with string syntax (a matched
267;; regexp delimiter). 247regexp delimiter).")
268(defconst c-awk-space*-unclosed-regexp-/-re 248(defconst c-awk-space*-unclosed-regexp-/-re
269 (concat c-awk-escaped-nls*-with-space* "\\s\|")) 249 (concat c-awk-escaped-nls*-with-space* "\\s\|")
270;; Matches optional whitespace followed by a "/" with string fence syntax (an 250 "Matches optional whitespace followed by a \"/\" with string fence syntax (an
271;; unmatched regexp delimiter). 251unmatched regexp delimiter).")
272 252
273 253
274;; ACM, 2002/5/29: 254;; ACM, 2002/5/29:
@@ -323,16 +303,16 @@
323;; statement of a do-while. 303;; statement of a do-while.
324 304
325(defun c-awk-after-if-for-while-condition-p (&optional do-lim) 305(defun c-awk-after-if-for-while-condition-p (&optional do-lim)
326 ;; Are we just after the ) in "if/for/while (<condition>)"? 306 "Are we just after the ) in \"if/for/while (<condition>)\"?
327 ;; 307
328 ;; Note that the end of the ) in a do .... while (<condition>) doesn't 308Note that the end of the ) in a do .... while (<condition>) doesn't
329 ;; count, since the purpose of this routine is essentially to decide 309count, since the purpose of this routine is essentially to decide
330 ;; whether to indent the next line. 310whether to indent the next line.
331 ;; 311
332 ;; DO-LIM sets a limit on how far back we search for the "do" of a possible 312DO-LIM sets a limit on how far back we search for the \"do\" of a possible
333 ;; do-while. 313do-while.
334 ;; 314
335 ;; This function might do hidden buffer changes. 315This function might do hidden buffer changes."
336 (and 316 (and
337 (eq (char-before) ?\)) 317 (eq (char-before) ?\))
338 (save-excursion 318 (save-excursion
@@ -346,9 +326,9 @@
346 'beginning))))))))) 326 'beginning)))))))))
347 327
348(defun c-awk-after-function-decl-param-list () 328(defun c-awk-after-function-decl-param-list ()
349 ;; Are we just after the ) in "function foo (bar)" ? 329 "Are we just after the ) in \"function foo (bar)\" ?
350 ;; 330
351 ;; This function might do hidden buffer changes. 331This function might do hidden buffer changes."
352 (and (eq (char-before) ?\)) 332 (and (eq (char-before) ?\))
353 (save-excursion 333 (save-excursion
354 (let ((par-pos (c-safe (scan-lists (point) -1 0)))) 334 (let ((par-pos (c-safe (scan-lists (point) -1 0))))
@@ -361,10 +341,10 @@
361 341
362;; 2002/11/8: FIXME! Check c-backward-token-1/2 for success (0 return code). 342;; 2002/11/8: FIXME! Check c-backward-token-1/2 for success (0 return code).
363(defun c-awk-after-continue-token () 343(defun c-awk-after-continue-token ()
364;; Are we just after a token which can be continued onto the next line without 344 "Are we just after a token which can be continued onto the next line without
365;; a backslash? 345a backslash?
366;; 346
367;; This function might do hidden buffer changes. 347This function might do hidden buffer changes."
368 (save-excursion 348 (save-excursion
369 (c-backward-token-1) ; FIXME 2002/10/27. What if this fails? 349 (c-backward-token-1) ; FIXME 2002/10/27. What if this fails?
370 (if (and (looking-at "[&|]") (not (bobp))) 350 (if (and (looking-at "[&|]") (not (bobp)))
@@ -372,10 +352,10 @@
372 (looking-at "[,{?:]\\|&&\\|||\\|do\\>\\|else\\>"))) 352 (looking-at "[,{?:]\\|&&\\|||\\|do\\>\\|else\\>")))
373 353
374(defun c-awk-after-rbrace-or-statement-semicolon () 354(defun c-awk-after-rbrace-or-statement-semicolon ()
375 ;; Are we just after a } or a ; which closes a statement? 355 "Are we just after a } or a ; which closes a statement?
376 ;; Be careful about ;s in for loop control bits. They don't count! 356Be careful about ;s in for loop control bits. They don't count!
377 ;; 357
378 ;; This function might do hidden buffer changes. 358This function might do hidden buffer changes."
379 (or (eq (char-before) ?\}) 359 (or (eq (char-before) ?\})
380 (and 360 (and
381 (eq (char-before) ?\;) 361 (eq (char-before) ?\;)
@@ -388,22 +368,22 @@
388 (looking-at "for\\>"))))))))) 368 (looking-at "for\\>")))))))))
389 369
390(defun c-awk-back-to-contentful-text-or-NL-prop () 370(defun c-awk-back-to-contentful-text-or-NL-prop ()
391 ;; Move back to just after the first found of either (i) an EOL which has 371 "Move back to just after the first found of either (i) an EOL which has
392 ;; the c-awk-NL-prop text-property set; or (ii) non-ws text; or (iii) BOB. 372the `c-awk-NL-prop' text-property set; or (ii) non-ws text; or (iii) BOB.
393 ;; We return either the value of c-awk-NL-prop (in case (i)) or nil. 373We return either the value of `c-awk-NL-prop' (in case (i)) or nil.
394 ;; Calling functions can best distinguish cases (ii) and (iii) with (bolp). 374Calling functions can best distinguish cases (ii) and (iii) with `bolp'.
395 ;; 375
396 ;; Note that an escaped eol counts as whitespace here. 376Note that an escaped eol counts as whitespace here.
397 ;; 377
398 ;; Kludge: If c-backward-syntactic-ws gets stuck at a BOL, it is likely 378Kludge: If `c-backward-syntactic-ws' gets stuck at a BOL, it is likely
399 ;; that the previous line contains an unterminated string (without \). In 379that the previous line contains an unterminated string (without \\). In
400 ;; this case, assume that the previous line's c-awk-NL-prop is a $. 380this case, assume that the previous line's `c-awk-NL-prop' is a $.
401 ;; 381
402 ;; POINT MUST BE AT THE START OF A LINE when calling this function. This 382POINT MUST BE AT THE START OF A LINE when calling this function. This
403 ;; is to ensure that the various backward-comment functions will work 383is to ensure that the various backward-comment functions will work
404 ;; properly. 384properly.
405 ;; 385
406 ;; This function might do hidden buffer changes. 386This function might do hidden buffer changes."
407 (let ((nl-prop nil) 387 (let ((nl-prop nil)
408 bol-pos bsws-pos) ; starting pos for a backward-syntactic-ws call. 388 bol-pos bsws-pos) ; starting pos for a backward-syntactic-ws call.
409 (while ;; We are at a BOL here. Go back one line each iteration. 389 (while ;; We are at a BOL here. Go back one line each iteration.
@@ -438,19 +418,19 @@
438 nl-prop)) 418 nl-prop))
439 419
440(defun c-awk-calculate-NL-prop-prev-line (&optional do-lim) 420(defun c-awk-calculate-NL-prop-prev-line (&optional do-lim)
441 ;; Calculate and set the value of the c-awk-NL-prop on the immediately 421 "Calculate and set the value of the `c-awk-NL-prop' on the immediately
442 ;; preceding EOL. This may also involve doing the same for several 422preceding EOL. This may also involve doing the same for several
443 ;; preceding EOLs. 423preceding EOLs.
444 ;; 424
445 ;; NOTE that if the property was already set, we return it without 425NOTE that if the property was already set, we return it without
446 ;; recalculation. (This is by accident rather than design.) 426recalculation. (This is by accident rather than design.)
447 ;; 427
448 ;; Return the property which got set (or was already set) on the previous 428Return the property which got set (or was already set) on the previous
449 ;; line. Return nil if we hit BOB. 429line. Return nil if we hit BOB.
450 ;; 430
451 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. 431See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM.
452 ;; 432
453 ;; This function might do hidden buffer changes. 433This function might do hidden buffer changes."
454 (save-excursion 434 (save-excursion
455 (save-match-data 435 (save-match-data
456 (beginning-of-line) 436 (beginning-of-line)
@@ -493,25 +473,25 @@
493 nl-prop)))) 473 nl-prop))))
494 474
495(defun c-awk-get-NL-prop-prev-line (&optional do-lim) 475(defun c-awk-get-NL-prop-prev-line (&optional do-lim)
496 ;; Get the c-awk-NL-prop text-property from the previous line, calculating 476 "Get the `c-awk-NL-prop' text-property from the previous line, calculating
497 ;; it if necessary. Return nil if we're already at BOB. 477it if necessary. Return nil if we're already at BOB.
498 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. 478See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM.
499 ;; 479
500 ;; This function might do hidden buffer changes. 480This function might do hidden buffer changes."
501 (if (bobp) 481 (if (bobp)
502 nil 482 nil
503 (or (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop) 483 (or (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop)
504 (c-awk-calculate-NL-prop-prev-line do-lim)))) 484 (c-awk-calculate-NL-prop-prev-line do-lim))))
505 485
506(defun c-awk-get-NL-prop-cur-line (&optional do-lim) 486(defun c-awk-get-NL-prop-cur-line (&optional do-lim)
507 ;; Get the c-awk-NL-prop text-property from the current line, calculating it 487 "Get the `c-awk-NL-prop' text-property from the current line, calculating it
508 ;; if necessary. (As a special case, the property doesn't get set on an 488if necessary. (As a special case, the property doesn't get set on an
509 ;; empty line at EOB (there's no position to set the property on), but the 489empty line at EOB (there's no position to set the property on), but the
510 ;; function returns the property value an EOL would have got.) 490function returns the property value an EOL would have got.)
511 ;; 491
512 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. 492See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM.
513 ;; 493
514 ;; This function might do hidden buffer changes. 494This function might do hidden buffer changes."
515 (save-excursion 495 (save-excursion
516 (let ((extra-nl nil)) 496 (let ((extra-nl nil))
517 (end-of-line) ; Necessary for the following test to work. 497 (end-of-line) ; Necessary for the following test to work.
@@ -522,17 +502,17 @@
522 (if extra-nl (delete-char -1)))))) 502 (if extra-nl (delete-char -1))))))
523 503
524(defsubst c-awk-prev-line-incomplete-p (&optional do-lim) 504(defsubst c-awk-prev-line-incomplete-p (&optional do-lim)
525 ;; Is there an incomplete statement at the end of the previous line? 505 "Is there an incomplete statement at the end of the previous line?
526 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. 506See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM.
527 ;; 507
528 ;; This function might do hidden buffer changes. 508This function might do hidden buffer changes."
529 (memq (c-awk-get-NL-prop-prev-line do-lim) '(?\\ ?\{))) 509 (memq (c-awk-get-NL-prop-prev-line do-lim) '(?\\ ?\{)))
530 510
531(defsubst c-awk-cur-line-incomplete-p (&optional do-lim) 511(defsubst c-awk-cur-line-incomplete-p (&optional do-lim)
532 ;; Is there an incomplete statement at the end of the current line? 512 "Is there an incomplete statement at the end of the current line?
533 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. 513See `c-awk-after-if-for-while-condition-p' for a description of DO-LIM.
534 ;; 514
535 ;; This function might do hidden buffer changes. 515This function might do hidden buffer changes."
536 (memq (c-awk-get-NL-prop-cur-line do-lim) '(?\\ ?\{))) 516 (memq (c-awk-get-NL-prop-cur-line do-lim) '(?\\ ?\{)))
537 517
538;; NOTES ON "VIRTUAL SEMICOLONS" 518;; NOTES ON "VIRTUAL SEMICOLONS"
@@ -545,7 +525,7 @@
545;; never counts as a virtual one. 525;; never counts as a virtual one.
546 526
547(defun c-awk-at-vsemi-p (&optional pos) 527(defun c-awk-at-vsemi-p (&optional pos)
548 ;; Is there a virtual semicolon at POS (or POINT)? 528 "Is there a virtual semicolon at POS (or POINT)?"
549 (save-excursion 529 (save-excursion
550 (let* (nl-prop 530 (let* (nl-prop
551 (pos-or-point (progn (if pos (goto-char pos)) (point))) 531 (pos-or-point (progn (if pos (goto-char pos)) (point)))
@@ -585,29 +565,29 @@
585 (eq nl-prop ?\$)))))) 565 (eq nl-prop ?\$))))))
586 566
587(defun c-awk-vsemi-status-unknown-p () 567(defun c-awk-vsemi-status-unknown-p ()
588 ;; Are we unsure whether there is a virtual semicolon on the current line? 568 "Are we unsure whether there is a virtual semicolon on the current line?
589 ;; DO NOT under any circumstances attempt to calculate this; that would 569DO NOT under any circumstances attempt to calculate this; that would
590 ;; defeat the (admittedly kludgy) purpose of this function, which is to 570defeat the (admittedly kludgy) purpose of this function, which is to
591 ;; prevent an infinite recursion in c-beginning-of-statement-1 when point 571prevent an infinite recursion in `c-beginning-of-statement-1' when point
592 ;; starts at a `while' token. 572starts at a `while' token."
593 (not (c-get-char-property (c-point 'eol) 'c-awk-NL-prop))) 573 (not (c-get-char-property (c-point 'eol) 'c-awk-NL-prop)))
594 574
595(defun c-awk-clear-NL-props (beg end) 575(defun c-awk-clear-NL-props (beg end)
596 ;; This function is run from before-change-hooks. It clears the 576 "This function is run from `before-change-hooks.' It clears the
597 ;; c-awk-NL-prop text property from beg to the end of the buffer (The END 577`c-awk-NL-prop' text property from beg to the end of the buffer (The END
598 ;; parameter is ignored). This ensures that the indentation engine will 578parameter is ignored). This ensures that the indentation engine will
599 ;; never use stale values for this property. 579never use stale values for this property.
600 ;; 580
601 ;; This function might do hidden buffer changes. 581This function might do hidden buffer changes."
602 (save-restriction 582 (save-restriction
603 (widen) 583 (widen)
604 (c-clear-char-properties beg (point-max) 'c-awk-NL-prop))) 584 (c-clear-char-properties beg (point-max) 'c-awk-NL-prop)))
605 585
606(defun c-awk-unstick-NL-prop () 586(defun c-awk-unstick-NL-prop ()
607 ;; Ensure that the text property c-awk-NL-prop is "non-sticky". Without 587 "Ensure that the text property `c-awk-NL-prop' is \"non-sticky\".
608 ;; this, a new newline inserted after an old newline (e.g. by C-j) would 588Without this, a new newline inserted after an old newline (e.g. by C-j) would
609 ;; inherit any c-awk-NL-prop from the old newline. This would be a Bad 589inherit any `c-awk-NL-prop' from the old newline. This would be a Bad
610 ;; Thing. This function's action is required by c-put-char-property. 590Thing. This function's action is required by `c-put-char-property'."
611 (if (and (boundp 'text-property-default-nonsticky) ; doesn't exist in XEmacs 591 (if (and (boundp 'text-property-default-nonsticky) ; doesn't exist in XEmacs
612 (not (assoc 'c-awk-NL-prop text-property-default-nonsticky))) 592 (not (assoc 'c-awk-NL-prop text-property-default-nonsticky)))
613 (setq text-property-default-nonsticky 593 (setq text-property-default-nonsticky
@@ -650,15 +630,15 @@
650;; to allow this. 630;; to allow this.
651 631
652(defun c-awk-beginning-of-logical-line (&optional pos) 632(defun c-awk-beginning-of-logical-line (&optional pos)
653;; Go back to the start of the (apparent) current line (or the start of the 633 "Go back to the start of the (apparent) current line (or the start of the
654;; line containing POS), returning the buffer position of that point. I.e., 634line containing POS), returning the buffer position of that point. I.e.,
655;; go back to the last line which doesn't have an escaped EOL before it. 635go back to the last line which doesn't have an escaped EOL before it.
656;; 636
657;; This is guaranteed to be "safe" for syntactic analysis, i.e. outwith any 637This is guaranteed to be \"safe\" for syntactic analysis, i.e. outwith any
658;; comment, string or regexp. IT MAY WELL BE that this function should not be 638comment, string or regexp. IT MAY WELL BE that this function should not be
659;; executed on a narrowed buffer. 639executed on a narrowed buffer.
660;; 640
661;; This function might do hidden buffer changes. 641This function might do hidden buffer changes."
662 (if pos (goto-char pos)) 642 (if pos (goto-char pos))
663 (forward-line 0) 643 (forward-line 0)
664 (while (and (> (point) (point-min)) 644 (while (and (> (point) (point-min))
@@ -667,15 +647,15 @@
667 (point)) 647 (point))
668 648
669(defun c-awk-beyond-logical-line (&optional pos) 649(defun c-awk-beyond-logical-line (&optional pos)
670;; Return the position just beyond the (apparent) current logical line, or the 650 "Return the position just beyond the (apparent) current logical line, or the
671;; one containing POS. This is usually the beginning of the next line which 651one containing POS. This is usually the beginning of the next line which
672;; doesn't follow an escaped EOL. At EOB, this will be EOB. 652doesn't follow an escaped EOL. At EOB, this will be EOB.
673;; 653
674;; Point is unchanged. 654Point is unchanged.
675;; 655
676;; This is guaranteed to be "safe" for syntactic analysis, i.e. outwith any 656This is guaranteed to be \"safe\" for syntactic analysis, i.e. outwith any
677;; comment, string or regexp. IT MAY WELL BE that this function should not be 657comment, string or regexp. IT MAY WELL BE that this function should not be
678;; executed on a narrowed buffer. 658executed on a narrowed buffer."
679 (save-excursion 659 (save-excursion
680 (if pos (goto-char pos)) 660 (if pos (goto-char pos))
681 (end-of-line) 661 (end-of-line)
@@ -693,19 +673,19 @@
693;; or comment. 673;; or comment.
694 674
695(defun c-awk-set-string-regexp-syntax-table-properties (beg end) 675(defun c-awk-set-string-regexp-syntax-table-properties (beg end)
696;; BEG and END bracket a (possibly unterminated) string or regexp. The 676 "BEG and END bracket a (possibly unterminated) string or regexp. The
697;; opening delimiter is after BEG, and the closing delimiter, IF ANY, is AFTER 677opening delimiter is after BEG, and the closing delimiter, IF ANY, is AFTER
698;; END. Set the appropriate syntax-table properties on the delimiters and 678END. Set the appropriate syntax-table properties on the delimiters and
699;; contents of this string/regex. 679contents of this string/regex.
700;; 680
701;; "String" here can also mean a gawk 3.1 "localizable" string which starts 681\"String\" here can also mean a gawk 3.1 \"localizable\" string which starts
702;; with _". In this case, we step over the _ and ignore it; It will get it's 682with _\". In this case, we step over the _ and ignore it; It will get it's
703;; font from an entry in awk-font-lock-keywords. 683font from an entry in `awk-font-lock-keywords'.
704;; 684
705;; If the closing delimiter is missing (i.e., there is an EOL there) set the 685If the closing delimiter is missing (i.e., there is an EOL there) set the
706;; STRING-FENCE property on the opening " or / and closing EOL. 686STRING-FENCE property on the opening \" or / and closing EOL.
707;; 687
708;; This function does hidden buffer changes. 688This function does hidden buffer changes."
709 (if (eq (char-after beg) ?_) (setq beg (1+ beg))) 689 (if (eq (char-after beg) ?_) (setq beg (1+ beg)))
710 690
711 ;; First put the properties on the delimiters. 691 ;; First put the properties on the delimiters.
@@ -726,13 +706,13 @@
726 (c-put-char-property (1- (point)) 'syntax-table '(1)))))) 706 (c-put-char-property (1- (point)) 'syntax-table '(1))))))
727 707
728(defun c-awk-syntax-tablify-string () 708(defun c-awk-syntax-tablify-string ()
729 ;; Point is at the opening " or _" of a string. Set the syntax-table 709 "Point is at the opening \" or _\" of a string. Set the syntax-table
730 ;; properties on this string, leaving point just after the string. 710properties on this string, leaving point just after the string.
731 ;; 711
732 ;; The result is nil if a / immediately after the string would be a regexp 712The result is nil if a / immediately after the string would be a regexp
733 ;; opener, t if it would be a division sign. 713opener, t if it would be a division sign.
734 ;; 714
735 ;; This function does hidden buffer changes. 715This function does hidden buffer changes."
736 (search-forward-regexp c-awk-string-without-end-here-re nil t) ; a (possibly unterminated) string 716 (search-forward-regexp c-awk-string-without-end-here-re nil t) ; a (possibly unterminated) string
737 (c-awk-set-string-regexp-syntax-table-properties 717 (c-awk-set-string-regexp-syntax-table-properties
738 (match-beginning 0) (match-end 0)) 718 (match-beginning 0) (match-end 0))
@@ -745,19 +725,19 @@
745 (t nil))) ; Unterminated string at EOB 725 (t nil))) ; Unterminated string at EOB
746 726
747(defun c-awk-syntax-tablify-/ (anchor anchor-state-/div) 727(defun c-awk-syntax-tablify-/ (anchor anchor-state-/div)
748 ;; Point is at a /. Determine whether this is a division sign or a regexp 728 "Point is at a /. Determine whether this is a division sign or a regexp
749 ;; opener, and if the latter, apply syntax-table properties to the entire 729opener, and if the latter, apply syntax-table properties to the entire
750 ;; regexp. Point is left immediately after the division sign or regexp, as 730regexp. Point is left immediately after the division sign or regexp, as
751 ;; the case may be. 731the case may be.
752 ;; 732
753 ;; ANCHOR-STATE-/DIV identifies whether a / at ANCHOR would have been a 733ANCHOR-STATE-/DIV identifies whether a / at ANCHOR would have been a
754 ;; division sign (value t) or a regexp opener (value nil). The idea is that 734division sign (value t) or a regexp opener (value nil). The idea is that
755 ;; we analyze the line from ANCHOR up till point to determine what the / at 735we analyze the line from ANCHOR up till point to determine what the / at
756 ;; point is. 736point is.
757 ;; 737
758 ;; The result is what ANCHOR-STATE-/DIV (see above) is where point is left. 738The result is what ANCHOR-STATE-/DIV (see above) is where point is left.
759 ;; 739
760 ;; This function does hidden buffer changes. 740This function does hidden buffer changes."
761 (let ((/point (point))) 741 (let ((/point (point)))
762 (goto-char anchor) 742 (goto-char anchor)
763 ;; Analyze the line to find out what the / is. 743 ;; Analyze the line to find out what the / is.
@@ -782,30 +762,30 @@
782 (t nil))))) ; Unterminated regexp at EOB 762 (t nil))))) ; Unterminated regexp at EOB
783 763
784(defun c-awk-set-syntax-table-properties (lim) 764(defun c-awk-set-syntax-table-properties (lim)
785;; Scan the buffer text between point and LIM, setting (and clearing) the 765 "Scan the buffer text between point and LIM, setting (and clearing) the
786;; syntax-table property where necessary. 766syntax-table property where necessary.
787;; 767
788;; This function is designed to be called as the FUNCTION in a MATCHER in 768This function is designed to be called as the FUNCTION in a MATCHER in
789;; font-lock-syntactic-keywords, and it always returns NIL (to inhibit 769font-lock-syntactic-keywords, and it always returns NIL (to inhibit
790;; repeated calls from font-lock: See elisp info page "Search-based 770repeated calls from font-lock: See elisp info page \"Search-based
791;; Fontification"). It also gets called, with a bit of glue, from 771Fontification\"). It also gets called, with a bit of glue, from
792;; after-change-functions when font-lock isn't active. Point is left 772after-change-functions when font-lock isn't active. Point is left
793;; "undefined" after this function exits. THE BUFFER SHOULD HAVE BEEN 773\"undefined\" after this function exits. THE BUFFER SHOULD HAVE BEEN
794;; WIDENED, AND ANY PRECIOUS MATCH-DATA SAVED BEFORE CALLING THIS ROUTINE. 774WIDENED, AND ANY PRECIOUS MATCH-DATA SAVED BEFORE CALLING THIS ROUTINE.
795;; 775
796;; We need to set/clear the syntax-table property on: 776We need to set/clear the syntax-table property on:
797;; (i) / - It is set to "string" on a / which is the opening or closing 777\(i) / - It is set to \"string\" on a / which is the opening or closing
798;; delimiter of the properly terminated regexp (and left unset on a 778 delimiter of the properly terminated regexp (and left unset on a
799;; division sign). 779 division sign).
800;; (ii) the opener of an unterminated string/regexp, we set the property 780\(ii) the opener of an unterminated string/regexp, we set the property
801;; "generic string delimiter" on both the opening " or / and the end of the 781 \"generic string delimiter\" on both the opening \" or / and the end of the
802;; line where the closing delimiter is missing. 782 line where the closing delimiter is missing.
803;; (iii) "s inside strings/regexps (these will all be escaped "s). They are 783\(iii) \"s inside strings/regexps (these will all be escaped \"s). They are
804;; given the property "punctuation". This will later allow other routines 784 given the property \"punctuation\". This will later allow other routines
805;; to use the regexp "\\S\"*" to skip over the string innards. 785 to use the regexp \"\\\\S\\\"*\" to skip over the string innards.
806;; (iv) Inside a comment, all syntax-table properties are cleared. 786\(iv) Inside a comment, all syntax-table properties are cleared.
807;; 787
808;; This function does hidden buffer changes. 788This function does hidden buffer changes."
809 (let (anchor 789 (let (anchor
810 (anchor-state-/div nil)) ; t means a following / would be a div sign. 790 (anchor-state-/div nil)) ; t means a following / would be a div sign.
811 (c-awk-beginning-of-logical-line) ; ACM 2002/7/21. This is probably redundant. 791 (c-awk-beginning-of-logical-line) ; ACM 2002/7/21. This is probably redundant.
@@ -845,26 +825,26 @@
845;; Set in c-awk-record-region-clear-NL and used in c-awk-after-change. 825;; Set in c-awk-record-region-clear-NL and used in c-awk-after-change.
846 826
847(defun c-awk-record-region-clear-NL (beg end) 827(defun c-awk-record-region-clear-NL (beg end)
848;; This function is called exclusively from the before-change-functions hook. 828 "This function is called exclusively from the `before-change-functions' hook.
849;; It does two things: Finds the end of the (logical) line on which END lies, 829It does two things: Finds the end of the (logical) line on which END lies,
850;; and clears c-awk-NL-prop text properties from this point onwards. BEG is 830and clears `c-awk-NL-prop' text properties from this point onwards. BEG is
851;; ignored. 831ignored.
852;; 832
853;; On entry, the buffer will have been widened and match-data will have been 833On entry, the buffer will have been widened and match-data will have been
854;; saved; point is undefined on both entry and exit; the return value is 834saved; point is undefined on both entry and exit; the return value is
855;; ignored. 835ignored.
856;; 836
857;; This function does hidden buffer changes. 837This function does hidden buffer changes."
858 (c-save-buffer-state () 838 (c-save-buffer-state ()
859 (setq c-awk-old-ByLL (c-awk-beyond-logical-line end)) 839 (setq c-awk-old-ByLL (c-awk-beyond-logical-line end))
860 (c-save-buffer-state nil 840 (c-save-buffer-state nil
861 (c-awk-clear-NL-props end (point-max))))) 841 (c-awk-clear-NL-props end (point-max)))))
862 842
863(defun c-awk-end-of-change-region (beg end old-len) 843(defun c-awk-end-of-change-region (beg end old-len)
864 ;; Find the end of the region which needs to be font-locked after a change. 844 "Find the end of the region which needs to be font-locked after a change.
865 ;; This is the end of the logical line on which the change happened, either 845This is the end of the logical line on which the change happened, either
866 ;; as it was before the change, or as it is now, whichever is later. 846as it was before the change, or as it is now, whichever is later.
867 ;; N.B. point is left undefined. 847N.B. point is left undefined."
868 (max (+ (- c-awk-old-ByLL old-len) (- end beg)) 848 (max (+ (- c-awk-old-ByLL old-len) (- end beg))
869 (c-awk-beyond-logical-line end))) 849 (c-awk-beyond-logical-line end)))
870 850
@@ -875,22 +855,25 @@
875;; Don't overlook the possibility of the buffer change being the "recapturing" 855;; Don't overlook the possibility of the buffer change being the "recapturing"
876;; of a previously escaped newline. 856;; of a previously escaped newline.
877 857
858(defvar c-new-BEG)
859(defvar c-new-END)
860
878;; ACM 2008-02-05: 861;; ACM 2008-02-05:
879(defun c-awk-extend-and-syntax-tablify-region (beg end old-len) 862(defun c-awk-extend-and-syntax-tablify-region (beg end old-len)
880 ;; Expand the region (BEG END) as needed to (c-new-BEG c-new-END) then put 863 "Expand the region (BEG END) as needed to (c-new-BEG c-new-END) then put
881 ;; `syntax-table' properties on this region. 864`syntax-table' properties on this region.
882 ;; 865
883 ;; This function is called from an after-change function, BEG END and 866This function is called from an after-change function, BEG END and
884 ;; OLD-LEN being the standard parameters. 867OLD-LEN being the standard parameters.
885 ;; 868
886 ;; Point is undefined both before and after this function call, the buffer 869Point is undefined both before and after this function call, the buffer
887 ;; has been widened, and match-data saved. The return value is ignored. 870has been widened, and match-data saved. The return value is ignored.
888 ;; 871
889 ;; It prepares the buffer for font 872It prepares the buffer for font
890 ;; locking, hence must get called before `font-lock-after-change-function'. 873locking, hence must get called before `font-lock-after-change-function'.
891 ;; 874
892 ;; This function is the AWK value of `c-before-font-lock-function'. 875This function is the AWK value of `c-before-font-lock-function'.
893 ;; It does hidden buffer changes. 876It does hidden buffer changes."
894 (c-save-buffer-state () 877 (c-save-buffer-state ()
895 (setq c-new-END (c-awk-end-of-change-region beg end old-len)) 878 (setq c-new-END (c-awk-end-of-change-region beg end old-len))
896 (setq c-new-BEG (c-awk-beginning-of-logical-line beg)) 879 (setq c-new-BEG (c-awk-beginning-of-logical-line beg))
@@ -962,7 +945,8 @@ std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\
962 "match" "mktime" "or" "print" "printf" "rand" "rshift" 945 "match" "mktime" "or" "print" "printf" "rand" "rshift"
963 "sin" "split" "sprintf" "sqrt" "srand" "stopme" 946 "sin" "split" "sprintf" "sqrt" "srand" "stopme"
964 "strftime" "strtonum" "sub" "substr" "system" 947 "strftime" "strtonum" "sub" "substr" "system"
965 "systime" "tolower" "toupper" "xor") t) 948 "systime" "tolower" "toupper" "xor")
949 t)
966 "\\>") 950 "\\>")
967 0 c-preprocessor-face-name)) 951 0 c-preprocessor-face-name))
968 952
@@ -993,21 +977,21 @@ std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\
993;; The following three regexps differ from those earlier on in cc-awk.el in 977;; The following three regexps differ from those earlier on in cc-awk.el in
994;; that they assume the syntax-table properties have been set. They are thus 978;; that they assume the syntax-table properties have been set. They are thus
995;; not useful for code which sets these properties. 979;; not useful for code which sets these properties.
996(defconst c-awk-terminated-regexp-or-string-here-re "\\=\\s\"\\S\"*\\s\"") 980(defconst c-awk-terminated-regexp-or-string-here-re "\\=\\s\"\\S\"*\\s\""
997;; Matches a terminated string/regexp. 981 "Matches a terminated string/regexp.")
998 982
999(defconst c-awk-unterminated-regexp-or-string-here-re "\\=\\s|\\S|*$") 983(defconst c-awk-unterminated-regexp-or-string-here-re "\\=\\s|\\S|*$"
1000;; Matches an unterminated string/regexp, NOT including the eol at the end. 984 "Matches an unterminated string/regexp, NOT including the eol at the end.")
1001 985
1002(defconst c-awk-harmless-pattern-characters* 986(defconst c-awk-harmless-pattern-characters*
1003 (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*")) 987 (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*")
1004;; Matches any "harmless" character in a pattern or an escaped character pair. 988 "Matches any \"harmless\" character in a pattern or an escaped character pair.")
1005 989
1006(defun c-awk-at-statement-end-p () 990(defun c-awk-at-statement-end-p ()
1007 ;; Point is not inside a comment or string. Is it AT the end of a 991 "Point is not inside a comment or string. Is it AT the end of a
1008 ;; statement? This means immediately after the last non-ws character of the 992statement? This means immediately after the last non-ws character of the
1009 ;; statement. The caller is responsible for widening the buffer, if 993statement. The caller is responsible for widening the buffer, if
1010 ;; appropriate. 994appropriate."
1011 (and (not (bobp)) 995 (and (not (bobp))
1012 (save-excursion 996 (save-excursion
1013 (backward-char) 997 (backward-char)
@@ -1057,13 +1041,13 @@ comment at the start of cc-engine.el for more info."
1057 (eq arg 0))))) 1041 (eq arg 0)))))
1058 1042
1059(defun c-awk-forward-awk-pattern () 1043(defun c-awk-forward-awk-pattern ()
1060 ;; Point is at the start of an AWK pattern (which may be null) or function 1044 "Point is at the start of an AWK pattern (which may be null) or function
1061 ;; declaration. Move to the pattern's end, and past any trailing space or 1045declaration. Move to the pattern's end, and past any trailing space or
1062 ;; comment. Typically, we stop at the { which denotes the corresponding AWK 1046comment. Typically, we stop at the { which denotes the corresponding AWK
1063 ;; action/function body. Otherwise we stop at the EOL (or ;) marking the 1047action/function body. Otherwise we stop at the EOL (or ;) marking the
1064 ;; absence of an explicit action. 1048absence of an explicit action.
1065 ;; 1049
1066 ;; This function might do hidden buffer changes. 1050This function might do hidden buffer changes."
1067 (while 1051 (while
1068 (progn 1052 (progn
1069 (search-forward-regexp c-awk-harmless-pattern-characters*) 1053 (search-forward-regexp c-awk-harmless-pattern-characters*)
@@ -1080,9 +1064,9 @@ comment at the start of cc-engine.el for more info."
1080 ((looking-at "/") (forward-char) t))))) ; division sign. 1064 ((looking-at "/") (forward-char) t))))) ; division sign.
1081 1065
1082(defun c-awk-end-of-defun1 () 1066(defun c-awk-end-of-defun1 ()
1083 ;; point is at the start of a "defun". Move to its end. Return end position. 1067 "Point is at the start of a \"defun\". Move to its end. Return end position.
1084 ;; 1068
1085 ;; This function might do hidden buffer changes. 1069This function might do hidden buffer changes."
1086 (c-awk-forward-awk-pattern) 1070 (c-awk-forward-awk-pattern)
1087 (cond 1071 (cond
1088 ((looking-at "{") (goto-char (scan-sexps (point) 1))) 1072 ((looking-at "{") (goto-char (scan-sexps (point) 1)))
@@ -1092,10 +1076,10 @@ comment at the start of cc-engine.el for more info."
1092 (point)) 1076 (point))
1093 1077
1094(defun c-awk-beginning-of-defun-p () 1078(defun c-awk-beginning-of-defun-p ()
1095 ;; Are we already at the beginning of a defun? (i.e. at code in column 0 1079 "Are we already at the beginning of a defun? (i.e. at code in column 0
1096 ;; which isn't a }, and isn't a continuation line of any sort. 1080which isn't a }, and isn't a continuation line of any sort.
1097 ;; 1081
1098 ;; This function might do hidden buffer changes. 1082This function might do hidden buffer changes."
1099 (and (looking-at "^[^#} \t\n\r]") 1083 (and (looking-at "^[^#} \t\n\r]")
1100 (not (c-awk-prev-line-incomplete-p)))) 1084 (not (c-awk-prev-line-incomplete-p))))
1101 1085
@@ -1145,6 +1129,5 @@ comment at the start of cc-engine.el for more info."
1145 (goto-char (min start-point end-point))))))) 1129 (goto-char (min start-point end-point)))))))
1146 1130
1147 1131
1148(cc-provide 'cc-awk) ; Changed from 'awk-mode, ACM 2002/5/21 1132(provide 'cc-awk)
1149 1133;;; cc-awk.el ends here
1150;;; awk-mode.el ends here