]> code.delx.au - gnu-emacs/blob - lisp/progmodes/icon.el
(dsssl-sgml-declaration): Doc fix.
[gnu-emacs] / lisp / progmodes / icon.el
1 ;;; icon.el --- mode for editing Icon code
2
3 ;; Copyright (C) 1989 Free Software Foundation, Inc.
4
5 ;; Author: Chris Smith <csmith@convex.com>
6 ;; Created: 15 Feb 89
7 ;; Keywords: languages
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; A major mode for editing the Icon programming language.
29
30 ;;; Code:
31
32 (defvar icon-mode-abbrev-table nil
33 "Abbrev table in use in Icon-mode buffers.")
34 (define-abbrev-table 'icon-mode-abbrev-table ())
35
36 (defvar icon-mode-map ()
37 "Keymap used in Icon mode.")
38 (if icon-mode-map
39 ()
40 (let ((map (make-sparse-keymap "Icon")))
41 (setq icon-mode-map (make-sparse-keymap))
42 (define-key icon-mode-map "{" 'electric-icon-brace)
43 (define-key icon-mode-map "}" 'electric-icon-brace)
44 (define-key icon-mode-map "\e\C-h" 'mark-icon-function)
45 (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun)
46 (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun)
47 (define-key icon-mode-map "\e\C-q" 'indent-icon-exp)
48 (define-key icon-mode-map "\177" 'backward-delete-char-untabify)
49 (define-key icon-mode-map "\t" 'icon-indent-command)
50
51 (define-key icon-mode-map [menu-bar] (make-sparse-keymap))
52 (define-key icon-mode-map [menu-bar icon]
53 (cons "Icon" map))
54 (define-key map [beginning-of-icon-defun] '("Beginning of function" . beginning-of-icon-defun))
55 (define-key map [end-of-icon-defun] '("End of function" . end-of-icon-defun))
56 (define-key map [comment-region] '("Comment Out Region" . comment-region))
57 (define-key map [indent-region] '("Indent Region" . indent-region))
58 (define-key map [indent-line] '("Indent Line" . icon-indent-command))
59 (put 'eval-region 'menu-enable 'mark-active)
60 (put 'comment-region 'menu-enable 'mark-active)
61 (put 'indent-region 'menu-enable 'mark-active)))
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
85 (defvar icon-indent-level 4
86 "*Indentation of Icon statements with respect to containing block.")
87 (defvar icon-brace-imaginary-offset 0
88 "*Imagined indentation of a Icon open brace that actually follows a statement.")
89 (defvar icon-brace-offset 0
90 "*Extra indentation for braces, compared with other text in same context.")
91 (defvar icon-continued-statement-offset 4
92 "*Extra indent for lines not starting new statements.")
93 (defvar icon-continued-brace-offset 0
94 "*Extra indent for substatements that start with open-braces.
95 This is in addition to icon-continued-statement-offset.")
96
97 (defvar icon-auto-newline nil
98 "*Non-nil means automatically newline before and after braces
99 inserted in Icon code.")
100
101 (defvar icon-tab-always-indent t
102 "*Non-nil means TAB in Icon mode should always reindent the current line,
103 regardless of where in the line point is when the TAB command is used.")
104
105 (defvar icon-imenu-generic-expression
106 '((nil "^[ \t]*procedure[ \t]*\\(\\sw+\\)[ \t]*(" 1))
107 "Imenu expression for Icon-mode. See `imenu-generic-expression'.")
108
109
110 \f
111 ;;;###autoload
112 (defun icon-mode ()
113 "Major mode for editing Icon code.
114 Expression and list commands understand all Icon brackets.
115 Tab indents for Icon code.
116 Paragraphs are separated by blank lines only.
117 Delete converts tabs to spaces as it moves back.
118 \\{icon-mode-map}
119 Variables controlling indentation style:
120 icon-tab-always-indent
121 Non-nil means TAB in Icon mode should always reindent the current line,
122 regardless of where in the line point is when the TAB command is used.
123 icon-auto-newline
124 Non-nil means automatically newline before and after braces
125 inserted in Icon code.
126 icon-indent-level
127 Indentation of Icon statements within surrounding block.
128 The surrounding block's indentation is the indentation
129 of the line on which the open-brace appears.
130 icon-continued-statement-offset
131 Extra indentation given to a substatement, such as the
132 then-clause of an if or body of a while.
133 icon-continued-brace-offset
134 Extra indentation given to a brace that starts a substatement.
135 This is in addition to `icon-continued-statement-offset'.
136 icon-brace-offset
137 Extra indentation for line if it starts with an open brace.
138 icon-brace-imaginary-offset
139 An open brace following other text is treated as if it were
140 this far to the right of the start of its line.
141
142 Turning on Icon mode calls the value of the variable `icon-mode-hook'
143 with no args, if that value is non-nil."
144 (interactive)
145 (kill-all-local-variables)
146 (use-local-map icon-mode-map)
147 (setq major-mode 'icon-mode)
148 (setq mode-name "Icon")
149 (setq local-abbrev-table icon-mode-abbrev-table)
150 (set-syntax-table icon-mode-syntax-table)
151 (make-local-variable 'paragraph-start)
152 (setq paragraph-start (concat "$\\|" page-delimiter))
153 (make-local-variable 'paragraph-separate)
154 (setq paragraph-separate paragraph-start)
155 (make-local-variable 'indent-line-function)
156 (setq indent-line-function 'icon-indent-line)
157 (make-local-variable 'require-final-newline)
158 (setq require-final-newline t)
159 (make-local-variable 'comment-start)
160 (setq comment-start "# ")
161 (make-local-variable 'comment-end)
162 (setq comment-end "")
163 (make-local-variable 'comment-column)
164 (setq comment-column 32)
165 (make-local-variable 'comment-start-skip)
166 (setq comment-start-skip "# *")
167 (make-local-variable 'comment-indent-function)
168 (setq comment-indent-function 'icon-comment-indent)
169 ;; font-lock support
170 (make-local-variable 'font-lock-defaults)
171 (setq font-lock-defaults
172 '((icon-font-lock-keywords
173 icon-font-lock-keywords-1
174 icon-font-lock-keywords-2
175 )
176 nil nil ((?_ . "w")) beginning-of-defun
177 (font-lock-comment-start-regexp . "#")
178 (font-lock-mark-block-function . mark-defun)))
179 ;; imenu support
180 (make-local-variable 'imenu-generic-expression)
181 (setq imenu-generic-expression icon-imenu-generic-expression)
182 ;; hideshow support
183 ;; we start from the assertion that `hs-special-modes-alist' is autoloaded.
184 (pushnew '(icon-mode "procedure" "end" icon-forward-sexp-function)
185 hs-special-modes-alist :test 'equal)
186 (run-hooks 'icon-mode-hook))
187 \f
188 ;; This is used by indent-for-comment to decide how much to
189 ;; indent a comment in Icon code based on its context.
190 (defun icon-comment-indent ()
191 (if (looking-at "^#")
192 0
193 (save-excursion
194 (skip-chars-backward " \t")
195 (max (if (bolp) 0 (1+ (current-column)))
196 comment-column))))
197
198 (defun electric-icon-brace (arg)
199 "Insert character and correct line's indentation."
200 (interactive "P")
201 (let (insertpos)
202 (if (and (not arg)
203 (eolp)
204 (or (save-excursion
205 (skip-chars-backward " \t")
206 (bolp))
207 (if icon-auto-newline
208 (progn (icon-indent-line) (newline) t)
209 nil)))
210 (progn
211 (insert last-command-char)
212 (icon-indent-line)
213 (if icon-auto-newline
214 (progn
215 (newline)
216 ;; (newline) may have done auto-fill
217 (setq insertpos (- (point) 2))
218 (icon-indent-line)))
219 (save-excursion
220 (if insertpos (goto-char (1+ insertpos)))
221 (delete-char -1))))
222 (if insertpos
223 (save-excursion
224 (goto-char insertpos)
225 (self-insert-command (prefix-numeric-value arg)))
226 (self-insert-command (prefix-numeric-value arg)))))
227 \f
228 (defun icon-indent-command (&optional whole-exp)
229 (interactive "P")
230 "Indent current line as Icon code, or in some cases insert a tab character.
231 If `icon-tab-always-indent' is non-nil (the default), always indent current
232 line. Otherwise, indent the current line only if point is at the left margin
233 or in the line's indentation; otherwise insert a tab.
234
235 A numeric argument, regardless of its value, means indent rigidly all the
236 lines of the expression starting after point so that this line becomes
237 properly indented. The relative indentation among the lines of the
238 expression are preserved."
239 (if whole-exp
240 ;; If arg, always indent this line as Icon
241 ;; and shift remaining lines of expression the same amount.
242 (let ((shift-amt (icon-indent-line))
243 beg end)
244 (save-excursion
245 (if icon-tab-always-indent
246 (beginning-of-line))
247 (setq beg (point))
248 (forward-sexp 1)
249 (setq end (point))
250 (goto-char beg)
251 (forward-line 1)
252 (setq beg (point)))
253 (if (> end beg)
254 (indent-code-rigidly beg end shift-amt "#")))
255 (if (and (not icon-tab-always-indent)
256 (save-excursion
257 (skip-chars-backward " \t")
258 (not (bolp))))
259 (insert-tab)
260 (icon-indent-line))))
261
262 (defun icon-indent-line ()
263 "Indent current line as Icon code.
264 Return the amount the indentation changed by."
265 (let ((indent (calculate-icon-indent nil))
266 beg shift-amt
267 (case-fold-search nil)
268 (pos (- (point-max) (point))))
269 (beginning-of-line)
270 (setq beg (point))
271 (cond ((eq indent nil)
272 (setq indent (current-indentation)))
273 ((eq indent t)
274 (setq indent (calculate-icon-indent-within-comment)))
275 ((looking-at "[ \t]*#")
276 (setq indent 0))
277 (t
278 (skip-chars-forward " \t")
279 (if (listp indent) (setq indent (car indent)))
280 (cond ((and (looking-at "else\\b")
281 (not (looking-at "else\\s_")))
282 (setq indent (save-excursion
283 (icon-backward-to-start-of-if)
284 (current-indentation))))
285 ((or (= (following-char) ?})
286 (looking-at "end\\b"))
287 (setq indent (- indent icon-indent-level)))
288 ((= (following-char) ?{)
289 (setq indent (+ indent icon-brace-offset))))))
290 (skip-chars-forward " \t")
291 (setq shift-amt (- indent (current-column)))
292 (if (zerop shift-amt)
293 (if (> (- (point-max) pos) (point))
294 (goto-char (- (point-max) pos)))
295 (delete-region beg (point))
296 (indent-to indent)
297 ;; If initial point was within line's indentation,
298 ;; position after the indentation. Else stay at same point in text.
299 (if (> (- (point-max) pos) (point))
300 (goto-char (- (point-max) pos))))
301 shift-amt))
302
303 (defun calculate-icon-indent (&optional parse-start)
304 "Return appropriate indentation for current line as Icon code.
305 In usual case returns an integer: the column to indent to.
306 Returns nil if line starts inside a string, t if in a comment."
307 (save-excursion
308 (beginning-of-line)
309 (let ((indent-point (point))
310 (case-fold-search nil)
311 state
312 containing-sexp
313 toplevel)
314 (if parse-start
315 (goto-char parse-start)
316 (setq toplevel (beginning-of-icon-defun)))
317 (while (< (point) indent-point)
318 (setq parse-start (point))
319 (setq state (parse-partial-sexp (point) indent-point 0))
320 (setq containing-sexp (car (cdr state))))
321 (cond ((or (nth 3 state) (nth 4 state))
322 ;; return nil or t if should not change this line
323 (nth 4 state))
324 ((and containing-sexp
325 (/= (char-after containing-sexp) ?{))
326 ;; line is expression, not statement:
327 ;; indent to just after the surrounding open.
328 (goto-char (1+ containing-sexp))
329 (current-column))
330 (t
331 (if toplevel
332 ;; Outside any procedures.
333 (progn (icon-backward-to-noncomment (point-min))
334 (if (icon-is-continuation-line)
335 icon-continued-statement-offset 0))
336 ;; Statement level.
337 (if (null containing-sexp)
338 (progn (beginning-of-icon-defun)
339 (setq containing-sexp (point))))
340 (goto-char indent-point)
341 ;; Is it a continuation or a new statement?
342 ;; Find previous non-comment character.
343 (icon-backward-to-noncomment containing-sexp)
344 ;; Now we get the answer.
345 (if (icon-is-continuation-line)
346 ;; This line is continuation of preceding line's statement;
347 ;; indent icon-continued-statement-offset more than the
348 ;; first line of the statement.
349 (progn
350 (icon-backward-to-start-of-continued-exp containing-sexp)
351 (+ icon-continued-statement-offset (current-column)
352 (if (save-excursion (goto-char indent-point)
353 (skip-chars-forward " \t")
354 (eq (following-char) ?{))
355 icon-continued-brace-offset 0)))
356 ;; This line starts a new statement.
357 ;; Position following last unclosed open.
358 (goto-char containing-sexp)
359 ;; Is line first statement after an open-brace?
360 (or
361 ;; If no, find that first statement and indent like it.
362 (save-excursion
363 (if (looking-at "procedure\\s ")
364 (forward-sexp 3)
365 (forward-char 1))
366 (while (progn (skip-chars-forward " \t\n")
367 (looking-at "#"))
368 ;; Skip over comments following openbrace.
369 (forward-line 1))
370 ;; The first following code counts
371 ;; if it is before the line we want to indent.
372 (and (< (point) indent-point)
373 (current-column)))
374 ;; If no previous statement,
375 ;; indent it relative to line brace is on.
376 ;; For open brace in column zero, don't let statement
377 ;; start there too. If icon-indent-level is zero,
378 ;; use icon-brace-offset + icon-continued-statement-offset
379 ;; instead.
380 ;; For open-braces not the first thing in a line,
381 ;; add in icon-brace-imaginary-offset.
382 (+ (if (and (bolp) (zerop icon-indent-level))
383 (+ icon-brace-offset
384 icon-continued-statement-offset)
385 icon-indent-level)
386 ;; Move back over whitespace before the openbrace.
387 ;; If openbrace is not first nonwhite thing on the line,
388 ;; add the icon-brace-imaginary-offset.
389 (progn (skip-chars-backward " \t")
390 (if (bolp) 0 icon-brace-imaginary-offset))
391 ;; Get initial indentation of the line we are on.
392 (current-indentation))))))))))
393
394 ;; List of words to check for as the last thing on a line.
395 ;; If cdr is t, next line is a continuation of the same statement,
396 ;; if cdr is nil, next line starts a new (possibly indented) statement.
397
398 (defconst icon-resword-alist
399 '(("by" . t) ("case" . t) ("create") ("do") ("dynamic" . t) ("else")
400 ("every" . t) ("if" . t) ("global" . t) ("initial" . t)
401 ("link" . t) ("local" . t) ("of") ("record" . t) ("repeat" . t)
402 ("static" . t) ("then") ("to" . t) ("until" . t) ("while" . t)))
403
404 (defun icon-is-continuation-line ()
405 (let* ((ch (preceding-char))
406 (ch-syntax (char-syntax ch)))
407 (if (eq ch-syntax ?w)
408 (assoc (buffer-substring
409 (progn (forward-word -1) (point))
410 (progn (forward-word 1) (point)))
411 icon-resword-alist)
412 (not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\n))))))
413
414 (defun icon-backward-to-noncomment (lim)
415 (let (opoint stop)
416 (while (not stop)
417 (skip-chars-backward " \t\n\f" lim)
418 (setq opoint (point))
419 (beginning-of-line)
420 (if (and (nth 5 (parse-partial-sexp (point) opoint))
421 (< lim (point)))
422 (search-backward "#")
423 (setq stop t)))))
424
425 (defun icon-backward-to-start-of-continued-exp (lim)
426 (if (memq (preceding-char) '(?\) ?\]))
427 (forward-sexp -1))
428 (beginning-of-line)
429 (skip-chars-forward " \t")
430 (cond
431 ((<= (point) lim) (goto-char (1+ lim)))
432 ((not (icon-is-continued-line)) 0)
433 ((and (eq (char-syntax (following-char)) ?w)
434 (cdr
435 (assoc (buffer-substring (point)
436 (save-excursion (forward-word 1) (point)))
437 icon-resword-alist))) 0)
438 (t (end-of-line 0) (icon-backward-to-start-of-continued-exp lim))))
439
440 (defun icon-is-continued-line ()
441 (save-excursion
442 (end-of-line 0)
443 (icon-is-continuation-line)))
444
445 (defun icon-backward-to-start-of-if (&optional limit)
446 "Move to the start of the last \"unbalanced\" if."
447 (or limit (setq limit (save-excursion (beginning-of-icon-defun) (point))))
448 (let ((if-level 1)
449 (case-fold-search nil))
450 (while (not (zerop if-level))
451 (backward-sexp 1)
452 (cond ((looking-at "else\\b")
453 (setq if-level (1+ if-level)))
454 ((looking-at "if\\b")
455 (setq if-level (1- if-level)))
456 ((< (point) limit)
457 (setq if-level 0)
458 (goto-char limit))))))
459 \f
460 (defun mark-icon-function ()
461 "Put mark at end of Icon function, point at beginning."
462 (interactive)
463 (push-mark (point))
464 (end-of-icon-defun)
465 (push-mark (point))
466 (beginning-of-line 0)
467 (beginning-of-icon-defun))
468
469 (defun beginning-of-icon-defun ()
470 "Go to the start of the enclosing procedure; return t if at top level."
471 (interactive)
472 (if (re-search-backward "^procedure\\s \\|^end[ \t\n]" (point-min) 'move)
473 (looking-at "e")
474 t))
475
476 (defun end-of-icon-defun ()
477 (interactive)
478 (if (not (bobp)) (forward-char -1))
479 (re-search-forward "\\(\\s \\|^\\)end\\(\\s \\|$\\)" (point-max) 'move)
480 (forward-word -1)
481 (forward-line 1))
482 \f
483 (defun indent-icon-exp ()
484 "Indent each line of the Icon grouping following point."
485 (interactive)
486 (let ((indent-stack (list nil))
487 (contain-stack (list (point)))
488 (case-fold-search nil)
489 restart outer-loop-done inner-loop-done state ostate
490 this-indent last-sexp
491 at-else at-brace at-do
492 (opoint (point))
493 (next-depth 0))
494 (save-excursion
495 (forward-sexp 1))
496 (save-excursion
497 (setq outer-loop-done nil)
498 (while (and (not (eobp)) (not outer-loop-done))
499 (setq last-depth next-depth)
500 ;; Compute how depth changes over this line
501 ;; plus enough other lines to get to one that
502 ;; does not end inside a comment or string.
503 ;; Meanwhile, do appropriate indentation on comment lines.
504 (setq innerloop-done nil)
505 (while (and (not innerloop-done)
506 (not (and (eobp) (setq outer-loop-done t))))
507 (setq ostate state)
508 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point))
509 nil nil state))
510 (setq next-depth (car state))
511 (if (and (car (cdr (cdr state)))
512 (>= (car (cdr (cdr state))) 0))
513 (setq last-sexp (car (cdr (cdr state)))))
514 (if (or (nth 4 ostate))
515 (icon-indent-line))
516 (if (or (nth 3 state))
517 (forward-line 1)
518 (setq innerloop-done t)))
519 (if (<= next-depth 0)
520 (setq outer-loop-done t))
521 (if outer-loop-done
522 nil
523 (if (/= last-depth next-depth)
524 (setq last-sexp nil))
525 (while (> last-depth next-depth)
526 (setq indent-stack (cdr indent-stack)
527 contain-stack (cdr contain-stack)
528 last-depth (1- last-depth)))
529 (while (< last-depth next-depth)
530 (setq indent-stack (cons nil indent-stack)
531 contain-stack (cons nil contain-stack)
532 last-depth (1+ last-depth)))
533 (if (null (car contain-stack))
534 (setcar contain-stack (or (car (cdr state))
535 (save-excursion (forward-sexp -1)
536 (point)))))
537 (forward-line 1)
538 (skip-chars-forward " \t")
539 (if (eolp)
540 nil
541 (if (and (car indent-stack)
542 (>= (car indent-stack) 0))
543 ;; Line is on an existing nesting level.
544 ;; Lines inside parens are handled specially.
545 (if (/= (char-after (car contain-stack)) ?{)
546 (setq this-indent (car indent-stack))
547 ;; Line is at statement level.
548 ;; Is it a new statement? Is it an else?
549 ;; Find last non-comment character before this line
550 (save-excursion
551 (setq at-else (looking-at "else\\W"))
552 (setq at-brace (= (following-char) ?{))
553 (icon-backward-to-noncomment opoint)
554 (if (icon-is-continuation-line)
555 ;; Preceding line did not end in comma or semi;
556 ;; indent this line icon-continued-statement-offset
557 ;; more than previous.
558 (progn
559 (icon-backward-to-start-of-continued-exp (car contain-stack))
560 (setq this-indent
561 (+ icon-continued-statement-offset (current-column)
562 (if at-brace icon-continued-brace-offset 0))))
563 ;; Preceding line ended in comma or semi;
564 ;; use the standard indent for this level.
565 (if at-else
566 (progn (icon-backward-to-start-of-if opoint)
567 (setq this-indent (current-indentation)))
568 (setq this-indent (car indent-stack))))))
569 ;; Just started a new nesting level.
570 ;; Compute the standard indent for this level.
571 (let ((val (calculate-icon-indent
572 (if (car indent-stack)
573 (- (car indent-stack))))))
574 (setcar indent-stack
575 (setq this-indent val))))
576 ;; Adjust line indentation according to its contents
577 (if (or (= (following-char) ?})
578 (looking-at "end\\b"))
579 (setq this-indent (- this-indent icon-indent-level)))
580 (if (= (following-char) ?{)
581 (setq this-indent (+ this-indent icon-brace-offset)))
582 ;; Put chosen indentation into effect.
583 (or (= (current-column) this-indent)
584 (progn
585 (delete-region (point) (progn (beginning-of-line) (point)))
586 (indent-to this-indent)))
587 ;; Indent any comment following the text.
588 (or (looking-at comment-start-skip)
589 (if (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t)
590 (progn (indent-for-comment) (beginning-of-line))))))))))
591
592 (defconst icon-font-lock-keywords-1
593 (eval-when-compile
594 (list
595 ;; Fontify procedure name definitions.
596 '("^[ \t]*\\(procedure\\)[ \t]*\\(\\sw+\\)[ \t]*("
597 (1 font-lock-builtin-face) (2 font-lock-function-name-face nil t))))
598 "Subdued level highlighting for `icon-mode'.")
599
600 (defconst icon-font-lock-keywords-2
601 (append
602 icon-font-lock-keywords-1
603 (eval-when-compile
604 (list
605 ;; Fontify all type specifiers.
606 ;;"null" "string" "co-expression" "table" "integer" "cset" "set" "real" "file" "list"
607 (cons "\\<\\(c\\(o-expression\\|set\\)\\|file\\|integer\\|list\\|null\\|real\\|s\\(et\\|tring\\)\\|table\\)\\>"'font-lock-type-face)
608 ;; Fontify all keywords.
609 ;;"break" "do" "next" "repeat" "to" "by" "else" "if" "not" "return" "until" "case" "of" "while" "create" "every" "suspend" "default" "fail" "record" "then"
610 (cons "\\<\\(b\\(reak\\|y\\)\\|c\\(ase\\|reate\\)\\|d\\(efault\\|o\\)\\|e\\(lse\\|very\\)\\|fail\\|if\\|n\\(ext\\|ot\\)\\|of\\|re\\(cord\\|peat\\|turn\\)\\|suspend\\|t\\(hen\\|o\\)\\|until\\|while\\)\\>" 'font-lock-keyword-face)
611 ;; "end" "initial"
612 (cons (concat "\\<\\(end\\|initial\\)\\>") 'font-lock-builtin-face)
613 ;; Fontify all system variables.
614 ;;"&allocated" "&ascii" "&clock" "&col" "&collections" "&column" "&control" "&cset" "&current" "&date" "&dateline" "&digits" "&dump" "&error" "&errornumber" "&errortext" "&errorvalue" "&errout" "&eventcode" "&eventsource" "&eventvalue" "&fail" "&features" "&file" "&host" "&input" "&interval" "&lcase" "&ldrag" "&letters" "&level" "&line" "&lpress" "&lrelease" "&main" "&mdrag" "&meta" "&mpress" "&mrelease" "&null" "&output" "&phi" "&pi" "&pos" "&progname" "&random" "&rdrag" "&regions" "&resize" "&row" "&rpress" "&rrelease" "&shift" "&source" "&storage" "&subject" "&time" "&trace" "&ucase" "&version" "&window" "&x" "&y"
615 (cons (concat "\\(&\\(a\\(llocated\\|scii\\)\\|c\\(lock\\|o\\(l\\(\\|lections\\|umn\\)\\|ntrol\\)\\|set\\|urrent\\)\\|d\\(ate\\(\\|line\\)\\|igits\\|ump\\)\\|e\\(rro\\(r\\(\\|number\\|text\\|value\\)\\|ut\\)\\|vent\\(code\\|source\\|value\\)\\)\\|f\\(ail\\|eatures\\|ile\\)\\|host\\|in\\(put\\|terval\\)\\|l\\(case\\|drag\\|e\\(tters\\|vel\\)\\|ine\\|press\\|release\\)\\|m\\(ain\\|drag\\|eta\\|press\\|release\\)\\|null\\|output\\|p\\(hi\\|i\\|os\\|rogname\\)\\|r\\(andom\\|drag\\|e\\(gions\\|size\\)\\|ow\\|press\\|release\\)\\|s\\(hift\\|ource\\|torage\\|ubject\\)\\|t\\(ime\\|race\\)\\|ucase\\|version\\|window\\|[exy]\\)\\)") 'font-lock-reference-face)
616 ;; global local static declarations and link files
617 (cons "^[ \t]*\\(global\\|link\\|local\\|static\\)\\(\\sw+\\>\\)*"
618 '((1 font-lock-builtin-face)
619 (font-lock-match-c-style-declaration-item-and-skip-to-next
620 (goto-char (or (match-beginning 2) (match-end 1))) nil
621 (1 (if (match-beginning 2)
622 font-lock-function-name-face
623 font-lock-variable-name-face)))))
624 ;; $define $elif $ifdef $ifdef $ifndef
625 (cons "^\\(\\$\\(define\\|elif\\|if\\(\\|def\\|ndef\\)\\|undef\\)\\)[ \t]+\\([^ \t\n]+\\)"
626 '((1 font-lock-builtin-face) (4 font-lock-variable-name-face nil t)))
627 ;; $dump $endif $else $include
628 (cons "^\\(\\$\\(dump\\|e\\(lse\\|ndif\\)\\|include\\)\\)\\>" 'font-lock-builtin-face)
629 ;; $warning $error
630 (cons "^\\(\\$\\(warning\\|error\\)\\)[ \t]+\\([^\n]+\\)"
631 '((1 font-lock-builtin-face) (3 font-lock-warning-face nil t)))
632 )))
633 "Gaudy level highlighting for `icon-mode'.")
634
635 (defvar icon-font-lock-keywords icon-font-lock-keywords-1
636 "Default expressions to highlight in `icon-mode'.")
637
638 ;;;used by hs-minor-mode
639 (defun icon-forward-sexp-function (arg)
640 (if (> arg 0)
641 (re-search-forward "^[ \t]*end")
642 (re-search-backward "^[ \t]procedure")))
643
644 (provide 'icon-mode)
645 ;;; icon.el ends here