Mercurial > emacs
annotate lisp/progmodes/cc-awk.el @ 65939:ba4c1a7f880b
* cmdargs.texi (Icons X): Removed options -i, -itype, --icon-type,
added -nb, --no-bitmap-icon.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sun, 09 Oct 2005 06:59:21 +0000 |
parents | 629afbe74e61 |
children | 04d2abb755d9 edf295560b5a |
rev | line source |
---|---|
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1 ;;; cc-awk.el --- AWK specific code within cc-mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2 |
64699
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1988, 94, 96, 2000, 2001, 2002, 2003, 2004, 2005 |
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
5 |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
6 ;; Author: Alan Mackenzie <acm@muc.de> (originally based on awk-mode.el) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
7 ;; Maintainer: FSF |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
8 ;; Keywords: AWK, cc-mode, unix, languages |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
9 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
11 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
15 ;; any later version. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
16 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
21 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
26 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
27 ;;; Commentary: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
28 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
29 ;; This file contains (most of) the adaptations to cc-mode required for the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
30 ;; integration of AWK Mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
31 ;; It is organised thusly: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
32 ;; 1. The AWK Mode syntax table. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
33 ;; 2. Indentation calculation stuff ("c-awk-NL-prop text-property"). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
34 ;; 3. Syntax-table property/font-locking stuff, but not including the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
35 ;; font-lock-keywords setting. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
36 ;; 4. The AWK Mode before/after-change-functions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
37 ;; 5. AWK Mode specific versions of commands like beginning-of-defun. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
38 ;; The AWK Mode keymap, abbreviation table, and the mode function itself are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
39 ;; in cc-mode.el. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
40 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
41 ;;; Code: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
42 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
43 (eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
44 (let ((load-path |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
45 (if (and (boundp 'byte-compile-dest-file) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
46 (stringp byte-compile-dest-file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
47 (cons (file-name-directory byte-compile-dest-file) load-path) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
48 load-path))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
49 (load "cc-bytecomp" nil t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
50 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
51 (cc-require 'cc-defs) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
52 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
53 ;; Silence the byte compiler. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
54 (cc-bytecomp-defvar font-lock-mode) ; Checked with boundp before use. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
55 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
56 ;; Some functions in cc-engine that are used below. There's a cyclic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
57 ;; dependency so it can't be required here. (Perhaps some functions |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
58 ;; could be moved to cc-engine to avoid it.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
59 (cc-bytecomp-defun c-backward-token-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
60 (cc-bytecomp-defun c-beginning-of-statement-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
61 (cc-bytecomp-defun c-backward-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
62 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
63 (defvar awk-mode-syntax-table |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
64 (let ((st (make-syntax-table))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
65 (modify-syntax-entry ?\\ "\\" st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
66 (modify-syntax-entry ?\n "> " st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
67 (modify-syntax-entry ?\r "> " st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
68 (modify-syntax-entry ?\f "> " st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
69 (modify-syntax-entry ?\# "< " st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
70 ;; / can delimit regexes or be a division operator. By default we assume |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
71 ;; that it is a division sign, and fix the regexp operator cases with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
72 ;; `font-lock-syntactic-keywords'. |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
73 (modify-syntax-entry ?/ "." st) ; ACM 2002/4/27. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
74 (modify-syntax-entry ?* "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
75 (modify-syntax-entry ?+ "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
76 (modify-syntax-entry ?- "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
77 (modify-syntax-entry ?= "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
78 (modify-syntax-entry ?% "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
79 (modify-syntax-entry ?< "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
80 (modify-syntax-entry ?> "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
81 (modify-syntax-entry ?& "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
82 (modify-syntax-entry ?| "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
83 (modify-syntax-entry ?_ "_" st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
84 (modify-syntax-entry ?\' "." st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
85 st) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
86 "Syntax table in use in AWK Mode buffers.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
87 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
88 ;; ACM, 2002/5/29: |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
89 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
90 ;; The next section of code is about determining whether or not an AWK |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
91 ;; statement is complete or not. We use this to indent the following line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
92 ;; The determination is pretty straightforward in C, where a statement ends |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
93 ;; with either a ; or a }. Only "while" really gives any trouble there, since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
94 ;; it might be the end of a do-while. In AWK, on the other hand, semicolons |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
95 ;; are rarely used, and EOLs _usually_ act as "virtual semicolons". In |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
96 ;; addition, we have the complexity of escaped EOLs. The core of this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
97 ;; analysis is in the middle of the function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
98 ;; c-awk-calculate-NL-prop-prev-line, about 130 lines lower down. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
99 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
100 ;; To avoid continually repeating this expensive analysis, we "cache" its |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
101 ;; result in a text-property, c-awk-NL-prop, whose value for a line is set on |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
102 ;; the EOL (if any) which terminates that line. Should the property be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
103 ;; required for the very last line (which has no EOL), it is calculated as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
104 ;; required but not cached. The c-awk-NL-prop property should be thought of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
105 ;; as only really valid immediately after a buffer change, not a permanently |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
106 ;; set property. (By contrast, the syntax-table text properties (set by an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
107 ;; after-change function) must be constantly updated for the mode to work |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
108 ;; properly). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
109 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
110 ;; The valid values for c-awk-NL-prop are: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
111 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
112 ;; nil The property is not currently set for this line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
113 ;; '#' There is NO statement on this line (at most a comment), and no open |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
114 ;; statement from a previous line which could have been completed on this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
115 ;; line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
116 ;; '{' There is an unfinished statement on this (or a previous) line which |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
117 ;; doesn't require \s to continue onto another line, e.g. the line ends |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
118 ;; with {, or the && operator, or "if (condition)". Note that even if the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
119 ;; newline is redundantly escaped, it remains a '{' line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
120 ;; '\' There is an escaped newline at the end of this line and this '\' is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
121 ;; essential to the syntax of the program. (i.e. if it had been a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
122 ;; frivolous \, it would have been ignored and the line been given one of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
123 ;; the other property values.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
124 ;; ';' A statement is completed as the last thing (aside from ws) on the line - |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
125 ;; i.e. there is (at least part of) a statement on this line, and the last |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
126 ;; statement on the line is complete, OR (2002/10/25) the line is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
127 ;; content-free but terminates a statement from the preceding (continued) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
128 ;; line (which has property \). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
129 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
130 ;; This set of values has been chosen so that the property's value on a line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
131 ;; is completely determined by the contents of the line and the property on |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
132 ;; the previous line, EXCEPT for where a "while" might be the closing |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
133 ;; statement of a do-while. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
134 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
135 (defun c-awk-after-if-for-while-condition-p (&optional do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
136 ;; Are we just after the ) in "if/for/while (<condition>)"? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
137 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
138 ;; Note that the end of the ) in a do .... while (<condition>) doesn't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
139 ;; count, since the purpose of this routine is essentially to decide |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
140 ;; whether to indent the next line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
141 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
142 ;; DO-LIM sets a limit on how far back we search for the "do" of a possible |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
143 ;; do-while. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
144 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
145 (eq (char-before) ?\)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
146 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
147 (let ((par-pos (c-safe (scan-lists (point) -1 0)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
148 (when par-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
149 (goto-char par-pos) ; back over "(...)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
150 (c-backward-token-1) ; BOB isn't a problem. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
151 (or (looking-at "\\(if\\|for\\)\\>\\([^_]\\|$\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
152 (and (looking-at "while\\>\\([^_]\\|$\\)") ; Ensure this isn't a do-while. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
153 (not (eq (c-beginning-of-statement-1 do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
154 'beginning))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
155 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
156 (defun c-awk-after-function-decl-param-list () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
157 ;; Are we just after the ) in "function foo (bar)" ? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
158 (and (eq (char-before) ?\)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
159 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
160 (let ((par-pos (c-safe (scan-lists (point) -1 0)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
161 (when par-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
162 (goto-char par-pos) ; back over "(...)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
163 (c-backward-token-1) ; BOB isn't a problem |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
164 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
165 (progn (c-backward-token-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
166 (looking-at "func\\(tion\\)?\\>")))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
167 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
168 ;; 2002/11/8: FIXME! Check c-backward-token-1/2 for success (0 return code). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
169 (defun c-awk-after-continue-token () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
170 ;; Are we just after a token which can be continued onto the next line without |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
171 ;; a backslash? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
172 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
173 (c-backward-token-1) ; FIXME 2002/10/27. What if this fails? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
174 (if (and (looking-at "[&|]") (not (bobp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
175 (backward-char)) ; c-backward-token-1 doesn't do this :-( |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
176 (looking-at "[,{?:]\\|&&\\|||\\|do\\>\\|else\\>"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
177 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
178 (defun c-awk-after-rbrace-or-statement-semicolon () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
179 ;; Are we just after a } or a ; which closes a statement? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
180 ;; Be careful about ;s in for loop control bits. They don't count! |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
181 (or (eq (char-before) ?\}) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
182 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
183 (eq (char-before) ?\;) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
184 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
185 (let ((par-pos (c-safe (scan-lists (point) -1 1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
186 (when par-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
187 (goto-char par-pos) ; go back to containing ( |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
188 (not (and (looking-at "(") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
189 (c-backward-token-1) ; BOB isn't a problem |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
190 (looking-at "for\\>"))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
191 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
192 (defun c-awk-back-to-contentful-text-or-NL-prop () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
193 ;; Move back to just after the first found of either (i) an EOL which has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
194 ;; the c-awk-NL-prop text-property set; or (ii) non-ws text; or (iii) BOB. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
195 ;; We return either the value of c-awk-NL-prop (in case (i)) or nil. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
196 ;; Calling function can best distinguish cases (ii) and (iii) with (bolp). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
197 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
198 ;; Note that an escaped eol counts as whitespace here. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
199 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
200 ;; Kludge: If c-backward-syntactic-ws gets stuck at a BOL, it is likely |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
201 ;; that the previous line contains an unterminated string (without \). In |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
202 ;; this case, assume that the previous line's c-awk-NL-prop is a ;. |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
203 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
204 ;; POINT MUST BE AT THE START OF A LINE when calling this function. This |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
205 ;; is to ensure that the various backward-comment functions will work |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
206 ;; properly. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
207 (let ((nl-prop nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
208 bol-pos bsws-pos) ; starting pos for a backward-syntactic-ws call. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
209 (while ;; We are at a BOL here. Go back one line each iteration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
210 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
211 (not (bobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
212 (not (setq nl-prop (c-get-char-property (1- (point)) 'c-awk-NL-prop))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
213 (progn (setq bol-pos (c-point 'bopl)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
214 (setq bsws-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
215 ;; N.B. the following function will not go back past an EOL if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
216 ;; there is an open string (without \) on the previous line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
217 (c-backward-syntactic-ws bol-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
218 (or (/= (point) bsws-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
219 (progn (setq nl-prop ?\;) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
220 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
221 ;; If we had a backslash at EOL, c-backward-syntactic-ws will |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
222 ;; have gone backwards over it. Check the backslash was "real". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
223 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
224 (if (looking-at "[ \t]*\\\\+$") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
225 (if (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
226 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
227 (search-backward-regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
228 "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\$" ; ODD number of \s at EOL :-) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
229 bol-pos t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
230 (progn (end-of-line) ; escaped EOL. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
231 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
232 (c-backward-syntactic-ws bol-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
233 (end-of-line))) ; The \ at eol is a fake. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
234 (bolp)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
235 nl-prop)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
236 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
237 (defun c-awk-calculate-NL-prop-prev-line (&optional do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
238 ;; Calculate and set the value of the c-awk-NL-prop on the immediately |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
239 ;; preceding EOL. This may also involve doing the same for several |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
240 ;; preceding EOLs. |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
241 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
242 ;; NOTE that if the property was already set, we return it without |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
243 ;; recalculation. (This is by accident rather than design.) |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
244 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
245 ;; Return the property which got set (or was already set) on the previous |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
246 ;; line. Return nil if we hit BOB. |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
247 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
248 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
249 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
250 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
251 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
252 (let* ((pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
253 (nl-prop (c-awk-back-to-contentful-text-or-NL-prop))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
254 ;; We are either (1) at a BOL (with nl-prop containing the previous |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
255 ;; line's c-awk-NL-prop) or (2) after contentful text on a line. At |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
256 ;; the BOB counts as case (1), so we test next for bolp rather than |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
257 ;; non-nil nl-prop. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
258 (when (not (bolp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
259 (setq nl-prop |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
260 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
261 ;; Incomplete statement which doesn't require escaped EOL? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
262 ((or (c-awk-after-if-for-while-condition-p do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
263 (c-awk-after-function-decl-param-list) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
264 (c-awk-after-continue-token)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
265 ?\{) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
266 ;; Escaped EOL (where there's also something to continue)? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
267 ((and (looking-at "[ \t]*\\\\$") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
268 (not (c-awk-after-rbrace-or-statement-semicolon))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
269 ?\\) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
270 (t ?\;))) ; A statement was completed on this line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
271 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
272 (c-put-char-property (point) 'c-awk-NL-prop nl-prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
273 (forward-line)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
274 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
275 ;; We are now at a (possibly empty) sequence of content-free lines. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
276 ;; Set c-awk-NL-prop on each of these lines's EOL. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
277 (while (< (point) pos) ; one content-free line each iteration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
278 (cond ; recalculate nl-prop from previous line's value. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
279 ((memq nl-prop '(?\; nil)) (setq nl-prop ?\#)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
280 ((eq nl-prop ?\\) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
281 (if (not (looking-at "[ \t]*\\\\$")) (setq nl-prop ?\;))) ; was ?\# 2002/10/25 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
282 ;; ?\# (empty line) and ?\{ (open stmt) don't change. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
283 ) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
284 (forward-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
285 (c-put-char-property (1- (point)) 'c-awk-NL-prop nl-prop)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
286 nl-prop)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
287 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
288 (defun c-awk-get-NL-prop-prev-line (&optional do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
289 ;; Get the c-awk-NL-prop text-property from the previous line, calculating |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
290 ;; it if necessary. Return nil iff we're already at BOB. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
291 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
292 (if (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
293 nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
294 (or (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
295 (c-awk-calculate-NL-prop-prev-line do-lim)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
296 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
297 (defun c-awk-get-NL-prop-cur-line (&optional do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
298 ;; Get the c-awk-NL-prop text-property from the current line, calculating it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
299 ;; if necessary. (As a special case, the property doesn't get set on an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
300 ;; empty line at EOB (there's no position to set the property on), but the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
301 ;; function returns the property value an EOL would have got.) |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
302 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
303 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
304 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
305 (let ((extra-nl nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
306 (end-of-line) ; Necessary for the following test to work. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
307 (when (= (forward-line) 1) ; if we were on the last line.... |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
308 (insert-char ?\n 1) ; ...artificial eol is needed for comment detection. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
309 (setq extra-nl t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
310 (prog1 (c-awk-get-NL-prop-prev-line do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
311 (if extra-nl (delete-backward-char 1)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
312 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
313 (defun c-awk-prev-line-incomplete-p (&optional do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
314 ;; Is there an incomplete statement at the end of the previous line? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
315 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
316 (memq (c-awk-get-NL-prop-prev-line do-lim) '(?\\ ?\{))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
317 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
318 (defun c-awk-cur-line-incomplete-p (&optional do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
319 ;; Is there an incomplete statement at the end of the current line? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
320 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
321 (memq (c-awk-get-NL-prop-cur-line do-lim) '(?\\ ?\{))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
322 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
323 (defun c-awk-completed-stmt-ws-ends-prev-line-p (&optional do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
324 ;; Is there a termination of a statement as the last thing (apart from an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
325 ;; optional comment) on the previous line? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
326 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
327 (eq (c-awk-get-NL-prop-prev-line do-lim) ?\;)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
328 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
329 (defun c-awk-completed-stmt-ws-ends-line-p (&optional pos do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
330 ;; Same as previous function, but for the line containing position POS (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
331 ;; the current line if POS is omitted). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
332 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
333 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
334 (if pos (goto-char pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
335 (eq (c-awk-get-NL-prop-cur-line do-lim) ?\;))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
336 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
337 (defun c-awk-after-logical-semicolon (&optional do-lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
338 ;; Are we at BOL, the preceding EOL being a "logical semicolon"? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
339 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
340 (and (bolp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
341 (eq (c-awk-get-NL-prop-prev-line do-lim) ?\;))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
342 |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
343 (defun c-awk-backward-syntactic-ws (&optional lim) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
344 ;; Skip backwards over awk-syntactic whitespace. This is whitespace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
345 ;; characters, comments, and NEWLINES WHICH AREN'T "VIRTUAL SEMICOLONS". For |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
346 ;; this function, a newline isn't a "virtual semicolon" if that line ends with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
347 ;; a real semicolon (or closing brace). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
348 ;; However if point starts inside a comment or preprocessor directive, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
349 ;; content of it is not treated as whitespace. LIM (optional) sets a limit on |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
350 ;; the backward movement. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
351 (let ((lim (or lim (point-min))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
352 after-real-br) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
353 (c-backward-syntactic-ws (max lim (c-point 'bol))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
354 (while ; go back one WS line each time round this loop. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
355 (and (bolp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
356 (> (point) lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
357 (/= (c-awk-get-NL-prop-prev-line) ?\;) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
358 (/= (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
359 ;; The following function requires point at BONL [not EOL] to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
360 ;; recognise a preceding comment,. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
361 (progn (c-backward-syntactic-ws (max lim (c-point 'bopl))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
362 (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
363 ;; Does the previous line end with a real ; or }? If so, go back to it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
364 (if (and (bolp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
365 (eq (c-awk-get-NL-prop-prev-line) ?\;) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
366 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
367 (c-backward-syntactic-ws (max lim (c-point 'bopl))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
368 (setq after-real-br (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
369 (c-awk-after-rbrace-or-statement-semicolon))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
370 (goto-char after-real-br)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
371 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
372 (defun c-awk-NL-prop-not-set () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
373 ;; Is the NL-prop on the current line either nil or unset? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
374 (not (c-get-char-property (c-point 'eol) 'c-awk-NL-prop))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
375 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
376 (defun c-awk-clear-NL-props (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
377 ;; This function is run from before-change-hooks. It clears the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
378 ;; c-awk-NL-prop text property from beg to the end of the buffer (The END |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
379 ;; parameter is ignored). This ensures that the indentation engine will |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
380 ;; never use stale values for this property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
381 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
382 (widen) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
383 (c-clear-char-properties beg (point-max) 'c-awk-NL-prop))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
384 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
385 (defun c-awk-unstick-NL-prop () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
386 ;; Ensure that the text property c-awk-NL-prop is "non-sticky". Without |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
387 ;; this, a new newline inserted after an old newline (e.g. by C-j) would |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
388 ;; inherit any c-awk-NL-prop from the old newline. This would be a Bad |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
389 ;; Thing. This function's action is required by c-put-char-property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
390 (if (and (boundp 'text-property-default-nonsticky) ; doesn't exist in Xemacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
391 (not (assoc 'c-awk-NL-prop text-property-default-nonsticky))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
392 (setq text-property-default-nonsticky |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
393 (cons '(c-awk-NL-prop . t) text-property-default-nonsticky)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
394 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
395 ;; The following is purely a diagnostic command, to be commented out of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
396 ;; final release. ACM, 2002/6/1 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
397 ;; (defun NL-props () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
398 ;; (interactive) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
399 ;; (let (pl-prop cl-prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
400 ;; (message "Prev-line: %s Cur-line: %s" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
401 ;; (if (setq pl-prop (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
402 ;; (char-to-string pl-prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
403 ;; "nil") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
404 ;; (if (setq cl-prop (c-get-char-property (c-point 'eol) 'c-awk-NL-prop)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
405 ;; (char-to-string cl-prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
406 ;; "nil")))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
407 ;(define-key awk-mode-map [?\C-c ?\r] 'NL-props) ; commented out, 2002/8/31 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
408 ;for now. In the byte compiled version, this causes things to crash because |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
409 ;awk-mode-map isn't yet defined. :-( |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
410 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
411 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
412 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
413 ;; The following section of the code is to do with font-locking. The biggest |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
414 ;; problem for font-locking is deciding whether a / is a regular expression |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
415 ;; delimiter or a division sign - determining precisely where strings and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
416 ;; regular expressions start and stop is also troublesome. This is the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
417 ;; purpose of the function c-awk-set-syntax-table-properties and the myriad |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
418 ;; elisp regular expressions it uses. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
419 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
420 ;; Because AWK is a line oriented language, I felt the normal cc-mode strategy |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
421 ;; for font-locking unterminated strings (i.e. font-locking the buffer up to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
422 ;; the next string delimiter as a string) was inappropriate. Instead, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
423 ;; unbalanced string/regexp delimiters are given the warning font, being |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
424 ;; refonted with the string font as soon as the matching delimiter is entered. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
425 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
426 ;; This requires the region processed by the current font-lock after-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
427 ;; function to have access to the start of the string/regexp, which may be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
428 ;; several lines back. The elisp "advice" feature is used on these functions |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
429 ;; to allow this. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
430 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
431 (defun c-awk-beginning-of-logical-line (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
432 ;; Go back to the start of the (apparent) current line (or the start of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
433 ;; line containing POS), returning the buffer position of that point. I.e., |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
434 ;; go back to the last line which doesn't have an escaped EOL before it. |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
435 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
436 ;; This is guaranteed to be "safe" for syntactic analysis, i.e. outwith any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
437 ;; comment, string or regexp. IT MAY WELL BE that this function should not be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
438 ;; executed on a narrowed buffer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
439 (if pos (goto-char pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
440 (forward-line 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
441 (while (and (> (point) (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
442 (eq (char-before (1- (point))) ?\\)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
443 (forward-line -1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
444 (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
445 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
446 (defun c-awk-end-of-logical-line (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
447 ;; Go forward to the end of the (apparent) current logical line (or the end of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
448 ;; the line containing POS), returning the buffer position of that point. I.e., |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
449 ;; go to the end of the next line which doesn't have an escaped EOL. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
450 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
451 ;; This is guaranteed to be "safe" for syntactic analysis, i.e. outwith any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
452 ;; comment, string or regexp. IT MAY WELL BE that this function should not be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
453 ;; executed on a narrowed buffer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
454 (if pos (goto-char pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
455 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
456 (while (and (< (point) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
457 (eq (char-before) ?\\)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
458 (end-of-line 2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
459 (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
460 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
461 ;; N.B. In the following regexps, an EOL is either \n OR \r. This is because |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
462 ;; Emacs has in the past used \r to mark hidden lines in some fashion (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
463 ;; maybe still does). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
464 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
465 (defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
466 ;; Matches any escaped (with \) character-pair, including an escaped newline. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
467 (defconst c-awk-comment-without-nl "#.*") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
468 ;; Matches an AWK comment, not including the terminating NL (if any). Note |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
469 ;; that the "enclosing" (elisp) regexp must ensure the # is real. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
470 (defconst c-awk-nl-or-eob "\\(\n\\|\r\\|\\'\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
471 ;; Matches a newline, or the end of buffer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
472 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
473 ;; "Space" regular expressions. |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
474 (defconst c-awk-escaped-nl "\\\\[\n\r]") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
475 ;; Matches an escaped newline. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
476 (defconst c-awk-escaped-nls* (concat "\\(" c-awk-escaped-nl "\\)*")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
477 ;; Matches a possibly empty sequence of escaped newlines. Used in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
478 ;; awk-font-lock-keywords. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
479 ;; (defconst c-awk-escaped-nls*-with-space* |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
480 ;; (concat "\\(" c-awk-escaped-nls* "\\|" "[ \t]+" "\\)*")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
481 ;; The above RE was very slow. It's runtime was doubling with each additional |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
482 ;; space :-( Reformulate it as below: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
483 (defconst c-awk-escaped-nls*-with-space* |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
484 (concat "\\(" c-awk-escaped-nl "\\|" "[ \t]" "\\)*")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
485 ;; Matches a possibly empty sequence of escaped newlines with optional |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
486 ;; interspersed spaces and tabs. Used in awk-font-lock-keywords. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
487 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
488 ;; REGEXPS FOR "HARMLESS" STRINGS/LINES. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
489 (defconst c-awk-harmless-char-re "[^_#/\"\\\\\n\r]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
490 ;; Matches any character but a _, #, /, ", \, or newline. N.B. _" starts a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
491 ;; localisation string in gawk 3.1 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
492 (defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
493 ;; Matches an underline NOT followed by ". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
494 (defconst c-awk-harmless-string*-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
495 (concat "\\(" c-awk-harmless-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
496 ;; Matches a (possibly empty) sequence of chars without unescaped /, ", \, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
497 ;; #, or newlines. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
498 (defconst c-awk-harmless-string*-here-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
499 (concat "\\=" c-awk-harmless-string*-re)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
500 ;; Matches the (possibly empty) sequence of chars without unescaped /, ", \, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
501 ;; at point. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
502 (defconst c-awk-harmless-line-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
503 (concat c-awk-harmless-string*-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
504 "\\(" c-awk-comment-without-nl "\\)?" c-awk-nl-or-eob)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
505 ;; Matches (the tail of) an AWK \"logical\" line not containing an unescaped |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
506 ;; " or /. "logical" means "possibly containing escaped newlines". A comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
507 ;; is matched as part of the line even if it contains a " or a /. The End of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
508 ;; buffer is also an end of line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
509 (defconst c-awk-harmless-lines+-here-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
510 (concat "\\=\\(" c-awk-harmless-line-re "\\)+")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
511 ;; Matches a sequence of (at least one) \"harmless-line\" at point. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
512 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
513 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
514 ;; REGEXPS FOR AWK STRINGS. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
515 (defconst c-awk-string-ch-re "[^\"\\\n\r]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
516 ;; Matches any character which can appear unescaped in a string. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
517 (defconst c-awk-string-innards-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
518 (concat "\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
519 ;; Matches the inside of an AWK string (i.e. without the enclosing quotes). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
520 (defconst c-awk-string-without-end-here-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
521 (concat "\\=_?\"" c-awk-string-innards-re)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
522 ;; Matches an AWK string at point up to, but not including, any terminator. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
523 ;; A gawk 3.1+ string may look like _"localisable string". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
524 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
525 ;; REGEXPS FOR AWK REGEXPS. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
526 (defconst c-awk-regexp-normal-re "[^[/\\\n\r]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
527 ;; Matches any AWK regexp character which doesn't require special analysis. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
528 (defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
529 ;; Matches a (possibly empty) sequence of escaped newlines. |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
530 |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
531 ;; NOTE: In what follows, "[asdf]" in a regexp will be called a "character |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
532 ;; list", and "[:alpha:]" inside a character list will be known as a |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
533 ;; "character class". These terms for these things vary between regexp |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
534 ;; descriptions . |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
535 (defconst c-awk-regexp-char-class-re |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
536 "\\[:[a-z]+:\\]") |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
537 ;; Matches a character class spec (e.g. [:alpha:]). |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
538 (defconst c-awk-regexp-char-list-re |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
539 (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?" |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
540 "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
541 "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)")) |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
542 ;; Matches a regexp char list, up to (but not including) EOL if the ] is |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
543 ;; missing. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
544 (defconst c-awk-regexp-innards-re |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
545 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
546 "\\|" c-awk-regexp-normal-re "\\)*")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
547 ;; Matches the inside of an AWK regexp (i.e. without the enclosing /s) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
548 (defconst c-awk-regexp-without-end-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
549 (concat "/" c-awk-regexp-innards-re)) |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
550 ;; Matches an AWK regexp up to, but not including, any terminating /. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
551 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
552 ;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
553 ;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
554 ;; whether a '/' at the current position would by a regexp opener or a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
555 ;; division sign. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
556 (defconst c-awk-neutral-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
557 ; "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)+") ; changed, 2003/6/7 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
558 "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
559 ;; A "neutral" char(pair). Doesn't change the "state" of a subsequent /. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
560 ;; This is space/tab, braces, an auto-increment/decrement operator or an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
561 ;; escaped character. Or one of the (illegal) characters @ or `. But NOT an |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
562 ;; end of line (even if escaped). |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
563 (defconst c-awk-neutrals*-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
564 (concat "\\(" c-awk-neutral-re "\\)*")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
565 ;; A (possibly empty) string of neutral characters (or character pairs). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
566 (defconst c-awk-var-num-ket-re "[]\)0-9a-zA-Z_$.\x80-\xff]+") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
567 ;; Matches a char which is a constituent of a variable or number, or a ket |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
568 ;; (i.e. closing bracKET), round or square. Assume that all characters \x80 to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
569 ;; \xff are "letters". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
570 (defconst c-awk-div-sign-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
571 (concat c-awk-var-num-ket-re c-awk-neutrals*-re "/")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
572 ;; Will match a piece of AWK buffer ending in / which is a division sign, in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
573 ;; a context where an immediate / would be a regexp bracket. It follows a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
574 ;; variable or number (with optional intervening "neutral" characters). This |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
575 ;; will only work when there won't be a preceding " or / before the sought / |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
576 ;; to foul things up. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
577 (defconst c-awk-non-arith-op-bra-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
578 "[[\(&=:!><,?;'~|]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
579 ;; Matches an openeing BRAcket ,round or square, or any operator character |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
580 ;; apart from +,-,/,*,%. For the purpose at hand (detecting a / which is a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
581 ;; regexp bracket) these arith ops are unnecessary and a pain, because of "++" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
582 ;; and "--". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
583 (defconst c-awk-regexp-sign-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
584 (concat c-awk-non-arith-op-bra-re c-awk-neutrals*-re "/")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
585 ;; Will match a piece of AWK buffer ending in / which is an opening regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
586 ;; bracket, in a context where an immediate / would be a division sign. This |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
587 ;; will only work when there won't be a preceding " or / before the sought / |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
588 ;; to foul things up. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
589 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
590 ;; ACM, 2002/02/15: The idea of the next function is to put the "Error font" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
591 ;; on strings/regexps which are missing their closing delimiter. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
592 ;; 2002/4/28. The default syntax for / has been changed from "string" to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
593 ;; "punctuation", to reduce hassle when this character appears within a string |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
594 ;; or comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
595 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
596 (defun c-awk-set-string-regexp-syntax-table-properties (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
597 ;; BEG and END bracket a (possibly unterminated) string or regexp. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
598 ;; opening delimiter is after BEG, and the closing delimiter, IF ANY, is AFTER |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
599 ;; END. Set the appropriate syntax-table properties on the delimiters and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
600 ;; contents of this string/regex. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
601 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
602 ;; "String" here can also mean a gawk 3.1 "localizable" string which starts |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
603 ;; with _". In this case, we step over the _ and ignore it; It will get it's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
604 ;; font from an entry in awk-font-lock-keywords. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
605 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
606 ;; If the closing delimiter is missing (i.e., there is an EOL there) set the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
607 ;; STRING-FENCE property on the opening " or / and closing EOL. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
608 (if (eq (char-after beg) ?_) (setq beg (1+ beg))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
609 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
610 ;; First put the properties on the delimiters. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
611 (cond ((eq end (point-max)) ; string/regexp terminated by EOB |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
612 (put-text-property beg (1+ beg) 'syntax-table '(15))) ; (15) = "string fence" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
613 ((/= (char-after beg) (char-after end)) ; missing end delimiter |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
614 (put-text-property beg (1+ beg) 'syntax-table '(15)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
615 (put-text-property end (1+ end) 'syntax-table '(15))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
616 ((eq (char-after beg) ?/) ; Properly bracketed regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
617 (put-text-property beg (1+ beg) 'syntax-table '(7)) ; (7) = "string" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
618 (put-text-property end (1+ end) 'syntax-table '(7))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
619 (t)) ; Properly bracketed string: Nothing to do. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
620 ;; Now change the properties of any escaped "s in the string to punctuation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
621 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
622 (goto-char (1+ beg)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
623 (or (eobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
624 (while (search-forward "\"" end t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
625 (put-text-property (1- (point)) (point) 'syntax-table '(1)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
626 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
627 (defun c-awk-syntax-tablify-string () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
628 ;; Point is at the opening " or _" of a string. Set the syntax-table |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
629 ;; properties on this string, leaving point just after the string. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
630 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
631 ;; The result is nil if a / immediately after the string would be a regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
632 ;; opener, t if it would be a division sign. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
633 (search-forward-regexp c-awk-string-without-end-here-re nil t) ; a (possibly unterminated) string |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
634 (c-awk-set-string-regexp-syntax-table-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
635 (match-beginning 0) (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
636 (cond ((looking-at "\"") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
637 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
638 t) ; In AWK, ("15" / 5) gives 3 ;-) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
639 ((looking-at "[\n\r]") ; Unterminated string with EOL. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
640 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
641 nil) ; / on next line would start a regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
642 (t nil))) ; Unterminated string at EOB |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
643 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
644 (defun c-awk-syntax-tablify-/ (anchor anchor-state-/div) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
645 ;; Point is at a /. Determine whether this is a division sign or a regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
646 ;; opener, and if the latter, apply syntax-table properties to the entire |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
647 ;; regexp. Point is left immediately after the division sign or regexp, as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
648 ;; the case may be. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
649 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
650 ;; ANCHOR-STATE-/DIV identifies whether a / at ANCHOR would have been a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
651 ;; division sign (value t) or a regexp opener (value nil). The idea is that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
652 ;; we analyse the line from ANCHOR up till point to determine what the / at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
653 ;; point is. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
654 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
655 ;; The result is what ANCHOR-STATE-/DIV (see above) is where point is left. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
656 (let ((/point (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
657 (goto-char anchor) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
658 ;; Analyse the line to find out what the / is. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
659 (if (if anchor-state-/div |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
660 (not (search-forward-regexp c-awk-regexp-sign-re (1+ /point) t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
661 (search-forward-regexp c-awk-div-sign-re (1+ /point) t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
662 ;; A division sign. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
663 (progn (goto-char (1+ /point)) nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
664 ;; A regexp opener |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
665 ;; Jump over the regexp innards, setting the match data. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
666 (goto-char /point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
667 (search-forward-regexp c-awk-regexp-without-end-re) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
668 (c-awk-set-string-regexp-syntax-table-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
669 (match-beginning 0) (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
670 (cond ((looking-at "/") ; Terminating / |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
671 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
672 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
673 ((looking-at "[\n\r]") ; Incomplete regexp terminated by EOL |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
674 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
675 nil) ; / on next line would start another regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
676 (t nil))))) ; Unterminated regexp at EOB |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
677 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
678 (defun c-awk-set-syntax-table-properties (lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
679 ;; Scan the buffer text between point and LIM, setting (and clearing) the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
680 ;; syntax-table property where necessary. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
681 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
682 ;; This function is designed to be called as the FUNCTION in a MATCHER in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
683 ;; font-lock-syntactic-keywords, and it always returns NIL (to inhibit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
684 ;; repeated calls from font-lock: See elisp info page "Search-based |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
685 ;; Fontification"). It also gets called, with a bit of glue, from |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
686 ;; after-change-functions when font-lock isn't active. Point is left |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
687 ;; "undefined" after this function exits. THE BUFFER SHOULD HAVE BEEN |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
688 ;; WIDENED, AND ANY PRECIOUS MATCH-DATA SAVED BEFORE CALLING THIS ROUTINE. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
689 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
690 ;; We need to set/clear the syntax-table property on: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
691 ;; (i) / - It is set to "string" on a / which is the opening or closing |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
692 ;; delimiter of the properly terminated regexp (and left unset on a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
693 ;; division sign). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
694 ;; (ii) the opener of an unterminated string/regexp, we set the property |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
695 ;; "generic string delimiter" on both the opening " or / and the end of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
696 ;; line where the closing delimiter is missing. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
697 ;; (iii) "s inside strings/regexps (these will all be escaped "s). They are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
698 ;; given the property "punctuation". This will later allow other routines |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
699 ;; to use the regexp "\\S\"*" to skip over the string innards. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
700 ;; (iv) Inside a comment, all syntax-table properties are cleared. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
701 (let (anchor |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
702 (anchor-state-/div nil)) ; t means a following / would be a div sign. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
703 (c-awk-beginning-of-logical-line) ; ACM 2002/7/21. This is probably redundant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
704 (put-text-property (point) lim 'syntax-table nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
705 (search-forward-regexp c-awk-harmless-lines+-here-re nil t) ; skip harmless lines. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
706 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
707 ;; Once round the next loop for each string, regexp, or div sign |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
708 (while (< (point) lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
709 (setq anchor (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
710 (search-forward-regexp c-awk-harmless-string*-here-re nil t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
711 ;; We are now looking at either a " or a /. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
712 ;; Do our thing on the string, regexp or divsion sign. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
713 (setq anchor-state-/div |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
714 (if (looking-at "_?\"") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
715 (c-awk-syntax-tablify-string) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
716 (c-awk-syntax-tablify-/ anchor anchor-state-/div))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
717 |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
718 ;; Skip any further "harmless" lines before the next tricky one. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
719 (if (search-forward-regexp c-awk-harmless-lines+-here-re nil t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
720 (setq anchor-state-/div nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
721 nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
722 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
723 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
724 ;; ACM, 2002/07/21: Thoughts: We need an AWK Mode after-change function to set |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
725 ;; the syntax-table properties even when font-lock isn't enabled, for the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
726 ;; subsequent use of movement functions, etc. However, it seems that if font |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
727 ;; lock _is_ enabled, we can always leave it to do the job. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
728 (defvar c-awk-old-EOLL 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
729 (make-variable-buffer-local 'c-awk-old-EOLL) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
730 ;; End of logical line following the region which is about to be changed. Set |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
731 ;; in c-awk-before-change and used in c-awk-after-change. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
732 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
733 (defun c-awk-before-change (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
734 ;; This function is called exclusively from the before-change-functions hook. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
735 ;; It does two things: Finds the end of the (logical) line on which END lies, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
736 ;; and clears c-awk-NL-prop text properties from this point onwards. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
737 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
738 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
739 (setq c-awk-old-EOLL (c-awk-end-of-logical-line end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
740 (c-save-buffer-state nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
741 (c-awk-clear-NL-props end (point-max)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
742 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
743 (defun c-awk-end-of-change-region (beg end old-len) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
744 ;; Find the end of the region which needs to be font-locked after a change. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
745 ;; This is the end of the logical line on which the change happened, either |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
746 ;; as it was before the change, or as it is now, which ever is later. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
747 ;; N.B. point is left undefined. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
748 (max (+ (- c-awk-old-EOLL old-len) (- end beg)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
749 (c-awk-end-of-logical-line end))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
750 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
751 (defun c-awk-after-change (beg end old-len) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
752 ;; This function is called exclusively as an after-change function in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
753 ;; AWK Mode. It ensures that the syntax-table properties get set in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
754 ;; changed region. However, if font-lock is enabled, this function does |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
755 ;; nothing, since an enabled font-lock after-change function will always do |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
756 ;; this. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
757 (unless (and (boundp 'font-lock-mode) font-lock-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
758 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
759 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
760 (setq end (c-awk-end-of-change-region beg end old-len)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
761 (c-awk-beginning-of-logical-line beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
762 (c-save-buffer-state nil ; So that read-only status isn't affected. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
763 ; (e.g. when first loading the buffer) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
764 (c-awk-set-syntax-table-properties end)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
765 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
766 ;; ACM 2002/5/25. When font-locking is invoked by a buffer change, the region |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
767 ;; specified by the font-lock after-change function must be expanded to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
768 ;; include ALL of any string or regexp within the region. The simplest way to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
769 ;; do this in practice is to use the beginning/end-of-logical-line functions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
770 ;; Don't overlook the possibility of the buffer change being the "recapturing" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
771 ;; of a previously escaped newline. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
772 (defmacro c-awk-advise-fl-for-awk-region (function) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
773 `(defadvice ,function (before get-awk-region activate) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
774 ;; When font-locking an AWK Mode buffer, make sure that any string/regexp is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
775 ;; completely font-locked. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
776 (when (eq major-mode 'awk-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
777 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
778 (ad-set-arg 1 (c-awk-end-of-change-region |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
779 (ad-get-arg 0) ; beg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
780 (ad-get-arg 1) ; end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
781 (ad-get-arg 2))) ; old-len |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
782 (ad-set-arg 0 (c-awk-beginning-of-logical-line (ad-get-arg 0))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
783 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
784 (c-awk-advise-fl-for-awk-region font-lock-after-change-function) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
785 (c-awk-advise-fl-for-awk-region jit-lock-after-change) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
786 (c-awk-advise-fl-for-awk-region lazy-lock-defer-rest-after-change) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
787 (c-awk-advise-fl-for-awk-region lazy-lock-defer-line-after-change) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
788 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
789 ;; ACM 2002/9/29. Functions for C-M-a and C-M-e |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
790 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
791 (defconst c-awk-terminated-regexp-or-string-here-re "\\=\\s\"\\S\"*\\s\"") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
792 ;; Matches a terminated string/regexp (utilising syntax-table properties). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
793 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
794 (defconst c-awk-unterminated-regexp-or-string-here-re "\\=\\s|\\S|*$") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
795 ;; Matches an unterminated string/regexp, NOT including the eol at the end. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
796 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
797 (defconst c-awk-harmless-pattern-characters* |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
798 (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
799 ;; Matches any "harmless" character in a pattern or an escaped character pair. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
800 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
801 (defun c-awk-beginning-of-defun (&optional arg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
802 "Move backward to the beginning of an AWK \"defun\". With ARG, do it that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
803 many times. Negative arg -N means move forward to Nth following beginning of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
804 defun. Returns t unless search stops due to beginning or end of buffer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
805 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
806 By a \"defun\" is meant either a pattern-action pair or a function. The start |
63517
7316ffa5763c
(c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
807 of a defun is recognized as code starting at column zero which is neither a |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
808 closing brace nor a comment nor a continuation of the previous line. Unlike |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
809 in some other modes, having an opening brace at column 0 is neither necessary |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
810 nor helpful." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
811 (interactive "p") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
812 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
813 (c-save-buffer-state ; ensures the buffer is writable. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
814 nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
815 (let ((found t)) ; Has the most recent regexp search found b-of-defun? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
816 (if (>= arg 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
817 ;; Go back one defun each time round the following loop. (For +ve arg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
818 (while (and found (> arg 0) (not (eq (point) (point-min)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
819 ;; Go back one "candidate" each time round the next loop until one |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
820 ;; is genuinely a beginning-of-defun. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
821 (while (and (setq found (search-backward-regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
822 "^[^#} \t\n\r]" (point-min) 'stop-at-limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
823 (not (memq (c-awk-get-NL-prop-prev-line) '(?\; ?\#))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
824 (setq arg (1- arg))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
825 ;; The same for a -ve arg. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
826 (if (not (eq (point) (point-max))) (forward-char 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
827 (while (and found (< arg 0) (not (eq (point) (point-max)))) ; The same for -ve arg. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
828 (while (and (setq found (search-forward-regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
829 "^[^#} \t\n\r]" (point-max) 'stop-at-limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
830 (not (memq (c-awk-get-NL-prop-prev-line) '(?\; ?\#))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
831 (setq arg (1+ arg))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
832 (if found (goto-char (match-beginning 0)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
833 (eq arg 0))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
834 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
835 (defun c-awk-forward-awk-pattern () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
836 ;; Point is at the start of an AWK pattern (which may be null) or function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
837 ;; declaration. Move to the pattern's end, and past any trailing space or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
838 ;; comment. Typically, we stop at the { which denotes the corresponding AWK |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
839 ;; action/function body. Otherwise we stop at the EOL (or ;) marking the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
840 ;; absence of an explicit action. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
841 (while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
842 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
843 (search-forward-regexp c-awk-harmless-pattern-characters*) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
844 (if (looking-at "#") (end-of-line)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
845 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
846 ((eobp) nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
847 ((looking-at "[{;]") nil) ; We've finished! |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
848 ((eolp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
849 (if (c-awk-cur-line-incomplete-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
850 (forward-line) ; returns non-nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
851 nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
852 ((search-forward-regexp c-awk-terminated-regexp-or-string-here-re nil t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
853 ((search-forward-regexp c-awk-unterminated-regexp-or-string-here-re nil t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
854 ((looking-at "/") (forward-char) t))))) ; division sign. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
855 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
856 (defun c-awk-end-of-defun1 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
857 ;; point is at the start of a "defun". Move to its end. Return end position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
858 (c-awk-forward-awk-pattern) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
859 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
860 ((looking-at "{") (goto-char (scan-sexps (point) 1))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
861 ((looking-at ";") (forward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
862 ((eolp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
863 (t (error "c-awk-end-of-defun1: Failure of c-awk-forward-awk-pattern"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
864 (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
865 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
866 (defun c-awk-beginning-of-defun-p () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
867 ;; Are we already at the beginning of a defun? (i.e. at code in column 0 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
868 ;; which isn't a }, and isn't a continuation line of any sort. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
869 (and (looking-at "^[^#} \t\n\r]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
870 (not (c-awk-prev-line-incomplete-p)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
871 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
872 (defun c-awk-end-of-defun (&optional arg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
873 "Move forward to next end of defun. With argument, do it that many times. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
874 Negative argument -N means move back to Nth preceding end of defun. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
875 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
876 An end of a defun occurs right after the closing brace that matches the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
877 opening brace at its start, or immediately after the AWK pattern when there is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
878 no explicit action; see function `c-awk-beginning-of-defun'." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
879 (interactive "p") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
880 (or arg (setq arg 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
881 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
882 (c-save-buffer-state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
883 nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
884 (let ((start-point (point)) end-point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
885 ;; Strategy: (For +ve ARG): If we're not already at a beginning-of-defun, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
886 ;; move backwards to one. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
887 ;; Repeat [(i) move forward to end-of-current-defun (see below); |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
888 ;; (ii) If this isn't it, move forward to beginning-of-defun]. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
889 ;; We start counting ARG only when step (i) has passed the original point. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
890 (when (> arg 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
891 ;; Try to move back to a beginning-of-defun, if not already at one. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
892 (if (not (c-awk-beginning-of-defun-p)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
893 (when (not (c-awk-beginning-of-defun 1)) ; No bo-defun before point. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
894 (goto-char start-point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
895 (c-awk-beginning-of-defun -1))) ; if this fails, we're at EOB, tough! |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
896 ;; Now count forward, one defun at a time |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
897 (while (and (not (eobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
898 (c-awk-end-of-defun1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
899 (if (> (point) start-point) (setq arg (1- arg)) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
900 (> arg 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
901 (c-awk-beginning-of-defun -1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
902 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
903 (when (< arg 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
904 (setq end-point start-point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
905 (while (and (not (bobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
906 (c-awk-beginning-of-defun 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
907 (if (< (setq end-point (if (bobp) (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
908 (save-excursion (c-awk-end-of-defun1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
909 start-point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
910 (setq arg (1+ arg)) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
911 (< arg 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
912 (goto-char (min start-point end-point))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
913 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
914 (cc-provide 'cc-awk) ; Changed from 'awk-mode, ACM 2002/5/21 |
52401 | 915 |
916 ;;; arch-tag: c4836289-3aa4-4a59-9934-9ccc2bacccf3 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
917 ;;; awk-mode.el ends here |