Handle Bug#23186
[emacs.git] / lisp / progmodes / icon.el
blobc91f98e32060df3143b32c102c63a3c61bf71bb2
1 ;;; icon.el --- mode for editing Icon code
3 ;; Copyright (C) 1989, 2001-2016 Free Software Foundation, Inc.
5 ;; Author: Chris Smith <csmith@convex.com>
6 ;; Created: 15 Feb 89
7 ;; Keywords: languages
9 ;; This file is part of GNU Emacs.
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 3 of the License, or
14 ;; (at your option) any later version.
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.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;; A major mode for editing the Icon programming language.
28 ;;; Code:
30 (defvar icon-mode-abbrev-table nil
31 "Abbrev table in use in Icon-mode buffers.")
32 (define-abbrev-table 'icon-mode-abbrev-table ())
34 (defvar icon-mode-map ()
35 "Keymap used in Icon mode.")
36 (if icon-mode-map
38 (let ((map (make-sparse-keymap "Icon")))
39 (setq icon-mode-map (make-sparse-keymap))
40 (define-key icon-mode-map "{" 'electric-icon-brace)
41 (define-key icon-mode-map "}" 'electric-icon-brace)
42 (define-key icon-mode-map "\e\C-h" 'mark-icon-function)
43 (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun)
44 (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun)
45 (define-key icon-mode-map "\e\C-q" 'indent-icon-exp)
46 (define-key icon-mode-map "\177" 'backward-delete-char-untabify)
48 (define-key icon-mode-map [menu-bar] (make-sparse-keymap "Icon"))
49 (define-key icon-mode-map [menu-bar icon]
50 (cons "Icon" map))
51 (define-key map [beginning-of-icon-defun] '("Beginning of function" . beginning-of-icon-defun))
52 (define-key map [end-of-icon-defun] '("End of function" . end-of-icon-defun))
53 (define-key map [comment-region] '("Comment Out Region" . comment-region))
54 (define-key map [indent-region] '("Indent Region" . indent-region))
55 (define-key map [indent-line] '("Indent Line" . icon-indent-command))
56 (put 'eval-region 'menu-enable 'mark-active)
57 (put 'comment-region 'menu-enable 'mark-active)
58 (put 'indent-region 'menu-enable 'mark-active)))
60 (defvar icon-mode-syntax-table nil
61 "Syntax table in use in Icon-mode buffers.")
63 (if icon-mode-syntax-table
65 (setq icon-mode-syntax-table (make-syntax-table))
66 (modify-syntax-entry ?\\ "\\" icon-mode-syntax-table)
67 (modify-syntax-entry ?# "<" icon-mode-syntax-table)
68 (modify-syntax-entry ?\n ">" icon-mode-syntax-table)
69 (modify-syntax-entry ?$ "." icon-mode-syntax-table)
70 (modify-syntax-entry ?/ "." icon-mode-syntax-table)
71 (modify-syntax-entry ?* "." 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))
82 (defgroup icon nil
83 "Mode for editing Icon code."
84 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
85 :group 'languages)
87 (defcustom icon-indent-level 4
88 "Indentation of Icon statements with respect to containing block."
89 :type 'integer
90 :group 'icon)
92 (defcustom icon-brace-imaginary-offset 0
93 "Imagined indentation of a Icon open brace that actually follows a statement."
94 :type 'integer
95 :group 'icon)
97 (defcustom icon-brace-offset 0
98 "Extra indentation for braces, compared with other text in same context."
99 :type 'integer
100 :group 'icon)
102 (defcustom icon-continued-statement-offset 4
103 "Extra indent for Icon lines not starting new statements."
104 :type 'integer
105 :group 'icon)
107 (defcustom icon-continued-brace-offset 0
108 "Extra indent for Icon substatements that start with open-braces.
109 This is in addition to `icon-continued-statement-offset'."
110 :type 'integer
111 :group 'icon)
113 (defcustom icon-auto-newline nil
114 "Non-nil means automatically newline before and after braces Icon code.
115 This applies when braces are inserted."
116 :type 'boolean
117 :group 'icon)
119 (defcustom icon-tab-always-indent t
120 "Non-nil means TAB in Icon mode should always reindent the current line.
121 It will then reindent, regardless of where in the line point is
122 when the TAB command is used."
123 :type 'boolean
124 :group 'icon)
126 (defvar icon-imenu-generic-expression
127 '((nil "^[ \t]*procedure[ \t]+\\(\\sw+\\)[ \t]*(" 1))
128 "Imenu expression for Icon mode. See `imenu-generic-expression'.")
132 ;;;###autoload
133 (define-derived-mode icon-mode prog-mode "Icon"
134 "Major mode for editing Icon code.
135 Expression and list commands understand all Icon brackets.
136 Tab indents for Icon code.
137 Paragraphs are separated by blank lines only.
138 Delete converts tabs to spaces as it moves back.
139 \\{icon-mode-map}
140 Variables controlling indentation style:
141 icon-tab-always-indent
142 Non-nil means TAB in Icon mode should always reindent the current line,
143 regardless of where in the line point is when the TAB command is used.
144 icon-auto-newline
145 Non-nil means automatically newline before and after braces
146 inserted in Icon code.
147 icon-indent-level
148 Indentation of Icon statements within surrounding block.
149 The surrounding block's indentation is the indentation
150 of the line on which the open-brace appears.
151 icon-continued-statement-offset
152 Extra indentation given to a substatement, such as the
153 then-clause of an if or body of a while.
154 icon-continued-brace-offset
155 Extra indentation given to a brace that starts a substatement.
156 This is in addition to `icon-continued-statement-offset'.
157 icon-brace-offset
158 Extra indentation for line if it starts with an open brace.
159 icon-brace-imaginary-offset
160 An open brace following other text is treated as if it were
161 this far to the right of the start of its line.
163 Turning on Icon mode calls the value of the variable `icon-mode-hook'
164 with no args, if that value is non-nil."
165 :abbrev-table icon-mode-abbrev-table
166 (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter))
167 (set (make-local-variable 'paragraph-separate) paragraph-start)
168 (set (make-local-variable 'indent-line-function) #'icon-indent-line)
169 (set (make-local-variable 'comment-start) "# ")
170 (set (make-local-variable 'comment-end) "")
171 (set (make-local-variable 'comment-start-skip) "# *")
172 (set (make-local-variable 'comment-indent-function) 'icon-comment-indent)
173 (set (make-local-variable 'indent-line-function) 'icon-indent-line)
174 ;; font-lock support
175 (set (make-local-variable 'font-lock-defaults)
176 '((icon-font-lock-keywords
177 icon-font-lock-keywords-1 icon-font-lock-keywords-2)
178 nil nil ((?_ . "w")) beginning-of-defun
179 ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP.
180 ;;(font-lock-comment-start-regexp . "#")
181 (font-lock-mark-block-function . mark-defun)))
182 ;; imenu support
183 (set (make-local-variable 'imenu-generic-expression)
184 icon-imenu-generic-expression)
185 ;; hideshow support
186 ;; we start from the assertion that `hs-special-modes-alist' is autoloaded.
187 (unless (assq 'icon-mode hs-special-modes-alist)
188 (setq hs-special-modes-alist
189 (cons '(icon-mode "\\<procedure\\>" "\\<end\\>" nil
190 icon-forward-sexp-function)
191 hs-special-modes-alist))))
193 ;; This is used by indent-for-comment to decide how much to
194 ;; indent a comment in Icon code based on its context.
195 (defun icon-comment-indent ()
196 (if (looking-at "^#") 0 comment-column))
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-event)
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)))))
228 (defun icon-indent-command (&optional whole-exp)
229 "Indent current line as Icon code, or in some cases insert a tab character.
230 If `icon-tab-always-indent' is non-nil (the default), always indent current
231 line. Otherwise, indent the current line only if point is at the left margin
232 or in the line's indentation; otherwise insert a tab.
234 A numeric argument, regardless of its value, means indent rigidly all the
235 lines of the expression starting after point so that this line becomes
236 properly indented. The relative indentation among the lines of the
237 expression are preserved."
238 (interactive "P")
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))))
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 ((looking-at "^#")
274 (setq indent 0))
276 (skip-chars-forward " \t")
277 (if (listp indent) (setq indent (car indent)))
278 (cond ((and (looking-at "else\\b")
279 (not (looking-at "else\\s_")))
280 (setq indent (save-excursion
281 (icon-backward-to-start-of-if)
282 (current-indentation))))
283 ((or (= (following-char) ?})
284 (looking-at "end\\b"))
285 (setq indent (- indent icon-indent-level)))
286 ((= (following-char) ?{)
287 (setq indent (+ indent icon-brace-offset))))))
288 (skip-chars-forward " \t")
289 (setq shift-amt (- indent (current-column)))
290 (if (zerop shift-amt)
291 (if (> (- (point-max) pos) (point))
292 (goto-char (- (point-max) pos)))
293 (delete-region beg (point))
294 (indent-to indent)
295 ;; If initial point was within line's indentation,
296 ;; position after the indentation. Else stay at same point in text.
297 (if (> (- (point-max) pos) (point))
298 (goto-char (- (point-max) pos))))
299 shift-amt))
301 (defun calculate-icon-indent (&optional parse-start)
302 "Return appropriate indentation for current line as Icon code.
303 In usual case returns an integer: the column to indent to.
304 Returns nil if line starts inside a string, t if in a comment."
305 (save-excursion
306 (beginning-of-line)
307 (let ((indent-point (point))
308 (case-fold-search nil)
309 state
310 containing-sexp
311 toplevel)
312 (if parse-start
313 (goto-char parse-start)
314 (setq toplevel (beginning-of-icon-defun)))
315 (while (< (point) indent-point)
316 (setq parse-start (point))
317 (setq state (parse-partial-sexp (point) indent-point 0))
318 (setq containing-sexp (car (cdr state))))
319 (cond ((or (nth 3 state) (nth 4 state))
320 ;; return nil or t if should not change this line
321 (nth 4 state))
322 ((and containing-sexp
323 (/= (char-after containing-sexp) ?{))
324 ;; line is expression, not statement:
325 ;; indent to just after the surrounding open.
326 (goto-char (1+ containing-sexp))
327 (current-column))
329 (if toplevel
330 ;; Outside any procedures.
331 (progn (icon-backward-to-noncomment (point-min))
332 (if (icon-is-continuation-line)
333 icon-continued-statement-offset 0))
334 ;; Statement level.
335 (if (null containing-sexp)
336 (progn (beginning-of-icon-defun)
337 (setq containing-sexp (point))))
338 (goto-char indent-point)
339 ;; Is it a continuation or a new statement?
340 ;; Find previous non-comment character.
341 (icon-backward-to-noncomment containing-sexp)
342 ;; Now we get the answer.
343 (if (icon-is-continuation-line)
344 ;; This line is continuation of preceding line's statement;
345 ;; indent icon-continued-statement-offset more than the
346 ;; first line of the statement.
347 (progn
348 (icon-backward-to-start-of-continued-exp containing-sexp)
349 (+ icon-continued-statement-offset (current-column)
350 (if (save-excursion (goto-char indent-point)
351 (skip-chars-forward " \t")
352 (eq (following-char) ?{))
353 icon-continued-brace-offset 0)))
354 ;; This line starts a new statement.
355 ;; Position following last unclosed open.
356 (goto-char containing-sexp)
357 ;; Is line first statement after an open-brace?
359 ;; If no, find that first statement and indent like it.
360 (save-excursion
361 (if (looking-at "procedure\\s ")
362 (forward-sexp 3)
363 (forward-char 1))
364 (while (progn (skip-chars-forward " \t\n")
365 (looking-at "#"))
366 ;; Skip over comments following openbrace.
367 (forward-line 1))
368 ;; The first following code counts
369 ;; if it is before the line we want to indent.
370 (and (< (point) indent-point)
371 (current-column)))
372 ;; If no previous statement,
373 ;; indent it relative to line brace is on.
374 ;; For open brace in column zero, don't let statement
375 ;; start there too. If icon-indent-level is zero,
376 ;; use icon-brace-offset + icon-continued-statement-offset
377 ;; instead.
378 ;; For open-braces not the first thing in a line,
379 ;; add in icon-brace-imaginary-offset.
380 (+ (if (and (bolp) (zerop icon-indent-level))
381 (+ icon-brace-offset
382 icon-continued-statement-offset)
383 icon-indent-level)
384 ;; Move back over whitespace before the openbrace.
385 ;; If openbrace is not first nonwhite thing on the line,
386 ;; add the icon-brace-imaginary-offset.
387 (progn (skip-chars-backward " \t")
388 (if (bolp) 0 icon-brace-imaginary-offset))
389 ;; Get initial indentation of the line we are on.
390 (current-indentation))))))))))
392 ;; List of words to check for as the last thing on a line.
393 ;; If cdr is t, next line is a continuation of the same statement,
394 ;; if cdr is nil, next line starts a new (possibly indented) statement.
396 (defconst icon-resword-alist
397 '(("by" . t) ("case" . t) ("create") ("do") ("dynamic" . t) ("else")
398 ("every" . t) ("if" . t) ("global" . t) ("initial" . t)
399 ("link" . t) ("local" . t) ("of") ("record" . t) ("repeat" . t)
400 ("static" . t) ("then") ("to" . t) ("until" . t) ("while" . t)))
402 (defun icon-is-continuation-line ()
403 (let* ((ch (preceding-char))
404 (ch-syntax (char-syntax ch)))
405 (if (eq ch-syntax ?w)
406 (assoc (buffer-substring
407 (progn (forward-word-strictly -1) (point))
408 (progn (forward-word-strictly 1) (point)))
409 icon-resword-alist)
410 (not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\# ?\, ?\. ?\n))))))
412 (defun icon-backward-to-noncomment (lim)
413 (let (opoint stop)
414 (while (not stop)
415 (skip-chars-backward " \t\n\f" lim)
416 (setq opoint (point))
417 (beginning-of-line)
418 (if (and (nth 5 (parse-partial-sexp (point) opoint))
419 (< lim (point)))
420 (search-backward "#")
421 (setq stop t)))))
423 (defun icon-backward-to-start-of-continued-exp (lim)
424 (if (memq (preceding-char) '(?\) ?\]))
425 (forward-sexp -1))
426 (beginning-of-line)
427 (skip-chars-forward " \t")
428 (cond
429 ((<= (point) lim) (goto-char (1+ lim)))
430 ((not (icon-is-continued-line)) 0)
431 ((and (eq (char-syntax (following-char)) ?w)
432 (cdr
433 (assoc (buffer-substring (point)
434 (save-excursion (forward-word-strictly 1)
435 (point)))
436 icon-resword-alist))) 0)
437 (t (end-of-line 0) (icon-backward-to-start-of-continued-exp lim))))
439 (defun icon-is-continued-line ()
440 (save-excursion
441 (end-of-line 0)
442 (icon-is-continuation-line)))
444 (defun icon-backward-to-start-of-if (&optional limit)
445 "Move to the start of the last \"unbalanced\" if."
446 (or limit (setq limit (save-excursion (beginning-of-icon-defun) (point))))
447 (let ((if-level 1)
448 (case-fold-search nil))
449 (while (not (zerop if-level))
450 (backward-sexp 1)
451 (cond ((looking-at "else\\b")
452 (setq if-level (1+ if-level)))
453 ((looking-at "if\\b")
454 (setq if-level (1- if-level)))
455 ((< (point) limit)
456 (setq if-level 0)
457 (goto-char limit))))))
459 (defun mark-icon-function ()
460 "Put mark at end of Icon function, point at beginning."
461 (interactive)
462 (push-mark (point))
463 (end-of-icon-defun)
464 (push-mark (point))
465 (beginning-of-line 0)
466 (beginning-of-icon-defun))
468 (defun beginning-of-icon-defun ()
469 "Go to the start of the enclosing procedure; return t if at top level."
470 (interactive)
471 (if (re-search-backward "^procedure\\s \\|^end[ \t\n]" (point-min) 'move)
472 (looking-at "e")
475 (defun end-of-icon-defun ()
476 (interactive)
477 (if (not (bobp)) (forward-char -1))
478 (re-search-forward "\\(\\s \\|^\\)end\\(\\s \\|$\\)" (point-max) 'move)
479 (forward-word-strictly -1)
480 (forward-line 1))
482 (defun indent-icon-exp ()
483 "Indent each line of the Icon grouping following point."
484 (interactive)
485 (let ((indent-stack (list nil))
486 (contain-stack (list (point)))
487 (case-fold-search nil)
488 outer-loop-done inner-loop-done state ostate
489 this-indent last-depth
490 at-else at-brace
491 (opoint (point))
492 (next-depth 0))
493 (save-excursion
494 (forward-sexp 1))
495 (save-excursion
496 (setq outer-loop-done nil)
497 (while (and (not (eobp)) (not outer-loop-done))
498 (setq last-depth next-depth)
499 ;; Compute how depth changes over this line
500 ;; plus enough other lines to get to one that
501 ;; does not end inside a comment or string.
502 ;; Meanwhile, do appropriate indentation on comment lines.
503 (setq inner-loop-done nil)
504 (while (and (not inner-loop-done)
505 (not (and (eobp) (setq outer-loop-done t))))
506 (setq ostate state)
507 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point))
508 nil nil state))
509 (setq next-depth (car state))
510 (if (or (nth 4 ostate))
511 (icon-indent-line))
512 (if (or (nth 3 state))
513 (forward-line 1)
514 (setq inner-loop-done t)))
515 (if (<= next-depth 0)
516 (setq outer-loop-done t))
517 (if outer-loop-done
519 (while (> last-depth next-depth)
520 (setq indent-stack (cdr indent-stack)
521 contain-stack (cdr contain-stack)
522 last-depth (1- last-depth)))
523 (while (< last-depth next-depth)
524 (setq indent-stack (cons nil indent-stack)
525 contain-stack (cons nil contain-stack)
526 last-depth (1+ last-depth)))
527 (if (null (car contain-stack))
528 (setcar contain-stack (or (car (cdr state))
529 (save-excursion (forward-sexp -1)
530 (point)))))
531 (forward-line 1)
532 (skip-chars-forward " \t")
533 (if (eolp)
535 (if (and (car indent-stack)
536 (>= (car indent-stack) 0))
537 ;; Line is on an existing nesting level.
538 ;; Lines inside parens are handled specially.
539 (if (/= (char-after (car contain-stack)) ?{)
540 (setq this-indent (car indent-stack))
541 ;; Line is at statement level.
542 ;; Is it a new statement? Is it an else?
543 ;; Find last non-comment character before this line
544 (save-excursion
545 (setq at-else (looking-at "else\\W"))
546 (setq at-brace (= (following-char) ?{))
547 (icon-backward-to-noncomment opoint)
548 (if (icon-is-continuation-line)
549 ;; Preceding line did not end in comma or semi;
550 ;; indent this line icon-continued-statement-offset
551 ;; more than previous.
552 (progn
553 (icon-backward-to-start-of-continued-exp (car contain-stack))
554 (setq this-indent
555 (+ icon-continued-statement-offset (current-column)
556 (if at-brace icon-continued-brace-offset 0))))
557 ;; Preceding line ended in comma or semi;
558 ;; use the standard indent for this level.
559 (if at-else
560 (progn (icon-backward-to-start-of-if opoint)
561 (setq this-indent (current-indentation)))
562 (setq this-indent (car indent-stack))))))
563 ;; Just started a new nesting level.
564 ;; Compute the standard indent for this level.
565 (let ((val (calculate-icon-indent
566 (if (car indent-stack)
567 (- (car indent-stack))))))
568 (setcar indent-stack
569 (setq this-indent val))))
570 ;; Adjust line indentation according to its contents
571 (if (or (= (following-char) ?})
572 (looking-at "end\\b"))
573 (setq this-indent (- this-indent icon-indent-level)))
574 (if (= (following-char) ?{)
575 (setq this-indent (+ this-indent icon-brace-offset)))
576 ;; Put chosen indentation into effect.
577 (or (= (current-column) this-indent)
578 (progn
579 (delete-region (point) (progn (beginning-of-line) (point)))
580 (indent-to this-indent)))
581 ;; Indent any comment following the text.
582 (or (looking-at comment-start-skip)
583 (if (re-search-forward comment-start-skip (line-end-position) t)
584 (progn (indent-for-comment) (beginning-of-line))))))))))
586 (defconst icon-font-lock-keywords-1
587 (eval-when-compile
588 (list
589 ;; Fontify procedure name definitions.
590 '("^[ \t]*\\(procedure\\)\\>[ \t]*\\(\\sw+\\)?"
591 (1 font-lock-builtin-face) (2 font-lock-function-name-face nil t))))
592 "Subdued level highlighting for Icon mode.")
594 (defconst icon-font-lock-keywords-2
595 (append
596 icon-font-lock-keywords-1
597 (eval-when-compile
598 (list
599 ;; Fontify all type specifiers.
600 (cons
601 (regexp-opt '("null" "string" "co-expression" "table" "integer"
602 "cset" "set" "real" "file" "list") 'words)
603 'font-lock-type-face)
604 ;; Fontify all keywords.
606 (cons
607 (regexp-opt
608 '("break" "do" "next" "repeat" "to" "by" "else" "if" "not" "return"
609 "until" "case" "of" "while" "create" "every" "suspend" "default"
610 "fail" "record" "then") 'words)
611 'font-lock-keyword-face)
612 ;; "end" "initial"
613 (cons (regexp-opt '("end" "initial") 'words)
614 'font-lock-builtin-face)
615 ;; Fontify all system variables.
616 (cons
617 (regexp-opt
618 '("&allocated" "&ascii" "&clock" "&col" "&collections" "&column"
619 "&control" "&cset" "&current" "&date" "&dateline" "&digits" "&dump"
620 "&e" "&error" "&errornumber" "&errortext" "&errorvalue" "&errout"
621 "&eventcode" "&eventsource" "&eventvalue" "&fail" "&features"
622 "&file" "&host" "&input" "&interval" "&lcase" "&ldrag" "&letters"
623 "&level" "&line" "&lpress" "&lrelease" "&main" "&mdrag" "&meta"
624 "&mpress" "&mrelease" "&null" "&output" "&phi" "&pi" "&pos"
625 "&progname" "&random" "&rdrag" "&regions" "&resize" "&row"
626 "&rpress" "&rrelease" "&shift" "&source" "&storage" "&subject"
627 "&time" "&trace" "&ucase" "&version" "&window" "&x" "&y") t)
628 'font-lock-constant-face)
629 (cons ;; global local static declarations and link files
630 (concat
631 "^[ \t]*"
632 (regexp-opt '("global" "link" "local" "static") t)
633 "\\(\\sw+\\>\\)*")
634 '((1 font-lock-builtin-face)
635 (font-lock-match-c-style-declaration-item-and-skip-to-next
636 (goto-char (or (match-beginning 2) (match-end 1))) nil
637 (1 (if (match-beginning 2)
638 font-lock-function-name-face
639 font-lock-variable-name-face)))))
641 (cons ;; $define $elif $ifdef $ifndef $undef
642 (concat "^"
643 (regexp-opt'("$define" "$elif" "$ifdef" "$ifndef" "$undef") t)
644 "\\>[ \t]*\\([^ \t\n]+\\)?")
645 '((1 font-lock-builtin-face)
646 (4 font-lock-variable-name-face nil t)))
647 (cons ;; $dump $endif $else $include
648 (concat
649 "^" (regexp-opt'("$dump" "$endif" "$else" "$include") t) "\\>" )
650 'font-lock-builtin-face)
651 (cons ;; $warning $error
652 (concat "^" (regexp-opt '("$warning" "$error") t)
653 "\\>[ \t]*\\(.+\\)?")
654 '((1 font-lock-builtin-face) (3 font-lock-warning-face nil t))))))
655 "Gaudy level highlighting for Icon mode.")
657 (defvar icon-font-lock-keywords icon-font-lock-keywords-1
658 "Default expressions to highlight in `icon-mode'.")
660 ;;;used by hs-minor-mode
661 (defun icon-forward-sexp-function (arg)
662 (if (< arg 0)
663 (beginning-of-icon-defun)
664 (end-of-icon-defun)
665 (forward-char -1)))
667 (provide 'icon)
669 ;;; icon.el ends here