Mercurial > emacs
annotate lisp/progmodes/icon.el @ 68398:cec05baae14f
(check_pure_size): Make overflow message an "error message".
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 26 Jan 2006 17:51:42 +0000 |
parents | a11fdee52c05 |
children | dc49655f57ae 7beb78bc1f8e |
rev | line source |
---|---|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
210
diff
changeset
|
1 ;;; icon.el --- mode for editing Icon code |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
210
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) 1989, 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. |
845 | 5 |
12910
8aa95606db04
Define user options with defvar, not defconst.
Richard M. Stallman <rms@gnu.org>
parents:
10874
diff
changeset
|
6 ;; Author: Chris Smith <csmith@convex.com> |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
7 ;; Created: 15 Feb 89 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
8 ;; Keywords: languages |
36 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 15 ;; any later version. |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 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. | |
36 | 26 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
27 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
28 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
29 ;; A major mode for editing the Icon programming language. |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
30 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
31 ;;; Code: |
36 | 32 |
33 (defvar icon-mode-abbrev-table nil | |
34 "Abbrev table in use in Icon-mode buffers.") | |
35 (define-abbrev-table 'icon-mode-abbrev-table ()) | |
36 | |
37 (defvar icon-mode-map () | |
38 "Keymap used in Icon mode.") | |
39 (if icon-mode-map | |
40 () | |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
41 (let ((map (make-sparse-keymap "Icon"))) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
42 (setq icon-mode-map (make-sparse-keymap)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
43 (define-key icon-mode-map "{" 'electric-icon-brace) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
44 (define-key icon-mode-map "}" 'electric-icon-brace) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
45 (define-key icon-mode-map "\e\C-h" 'mark-icon-function) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
46 (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
47 (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
48 (define-key icon-mode-map "\e\C-q" 'indent-icon-exp) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
49 (define-key icon-mode-map "\177" 'backward-delete-char-untabify) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
50 |
32299
4888d3b1cf29
(icon-mode-map): Add name to menu-bar keymap.
Dave Love <fx@gnu.org>
parents:
32155
diff
changeset
|
51 (define-key icon-mode-map [menu-bar] (make-sparse-keymap "Icon")) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 (define-key icon-mode-map [menu-bar icon] |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
53 (cons "Icon" map)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
54 (define-key map [beginning-of-icon-defun] '("Beginning of function" . beginning-of-icon-defun)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 (define-key map [end-of-icon-defun] '("End of function" . end-of-icon-defun)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
56 (define-key map [comment-region] '("Comment Out Region" . comment-region)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 (define-key map [indent-region] '("Indent Region" . indent-region)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
58 (define-key map [indent-line] '("Indent Line" . icon-indent-command)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 (put 'eval-region 'menu-enable 'mark-active) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 (put 'comment-region 'menu-enable 'mark-active) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
61 (put 'indent-region 'menu-enable 'mark-active))) |
36 | 62 |
63 (defvar icon-mode-syntax-table nil | |
64 "Syntax table in use in Icon-mode buffers.") | |
65 | |
66 (if icon-mode-syntax-table | |
67 () | |
68 (setq icon-mode-syntax-table (make-syntax-table)) | |
69 (modify-syntax-entry ?\\ "\\" icon-mode-syntax-table) | |
70 (modify-syntax-entry ?# "<" icon-mode-syntax-table) | |
71 (modify-syntax-entry ?\n ">" icon-mode-syntax-table) | |
72 (modify-syntax-entry ?$ "." icon-mode-syntax-table) | |
73 (modify-syntax-entry ?/ "." icon-mode-syntax-table) | |
74 (modify-syntax-entry ?* "." icon-mode-syntax-table) | |
75 (modify-syntax-entry ?+ "." icon-mode-syntax-table) | |
76 (modify-syntax-entry ?- "." icon-mode-syntax-table) | |
77 (modify-syntax-entry ?= "." icon-mode-syntax-table) | |
78 (modify-syntax-entry ?% "." icon-mode-syntax-table) | |
79 (modify-syntax-entry ?< "." icon-mode-syntax-table) | |
80 (modify-syntax-entry ?> "." icon-mode-syntax-table) | |
81 (modify-syntax-entry ?& "." icon-mode-syntax-table) | |
82 (modify-syntax-entry ?| "." icon-mode-syntax-table) | |
83 (modify-syntax-entry ?\' "\"" icon-mode-syntax-table)) | |
84 | |
17633 | 85 (defgroup icon nil |
86 "Mode for editing Icon code." | |
66963
a11fdee52c05
Add :link (custom-group-link font-lock-faces) to defgroup.
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
87 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) |
17633 | 88 :group 'languages) |
89 | |
90 (defcustom icon-indent-level 4 | |
91 "*Indentation of Icon statements with respect to containing block." | |
92 :type 'integer | |
93 :group 'icon) | |
94 | |
95 (defcustom icon-brace-imaginary-offset 0 | |
96 "*Imagined indentation of a Icon open brace that actually follows a statement." | |
97 :type 'integer | |
98 :group 'icon) | |
99 | |
100 (defcustom icon-brace-offset 0 | |
101 "*Extra indentation for braces, compared with other text in same context." | |
102 :type 'integer | |
103 :group 'icon) | |
36 | 104 |
17633 | 105 (defcustom icon-continued-statement-offset 4 |
106 "*Extra indent for Icon lines not starting new statements." | |
107 :type 'integer | |
108 :group 'icon) | |
109 | |
110 (defcustom icon-continued-brace-offset 0 | |
111 "*Extra indent for Icon substatements that start with open-braces. | |
112 This is in addition to `icon-continued-statement-offset'." | |
113 :type 'integer | |
114 :group 'icon) | |
36 | 115 |
17633 | 116 (defcustom icon-auto-newline nil |
117 "*Non-nil means automatically newline before and after braces Icon code. | |
118 This applies when braces are inserted." | |
119 :type 'boolean | |
120 :group 'icon) | |
121 | |
122 (defcustom icon-tab-always-indent t | |
123 "*Non-nil means TAB in Icon mode should always reindent the current line. | |
124 It will then reindent, regardless of where in the line point is | |
125 when the TAB command is used." | |
19834
63f793f84d0f
(icon-tab-always-indent): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents:
18381
diff
changeset
|
126 :type 'boolean |
17633 | 127 :group 'icon) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
128 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
129 (defvar icon-imenu-generic-expression |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
130 '((nil "^[ \t]*procedure[ \t]+\\(\\sw+\\)[ \t]*(" 1)) |
17633 | 131 "Imenu expression for Icon mode. See `imenu-generic-expression'.") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
132 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
133 |
36 | 134 |
9055
2e089bdec449
(icon-mode): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
135 ;;;###autoload |
36 | 136 (defun icon-mode () |
137 "Major mode for editing Icon code. | |
138 Expression and list commands understand all Icon brackets. | |
139 Tab indents for Icon code. | |
140 Paragraphs are separated by blank lines only. | |
141 Delete converts tabs to spaces as it moves back. | |
142 \\{icon-mode-map} | |
143 Variables controlling indentation style: | |
144 icon-tab-always-indent | |
145 Non-nil means TAB in Icon mode should always reindent the current line, | |
146 regardless of where in the line point is when the TAB command is used. | |
147 icon-auto-newline | |
148 Non-nil means automatically newline before and after braces | |
149 inserted in Icon code. | |
150 icon-indent-level | |
151 Indentation of Icon statements within surrounding block. | |
152 The surrounding block's indentation is the indentation | |
153 of the line on which the open-brace appears. | |
154 icon-continued-statement-offset | |
155 Extra indentation given to a substatement, such as the | |
156 then-clause of an if or body of a while. | |
157 icon-continued-brace-offset | |
158 Extra indentation given to a brace that starts a substatement. | |
210 | 159 This is in addition to `icon-continued-statement-offset'. |
36 | 160 icon-brace-offset |
161 Extra indentation for line if it starts with an open brace. | |
162 icon-brace-imaginary-offset | |
163 An open brace following other text is treated as if it were | |
164 this far to the right of the start of its line. | |
165 | |
210 | 166 Turning on Icon mode calls the value of the variable `icon-mode-hook' |
167 with no args, if that value is non-nil." | |
36 | 168 (interactive) |
169 (kill-all-local-variables) | |
170 (use-local-map icon-mode-map) | |
171 (setq major-mode 'icon-mode) | |
172 (setq mode-name "Icon") | |
173 (setq local-abbrev-table icon-mode-abbrev-table) | |
174 (set-syntax-table icon-mode-syntax-table) | |
175 (make-local-variable 'paragraph-start) | |
10874
7ad2cc4e9963
(icon-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
9055
diff
changeset
|
176 (setq paragraph-start (concat "$\\|" page-delimiter)) |
36 | 177 (make-local-variable 'paragraph-separate) |
178 (setq paragraph-separate paragraph-start) | |
179 (make-local-variable 'indent-line-function) | |
180 (setq indent-line-function 'icon-indent-line) | |
181 (make-local-variable 'require-final-newline) | |
59245
11d2d878c92f
(icon-mode): Use mode-require-final-newline.
Richard M. Stallman <rms@gnu.org>
parents:
54014
diff
changeset
|
182 (setq require-final-newline mode-require-final-newline) |
36 | 183 (make-local-variable 'comment-start) |
184 (setq comment-start "# ") | |
185 (make-local-variable 'comment-end) | |
186 (setq comment-end "") | |
187 (make-local-variable 'comment-start-skip) | |
188 (setq comment-start-skip "# *") | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
189 (make-local-variable 'comment-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
190 (setq comment-indent-function 'icon-comment-indent) |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
191 (set (make-local-variable 'indent-line-function) 'icon-indent-line) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
192 ;; font-lock support |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
193 (setq font-lock-defaults |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
194 '((icon-font-lock-keywords |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
195 icon-font-lock-keywords-1 icon-font-lock-keywords-2) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
196 nil nil ((?_ . "w")) beginning-of-defun |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
197 ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP. |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
198 ;(font-lock-comment-start-regexp . "#") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
199 (font-lock-mark-block-function . mark-defun))) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
200 ;; imenu support |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
201 (make-local-variable 'imenu-generic-expression) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
202 (setq imenu-generic-expression icon-imenu-generic-expression) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
203 ;; hideshow support |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
204 ;; we start from the assertion that `hs-special-modes-alist' is autoloaded. |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
205 (unless (assq 'icon-mode hs-special-modes-alist) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
206 (setq hs-special-modes-alist |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
207 (cons '(icon-mode "\\<procedure\\>" "\\<end\\>" nil |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
208 icon-forward-sexp-function) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
209 hs-special-modes-alist))) |
62772
f2892faa87d4
* progmodes/ada-mode.el (ada-mode):
Lute Kamstra <lute@gnu.org>
parents:
59245
diff
changeset
|
210 (run-mode-hooks 'icon-mode-hook)) |
36 | 211 |
210 | 212 ;; This is used by indent-for-comment to decide how much to |
213 ;; indent a comment in Icon code based on its context. | |
36 | 214 (defun icon-comment-indent () |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
215 (if (looking-at "^#") 0 comment-column)) |
36 | 216 |
217 (defun electric-icon-brace (arg) | |
218 "Insert character and correct line's indentation." | |
219 (interactive "P") | |
220 (let (insertpos) | |
221 (if (and (not arg) | |
222 (eolp) | |
223 (or (save-excursion | |
224 (skip-chars-backward " \t") | |
225 (bolp)) | |
226 (if icon-auto-newline | |
227 (progn (icon-indent-line) (newline) t) | |
228 nil))) | |
229 (progn | |
230 (insert last-command-char) | |
231 (icon-indent-line) | |
232 (if icon-auto-newline | |
233 (progn | |
234 (newline) | |
235 ;; (newline) may have done auto-fill | |
236 (setq insertpos (- (point) 2)) | |
237 (icon-indent-line))) | |
238 (save-excursion | |
239 (if insertpos (goto-char (1+ insertpos))) | |
240 (delete-char -1)))) | |
241 (if insertpos | |
242 (save-excursion | |
243 (goto-char insertpos) | |
244 (self-insert-command (prefix-numeric-value arg))) | |
245 (self-insert-command (prefix-numeric-value arg))))) | |
246 | |
247 (defun icon-indent-command (&optional whole-exp) | |
248 "Indent current line as Icon code, or in some cases insert a tab character. | |
210 | 249 If `icon-tab-always-indent' is non-nil (the default), always indent current |
250 line. Otherwise, indent the current line only if point is at the left margin | |
36 | 251 or in the line's indentation; otherwise insert a tab. |
252 | |
210 | 253 A numeric argument, regardless of its value, means indent rigidly all the |
254 lines of the expression starting after point so that this line becomes | |
255 properly indented. The relative indentation among the lines of the | |
256 expression are preserved." | |
54014
6296b1d1ae51
* net/telnet.el (telnet-interrupt-subjob): Move doc string to the correct place.
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
257 (interactive "P") |
36 | 258 (if whole-exp |
259 ;; If arg, always indent this line as Icon | |
260 ;; and shift remaining lines of expression the same amount. | |
261 (let ((shift-amt (icon-indent-line)) | |
262 beg end) | |
263 (save-excursion | |
264 (if icon-tab-always-indent | |
265 (beginning-of-line)) | |
266 (setq beg (point)) | |
267 (forward-sexp 1) | |
268 (setq end (point)) | |
269 (goto-char beg) | |
270 (forward-line 1) | |
271 (setq beg (point))) | |
272 (if (> end beg) | |
273 (indent-code-rigidly beg end shift-amt "#"))) | |
274 (if (and (not icon-tab-always-indent) | |
275 (save-excursion | |
276 (skip-chars-backward " \t") | |
277 (not (bolp)))) | |
278 (insert-tab) | |
279 (icon-indent-line)))) | |
280 | |
281 (defun icon-indent-line () | |
282 "Indent current line as Icon code. | |
283 Return the amount the indentation changed by." | |
284 (let ((indent (calculate-icon-indent nil)) | |
285 beg shift-amt | |
286 (case-fold-search nil) | |
287 (pos (- (point-max) (point)))) | |
288 (beginning-of-line) | |
289 (setq beg (point)) | |
290 (cond ((eq indent nil) | |
291 (setq indent (current-indentation))) | |
30947 | 292 ((looking-at "^#") |
36 | 293 (setq indent 0)) |
294 (t | |
295 (skip-chars-forward " \t") | |
296 (if (listp indent) (setq indent (car indent))) | |
297 (cond ((and (looking-at "else\\b") | |
298 (not (looking-at "else\\s_"))) | |
299 (setq indent (save-excursion | |
300 (icon-backward-to-start-of-if) | |
301 (current-indentation)))) | |
302 ((or (= (following-char) ?}) | |
303 (looking-at "end\\b")) | |
304 (setq indent (- indent icon-indent-level))) | |
305 ((= (following-char) ?{) | |
306 (setq indent (+ indent icon-brace-offset)))))) | |
307 (skip-chars-forward " \t") | |
308 (setq shift-amt (- indent (current-column))) | |
309 (if (zerop shift-amt) | |
310 (if (> (- (point-max) pos) (point)) | |
311 (goto-char (- (point-max) pos))) | |
312 (delete-region beg (point)) | |
313 (indent-to indent) | |
314 ;; If initial point was within line's indentation, | |
315 ;; position after the indentation. Else stay at same point in text. | |
316 (if (> (- (point-max) pos) (point)) | |
317 (goto-char (- (point-max) pos)))) | |
318 shift-amt)) | |
319 | |
320 (defun calculate-icon-indent (&optional parse-start) | |
321 "Return appropriate indentation for current line as Icon code. | |
322 In usual case returns an integer: the column to indent to. | |
323 Returns nil if line starts inside a string, t if in a comment." | |
324 (save-excursion | |
325 (beginning-of-line) | |
326 (let ((indent-point (point)) | |
327 (case-fold-search nil) | |
328 state | |
329 containing-sexp | |
330 toplevel) | |
331 (if parse-start | |
332 (goto-char parse-start) | |
333 (setq toplevel (beginning-of-icon-defun))) | |
334 (while (< (point) indent-point) | |
335 (setq parse-start (point)) | |
336 (setq state (parse-partial-sexp (point) indent-point 0)) | |
337 (setq containing-sexp (car (cdr state)))) | |
338 (cond ((or (nth 3 state) (nth 4 state)) | |
339 ;; return nil or t if should not change this line | |
340 (nth 4 state)) | |
341 ((and containing-sexp | |
342 (/= (char-after containing-sexp) ?{)) | |
343 ;; line is expression, not statement: | |
344 ;; indent to just after the surrounding open. | |
345 (goto-char (1+ containing-sexp)) | |
346 (current-column)) | |
347 (t | |
348 (if toplevel | |
349 ;; Outside any procedures. | |
350 (progn (icon-backward-to-noncomment (point-min)) | |
351 (if (icon-is-continuation-line) | |
352 icon-continued-statement-offset 0)) | |
353 ;; Statement level. | |
354 (if (null containing-sexp) | |
355 (progn (beginning-of-icon-defun) | |
356 (setq containing-sexp (point)))) | |
357 (goto-char indent-point) | |
358 ;; Is it a continuation or a new statement? | |
359 ;; Find previous non-comment character. | |
360 (icon-backward-to-noncomment containing-sexp) | |
361 ;; Now we get the answer. | |
362 (if (icon-is-continuation-line) | |
363 ;; This line is continuation of preceding line's statement; | |
364 ;; indent icon-continued-statement-offset more than the | |
365 ;; first line of the statement. | |
366 (progn | |
367 (icon-backward-to-start-of-continued-exp containing-sexp) | |
368 (+ icon-continued-statement-offset (current-column) | |
369 (if (save-excursion (goto-char indent-point) | |
370 (skip-chars-forward " \t") | |
371 (eq (following-char) ?{)) | |
372 icon-continued-brace-offset 0))) | |
373 ;; This line starts a new statement. | |
374 ;; Position following last unclosed open. | |
375 (goto-char containing-sexp) | |
376 ;; Is line first statement after an open-brace? | |
377 (or | |
378 ;; If no, find that first statement and indent like it. | |
379 (save-excursion | |
380 (if (looking-at "procedure\\s ") | |
381 (forward-sexp 3) | |
382 (forward-char 1)) | |
383 (while (progn (skip-chars-forward " \t\n") | |
384 (looking-at "#")) | |
385 ;; Skip over comments following openbrace. | |
386 (forward-line 1)) | |
387 ;; The first following code counts | |
388 ;; if it is before the line we want to indent. | |
389 (and (< (point) indent-point) | |
390 (current-column))) | |
391 ;; If no previous statement, | |
392 ;; indent it relative to line brace is on. | |
393 ;; For open brace in column zero, don't let statement | |
394 ;; start there too. If icon-indent-level is zero, | |
395 ;; use icon-brace-offset + icon-continued-statement-offset | |
396 ;; instead. | |
397 ;; For open-braces not the first thing in a line, | |
398 ;; add in icon-brace-imaginary-offset. | |
399 (+ (if (and (bolp) (zerop icon-indent-level)) | |
400 (+ icon-brace-offset | |
401 icon-continued-statement-offset) | |
402 icon-indent-level) | |
403 ;; Move back over whitespace before the openbrace. | |
404 ;; If openbrace is not first nonwhite thing on the line, | |
405 ;; add the icon-brace-imaginary-offset. | |
406 (progn (skip-chars-backward " \t") | |
407 (if (bolp) 0 icon-brace-imaginary-offset)) | |
408 ;; Get initial indentation of the line we are on. | |
409 (current-indentation)))))))))) | |
410 | |
411 ;; List of words to check for as the last thing on a line. | |
412 ;; If cdr is t, next line is a continuation of the same statement, | |
413 ;; if cdr is nil, next line starts a new (possibly indented) statement. | |
414 | |
415 (defconst icon-resword-alist | |
416 '(("by" . t) ("case" . t) ("create") ("do") ("dynamic" . t) ("else") | |
417 ("every" . t) ("if" . t) ("global" . t) ("initial" . t) | |
418 ("link" . t) ("local" . t) ("of") ("record" . t) ("repeat" . t) | |
419 ("static" . t) ("then") ("to" . t) ("until" . t) ("while" . t))) | |
420 | |
421 (defun icon-is-continuation-line () | |
422 (let* ((ch (preceding-char)) | |
423 (ch-syntax (char-syntax ch))) | |
424 (if (eq ch-syntax ?w) | |
425 (assoc (buffer-substring | |
426 (progn (forward-word -1) (point)) | |
427 (progn (forward-word 1) (point))) | |
428 icon-resword-alist) | |
30947 | 429 (not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\# ?\, ?\. ?\n)))))) |
36 | 430 |
431 (defun icon-backward-to-noncomment (lim) | |
432 (let (opoint stop) | |
433 (while (not stop) | |
434 (skip-chars-backward " \t\n\f" lim) | |
435 (setq opoint (point)) | |
436 (beginning-of-line) | |
437 (if (and (nth 5 (parse-partial-sexp (point) opoint)) | |
438 (< lim (point))) | |
439 (search-backward "#") | |
440 (setq stop t))))) | |
441 | |
442 (defun icon-backward-to-start-of-continued-exp (lim) | |
443 (if (memq (preceding-char) '(?\) ?\])) | |
444 (forward-sexp -1)) | |
445 (beginning-of-line) | |
446 (skip-chars-forward " \t") | |
447 (cond | |
448 ((<= (point) lim) (goto-char (1+ lim))) | |
449 ((not (icon-is-continued-line)) 0) | |
450 ((and (eq (char-syntax (following-char)) ?w) | |
451 (cdr | |
452 (assoc (buffer-substring (point) | |
453 (save-excursion (forward-word 1) (point))) | |
454 icon-resword-alist))) 0) | |
455 (t (end-of-line 0) (icon-backward-to-start-of-continued-exp lim)))) | |
456 | |
457 (defun icon-is-continued-line () | |
458 (save-excursion | |
459 (end-of-line 0) | |
460 (icon-is-continuation-line))) | |
461 | |
462 (defun icon-backward-to-start-of-if (&optional limit) | |
210 | 463 "Move to the start of the last \"unbalanced\" if." |
36 | 464 (or limit (setq limit (save-excursion (beginning-of-icon-defun) (point)))) |
465 (let ((if-level 1) | |
466 (case-fold-search nil)) | |
467 (while (not (zerop if-level)) | |
468 (backward-sexp 1) | |
469 (cond ((looking-at "else\\b") | |
470 (setq if-level (1+ if-level))) | |
471 ((looking-at "if\\b") | |
472 (setq if-level (1- if-level))) | |
473 ((< (point) limit) | |
474 (setq if-level 0) | |
475 (goto-char limit)))))) | |
476 | |
477 (defun mark-icon-function () | |
478 "Put mark at end of Icon function, point at beginning." | |
479 (interactive) | |
480 (push-mark (point)) | |
481 (end-of-icon-defun) | |
482 (push-mark (point)) | |
483 (beginning-of-line 0) | |
484 (beginning-of-icon-defun)) | |
485 | |
486 (defun beginning-of-icon-defun () | |
487 "Go to the start of the enclosing procedure; return t if at top level." | |
488 (interactive) | |
489 (if (re-search-backward "^procedure\\s \\|^end[ \t\n]" (point-min) 'move) | |
490 (looking-at "e") | |
491 t)) | |
492 | |
493 (defun end-of-icon-defun () | |
494 (interactive) | |
495 (if (not (bobp)) (forward-char -1)) | |
496 (re-search-forward "\\(\\s \\|^\\)end\\(\\s \\|$\\)" (point-max) 'move) | |
497 (forward-word -1) | |
498 (forward-line 1)) | |
499 | |
500 (defun indent-icon-exp () | |
501 "Indent each line of the Icon grouping following point." | |
502 (interactive) | |
503 (let ((indent-stack (list nil)) | |
504 (contain-stack (list (point))) | |
505 (case-fold-search nil) | |
506 restart outer-loop-done inner-loop-done state ostate | |
17974
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
507 this-indent last-sexp last-depth |
36 | 508 at-else at-brace at-do |
509 (opoint (point)) | |
510 (next-depth 0)) | |
511 (save-excursion | |
512 (forward-sexp 1)) | |
513 (save-excursion | |
514 (setq outer-loop-done nil) | |
515 (while (and (not (eobp)) (not outer-loop-done)) | |
516 (setq last-depth next-depth) | |
517 ;; Compute how depth changes over this line | |
518 ;; plus enough other lines to get to one that | |
519 ;; does not end inside a comment or string. | |
520 ;; Meanwhile, do appropriate indentation on comment lines. | |
17974
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
521 (setq inner-loop-done nil) |
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
522 (while (and (not inner-loop-done) |
36 | 523 (not (and (eobp) (setq outer-loop-done t)))) |
524 (setq ostate state) | |
525 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point)) | |
526 nil nil state)) | |
527 (setq next-depth (car state)) | |
528 (if (and (car (cdr (cdr state))) | |
529 (>= (car (cdr (cdr state))) 0)) | |
530 (setq last-sexp (car (cdr (cdr state))))) | |
531 (if (or (nth 4 ostate)) | |
532 (icon-indent-line)) | |
533 (if (or (nth 3 state)) | |
534 (forward-line 1) | |
17974
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
535 (setq inner-loop-done t))) |
36 | 536 (if (<= next-depth 0) |
537 (setq outer-loop-done t)) | |
538 (if outer-loop-done | |
539 nil | |
540 (if (/= last-depth next-depth) | |
541 (setq last-sexp nil)) | |
542 (while (> last-depth next-depth) | |
543 (setq indent-stack (cdr indent-stack) | |
544 contain-stack (cdr contain-stack) | |
545 last-depth (1- last-depth))) | |
546 (while (< last-depth next-depth) | |
547 (setq indent-stack (cons nil indent-stack) | |
548 contain-stack (cons nil contain-stack) | |
549 last-depth (1+ last-depth))) | |
550 (if (null (car contain-stack)) | |
551 (setcar contain-stack (or (car (cdr state)) | |
552 (save-excursion (forward-sexp -1) | |
553 (point))))) | |
554 (forward-line 1) | |
555 (skip-chars-forward " \t") | |
556 (if (eolp) | |
557 nil | |
558 (if (and (car indent-stack) | |
559 (>= (car indent-stack) 0)) | |
560 ;; Line is on an existing nesting level. | |
561 ;; Lines inside parens are handled specially. | |
562 (if (/= (char-after (car contain-stack)) ?{) | |
563 (setq this-indent (car indent-stack)) | |
564 ;; Line is at statement level. | |
565 ;; Is it a new statement? Is it an else? | |
566 ;; Find last non-comment character before this line | |
567 (save-excursion | |
568 (setq at-else (looking-at "else\\W")) | |
569 (setq at-brace (= (following-char) ?{)) | |
570 (icon-backward-to-noncomment opoint) | |
571 (if (icon-is-continuation-line) | |
572 ;; Preceding line did not end in comma or semi; | |
573 ;; indent this line icon-continued-statement-offset | |
574 ;; more than previous. | |
575 (progn | |
576 (icon-backward-to-start-of-continued-exp (car contain-stack)) | |
577 (setq this-indent | |
578 (+ icon-continued-statement-offset (current-column) | |
579 (if at-brace icon-continued-brace-offset 0)))) | |
580 ;; Preceding line ended in comma or semi; | |
581 ;; use the standard indent for this level. | |
582 (if at-else | |
583 (progn (icon-backward-to-start-of-if opoint) | |
584 (setq this-indent (current-indentation))) | |
585 (setq this-indent (car indent-stack)))))) | |
586 ;; Just started a new nesting level. | |
587 ;; Compute the standard indent for this level. | |
588 (let ((val (calculate-icon-indent | |
589 (if (car indent-stack) | |
590 (- (car indent-stack)))))) | |
591 (setcar indent-stack | |
592 (setq this-indent val)))) | |
593 ;; Adjust line indentation according to its contents | |
594 (if (or (= (following-char) ?}) | |
595 (looking-at "end\\b")) | |
596 (setq this-indent (- this-indent icon-indent-level))) | |
597 (if (= (following-char) ?{) | |
598 (setq this-indent (+ this-indent icon-brace-offset))) | |
599 ;; Put chosen indentation into effect. | |
600 (or (= (current-column) this-indent) | |
601 (progn | |
602 (delete-region (point) (progn (beginning-of-line) (point))) | |
603 (indent-to this-indent))) | |
604 ;; Indent any comment following the text. | |
605 (or (looking-at comment-start-skip) | |
606 (if (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t) | |
607 (progn (indent-for-comment) (beginning-of-line)))))))))) | |
608 | |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
609 (defconst icon-font-lock-keywords-1 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
610 (eval-when-compile |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
611 (list |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
612 ;; Fontify procedure name definitions. |
18281
ffc2fda197bc
(icon-indent-line): A comment ends at the end of the
Richard M. Stallman <rms@gnu.org>
parents:
18272
diff
changeset
|
613 '("^[ \t]*\\(procedure\\)\\>[ \t]*\\(\\sw+\\)?" |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
614 (1 font-lock-builtin-face) (2 font-lock-function-name-face nil t)))) |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
615 "Subdued level highlighting for Icon mode.") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
616 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
617 (defconst icon-font-lock-keywords-2 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
618 (append |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
619 icon-font-lock-keywords-1 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
620 (eval-when-compile |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
621 (list |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
622 ;; Fontify all type specifiers. |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
623 (cons |
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
624 (regexp-opt '("null" "string" "co-expression" "table" "integer" |
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
625 "cset" "set" "real" "file" "list") 'words) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
626 'font-lock-type-face) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
627 ;; Fontify all keywords. |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
628 ;; |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
629 (cons |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
630 (regexp-opt |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
631 '("break" "do" "next" "repeat" "to" "by" "else" "if" "not" "return" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
632 "until" "case" "of" "while" "create" "every" "suspend" "default" |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
633 "fail" "record" "then") 'words) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
634 'font-lock-keyword-face) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
635 ;; "end" "initial" |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
636 (cons (regexp-opt '("end" "initial") 'words) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
637 'font-lock-builtin-face) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
638 ;; Fontify all system variables. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
639 (cons |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
640 (regexp-opt |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
641 '("&allocated" "&ascii" "&clock" "&col" "&collections" "&column" |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
642 "&control" "&cset" "¤t" "&date" "&dateline" "&digits" "&dump" |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
643 "&e" "&error" "&errornumber" "&errortext" "&errorvalue" "&errout" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
644 "&eventcode" "&eventsource" "&eventvalue" "&fail" "&features" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
645 "&file" "&host" "&input" "&interval" "&lcase" "&ldrag" "&letters" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
646 "&level" "&line" "&lpress" "&lrelease" "&main" "&mdrag" "&meta" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
647 "&mpress" "&mrelease" "&null" "&output" "&phi" "&pi" "&pos" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
648 "&progname" "&random" "&rdrag" "®ions" "&resize" "&row" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
649 "&rpress" "&rrelease" "&shift" "&source" "&storage" "&subject" |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
650 "&time" "&trace" "&ucase" "&version" "&window" "&x" "&y") t) |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
19834
diff
changeset
|
651 'font-lock-constant-face) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
652 (cons ;; global local static declarations and link files |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
653 (concat |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
654 "^[ \t]*" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
655 (regexp-opt '("global" "link" "local" "static") t) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
656 "\\(\\sw+\\>\\)*") |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
657 '((1 font-lock-builtin-face) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
658 (font-lock-match-c-style-declaration-item-and-skip-to-next |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
659 (goto-char (or (match-beginning 2) (match-end 1))) nil |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
660 (1 (if (match-beginning 2) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
661 font-lock-function-name-face |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
662 font-lock-variable-name-face))))) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
663 |
18281
ffc2fda197bc
(icon-indent-line): A comment ends at the end of the
Richard M. Stallman <rms@gnu.org>
parents:
18272
diff
changeset
|
664 (cons ;; $define $elif $ifdef $ifndef $undef |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
665 (concat "^" |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
666 (regexp-opt'("$define" "$elif" "$ifdef" "$ifndef" "$undef") t) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
667 "\\>[ \t]*\\([^ \t\n]+\\)?") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
668 '((1 font-lock-builtin-face) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
669 (4 font-lock-variable-name-face nil t))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
670 (cons ;; $dump $endif $else $include |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
671 (concat |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
672 "^" (regexp-opt'("$dump" "$endif" "$else" "$include") t) "\\>" ) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
673 'font-lock-builtin-face) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
674 (cons ;; $warning $error |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
675 (concat "^" (regexp-opt '("$warning" "$error") t) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
676 "\\>[ \t]*\\(.+\\)?") |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
677 '((1 font-lock-builtin-face) (3 font-lock-warning-face nil t)))))) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
678 "Gaudy level highlighting for Icon mode.") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
679 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
680 (defvar icon-font-lock-keywords icon-font-lock-keywords-1 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
681 "Default expressions to highlight in `icon-mode'.") |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
682 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
683 ;;;used by hs-minor-mode |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
684 (defun icon-forward-sexp-function (arg) |
17969
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
685 (if (< arg 0) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
686 (beginning-of-icon-defun) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
687 (end-of-icon-defun) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
688 (forward-char -1))) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
689 |
18381 | 690 (provide 'icon) |
691 | |
52401 | 692 ;;; arch-tag: 8abf8c99-e7df-44af-a58f-ef5ed2ee52cb |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
210
diff
changeset
|
693 ;;; icon.el ends here |