1 ;;; simula.el --- SIMULA 87 code editing commands for Emacs
3 ;; Copyright (C) 1992, 1994, 1996, 2001-2013 Free Software Foundation,
6 ;; Author: Hans Henrik Eriksen <hhe@ifi.uio.no>
7 ;; Maintainer: simula-mode@ifi.uio.no
8 ;; (above email addresses invalid as of April 2008)
10 ;; Keywords: languages
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29 ;; A major mode for editing the Simula language. It knows about Simula
30 ;; syntax and standard indentation commands. It also provides convenient
31 ;; abbrevs for Simula keywords.
33 ;; Hans Henrik Eriksen (the author) may be reached at:
34 ;; Institutt for informatikk,
35 ;; Universitetet i Oslo
41 "Major mode for editing Simula code."
42 :link
'(custom-group-link :tag
"Font Lock Faces group" font-lock-faces
)
46 (defconst simula-tab-always-indent-default nil
47 "Non-nil means TAB in SIMULA mode should always reindent the current line.
48 Otherwise TAB indents only when point is within
49 the run of whitespace at the beginning of the line.")
51 (defcustom simula-tab-always-indent simula-tab-always-indent-default
52 "Non-nil means TAB in SIMULA mode should always reindent the current line.
53 Otherwise TAB indents only when point is within
54 the run of whitespace at the beginning of the line."
58 (defconst simula-indent-level-default
3
59 "Indentation of SIMULA statements with respect to containing block.")
61 (defcustom simula-indent-level simula-indent-level-default
62 "Indentation of SIMULA statements with respect to containing block."
67 (defconst simula-substatement-offset-default
3
68 "Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.")
70 (defcustom simula-substatement-offset simula-substatement-offset-default
71 "Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE."
75 (defconst simula-continued-statement-offset-default
3
76 "Extra indentation for lines not starting a statement or substatement.
77 If value is a list, each line in a multipleline continued statement
78 will have the car of the list extra indentation with respect to
79 the previous line of the statement.")
81 (defcustom simula-continued-statement-offset
82 simula-continued-statement-offset-default
83 "Extra indentation for lines not starting a statement or substatement.
84 If value is a list, each line in a multipleline continued statement
85 will have the car of the list extra indentation with respect to
86 the previous line of the statement."
90 (defconst simula-label-offset-default -
4711
91 "Offset of SIMULA label lines relative to usual indentation.")
93 (defcustom simula-label-offset simula-label-offset-default
94 "Offset of SIMULA label lines relative to usual indentation."
98 (defconst simula-if-indent-default
'(0 .
0)
99 "Extra indentation of THEN and ELSE with respect to the starting IF.
100 Value is a cons cell, the car is extra THEN indentation and the cdr
101 extra ELSE indentation. IF after ELSE is indented as the starting IF.")
103 (defcustom simula-if-indent simula-if-indent-default
104 "Extra indentation of THEN and ELSE with respect to the starting IF.
105 Value is a cons cell, the car is extra THEN indentation and the cdr
106 extra ELSE indentation. IF after ELSE is indented as the starting IF."
107 :type
'(cons integer integer
)
110 (defconst simula-inspect-indent-default
'(0 .
0)
111 "Extra indentation of WHEN and OTHERWISE with respect to the INSPECT.
112 Value is a cons cell, the car is extra WHEN indentation
113 and the cdr extra OTHERWISE indentation.")
115 (defcustom simula-inspect-indent simula-inspect-indent-default
116 "Extra indentation of WHEN and OTHERWISE with respect to the INSPECT.
117 Value is a cons cell, the car is extra WHEN indentation
118 and the cdr extra OTHERWISE indentation."
119 :type
'(cons integer integer
)
122 (defconst simula-electric-indent-default nil
123 "Non-nil means `simula-indent-line' function may reindent previous line.")
125 (defcustom simula-electric-indent simula-electric-indent-default
126 "Non-nil means `simula-indent-line' function may reindent previous line."
130 (defconst simula-abbrev-keyword-default
'upcase
131 "Specify how to convert case for SIMULA keywords.
132 Value is one of the symbols `upcase', `downcase', `capitalize',
133 \(as in) `abbrev-table' or nil if they should not be changed.")
135 (defcustom simula-abbrev-keyword simula-abbrev-keyword-default
136 "Specify how to convert case for SIMULA keywords.
137 Value is one of the symbols `upcase', `downcase', `capitalize',
138 \(as in) `abbrev-table' or nil if they should not be changed."
139 :type
'(choice (const upcase
) (const downcase
) (const capitalize
)(const nil
))
142 (defconst simula-abbrev-stdproc-default
'abbrev-table
143 "Specify how to convert case for standard SIMULA procedure and class names.
144 Value is one of the symbols `upcase', `downcase', `capitalize',
145 \(as in) `abbrev-table', or nil if they should not be changed.")
147 (defcustom simula-abbrev-stdproc simula-abbrev-stdproc-default
148 "Specify how to convert case for standard SIMULA procedure and class names.
149 Value is one of the symbols `upcase', `downcase', `capitalize',
150 \(as in) `abbrev-table', or nil if they should not be changed."
151 :type
'(choice (const upcase
) (const downcase
) (const capitalize
)
152 (const abbrev-table
) (const nil
))
155 (defcustom simula-abbrev-file nil
156 "File with extra abbrev definitions for use in SIMULA mode.
157 These are used together with the standard abbrev definitions for SIMULA.
158 Please note that the standard definitions are required
159 for SIMULA mode to function correctly."
160 :type
'(choice file
(const nil
))
163 (defvar simula-mode-syntax-table nil
164 "Syntax table in SIMULA mode buffers.")
166 (defconst simula-syntax-propertize-function
167 (syntax-propertize-rules
168 ;; `comment' directive.
169 ("\\<\\(c\\)omment\\>" (1 "<"))
171 ((concat "\\<end\\>\\([^;\n]\\).*?\\(\n\\|\\(.\\)\\(;\\|"
172 (regexp-opt '("end" "else" "when" "otherwise"))
176 ;; non-quoted single-quote char.
177 ("'\\('\\)'" (1 "."))))
179 ;; Regexps written with help from Alf-Ivar Holm <alfh@ifi.uio.no>.
180 (defconst simula-font-lock-keywords-1
182 ;; Compiler directives.
183 ("^%\\([^ \t\n].*\\)" 1 font-lock-constant-face t
)
185 ;; Class and procedure names.
186 ("\\<\\(class\\|procedure\\)\\>[ \t]*\\(\\sw+\\)?"
187 (1 font-lock-keyword-face
) (2 font-lock-function-name-face nil t
)))
188 "Subdued level highlighting for Simula mode.")
190 (defconst simula-font-lock-keywords-2
191 (append simula-font-lock-keywords-1
195 '("\\<\\(false\\|none\\|notext\\|true\\)\\>" . font-lock-constant-face
)
199 '("activate" "after" "and" "at" "before" "begin" "delay" "do"
200 "else" "end" "eq" "eqv" "external" "for" "ge" "go" "goto" "gt"
201 "hidden" "if" "imp" "in" "inner" "inspect" "is" "label" "le"
202 "lt" "ne" "new" "not" "or" "otherwise" "prior" "protected"
203 "qua" "reactivate" "step" "switch" "then" "this" "to" "until"
204 "virtual" "when" "while") 'words
)
208 '("array" "boolean" "character" "integer"
209 "long" "name" "real" "short" "text" "value" "ref") 'words
)
210 'font-lock-type-face
)))
211 "Medium level highlighting for Simula mode.")
213 (defconst simula-font-lock-keywords-3
214 (append simula-font-lock-keywords-2
217 ;; Super-class names and super-slow.
218 '("\\<\\(\\sw+\\)[ \t]+class\\>" 1 font-lock-function-name-face
)
220 ;; Types and their declarations.
221 (list (concat "\\<\\(array\\|boolean\\|character\\|integer\\|"
222 "long\\|name\\|real\\|short\\|text\\|value\\)\\>"
223 "\\([ \t]+\\sw+\\>\\)*")
224 '(font-lock-match-c-style-declaration-item-and-skip-to-next
225 ;; Start with point after all type specifiers.
226 (goto-char (or (match-beginning 2) (match-end 1)))
227 ;; Finish with point after first type specifier.
228 (goto-char (match-end 1))
229 ;; Fontify as a variable name.
230 (1 font-lock-variable-name-face
)))
232 ;; Object references and their declarations.
233 '("\\<\\(ref\\)\\>[ \t]*\\((\\(\\sw+\\))\\)?"
234 (3 font-lock-function-name-face nil t
)
235 (font-lock-match-c-style-declaration-item-and-skip-to-next nil nil
236 (1 font-lock-variable-name-face
)))
238 "Gaudy level highlighting for Simula mode.")
240 (defvar simula-font-lock-keywords simula-font-lock-keywords-1
241 "Default expressions to highlight in Simula mode.")
243 ; The following function is taken from cc-mode.el,
244 ; it determines the flavor of the Emacs running
246 (defvar simula-mode-menu
247 '(["Report Bug" simula-submit-bug-report t
]
248 ["Indent Line" simula-indent-line t
]
249 ["Backward Statement" simula-previous-statement t
]
250 ["Forward Statement" simula-next-statement t
]
251 ["Backward Up Level" simula-backward-up-level t
]
252 ["Forward Down Statement" simula-forward-down-level t
])
253 "Lucid Emacs menu for SIMULA mode.")
255 (if simula-mode-syntax-table
257 (setq simula-mode-syntax-table
(copy-syntax-table (standard-syntax-table)))
258 (modify-syntax-entry ?
! "<" simula-mode-syntax-table
)
259 (modify-syntax-entry ?$
"." simula-mode-syntax-table
)
260 (modify-syntax-entry ?%
"< b" simula-mode-syntax-table
)
261 (modify-syntax-entry ?
\n "> b" simula-mode-syntax-table
)
262 (modify-syntax-entry ?
' "\"" simula-mode-syntax-table
)
263 (modify-syntax-entry ?\
( "()" simula-mode-syntax-table
)
264 (modify-syntax-entry ?\
) ")(" simula-mode-syntax-table
)
265 (modify-syntax-entry ?\
; ">" simula-mode-syntax-table)
266 (modify-syntax-entry ?\
[ "." simula-mode-syntax-table
)
267 (modify-syntax-entry ?
\\ "." simula-mode-syntax-table
)
268 (modify-syntax-entry ?\
] "." simula-mode-syntax-table
)
269 (modify-syntax-entry ?_
"_" simula-mode-syntax-table
)
270 (modify-syntax-entry ?\|
"." simula-mode-syntax-table
)
271 (modify-syntax-entry ?\
{ "." simula-mode-syntax-table
)
272 (modify-syntax-entry ?\
} "." simula-mode-syntax-table
))
274 (defvar simula-mode-map
275 (let ((map (make-sparse-keymap)))
276 (define-key map
"\C-c\C-u" 'simula-backward-up-level
)
277 (define-key map
"\C-c\C-p" 'simula-previous-statement
)
278 (define-key map
"\C-c\C-d" 'simula-forward-down-level
)
279 (define-key map
"\C-c\C-n" 'simula-next-statement
)
280 ;; (define-key map "\C-c\C-g" 'simula-goto-definition)
281 ;; (define-key map "\C-c\C-h" 'simula-standard-help)
282 (define-key map
"\177" 'backward-delete-char-untabify
)
283 (define-key map
":" 'simula-electric-label
)
284 (define-key map
"\e\C-q" 'simula-indent-exp
)
285 (define-key map
"\t" 'simula-indent-command
)
286 ;; Emacs 19 defines menus in the mode map
287 (define-key map
[menu-bar simula
]
288 (cons "SIMULA" (make-sparse-keymap "SIMULA")))
289 (define-key map
[menu-bar simula bug-report
]
290 '("Submit Bug Report" . simula-submit-bug-report
))
291 (define-key map
[menu-bar simula separator-indent
]
293 (define-key map
[menu-bar simula indent-exp
]
294 '("Indent Expression" . simula-indent-exp
))
295 (define-key map
[menu-bar simula indent-line
]
296 '("Indent Line" . simula-indent-command
))
297 (define-key map
[menu-bar simula separator-navigate
]
299 (define-key map
[menu-bar simula backward-stmt
]
300 '("Previous Statement" . simula-previous-statement
))
301 (define-key map
[menu-bar simula forward-stmt
]
302 '("Next Statement" . simula-next-statement
))
303 (define-key map
[menu-bar simula backward-up
]
304 '("Backward Up Level" . simula-backward-up-level
))
305 (define-key map
[menu-bar simula forward-down
]
306 '("Forward Down Statement" . simula-forward-down-level
))
308 (put 'simula-next-statement
'menu-enable
'(not (eobp)))
309 (put 'simula-previous-statement
'menu-enable
'(not (bobp)))
310 (put 'simula-forward-down-level
'menu-enable
'(not (eobp)))
311 (put 'simula-backward-up-level
'menu-enable
'(not (bobp)))
312 (put 'simula-indent-command
'menu-enable
'(not buffer-read-only
))
313 (put 'simula-indent-exp
'menu-enable
'(not buffer-read-only
))
315 ;; RMS: mouse-3 should not select this menu. mouse-3's global
316 ;; definition is useful in SIMULA mode and we should not interfere
317 ;; with that. The menu is mainly for beginners, and for them,
318 ;; the menubar requires less memory than a special click.
319 ;; in Lucid Emacs, we want the menu to popup when the 3rd button is
320 ;; hit. In 19.10 and beyond this is done automatically if we put
321 ;; the menu on mode-popup-menu variable, see c-common-init [cc-mode.el]
322 ;;(if (not (boundp 'mode-popup-menu))
323 ;; (define-key simula-mode-map 'button3 'simula-popup-menu))
325 "Keymap used in `simula-mode'.")
328 (defun simula-popup-menu (_e)
329 "Pops up the SIMULA menu."
331 (popup-menu (cons (concat mode-name
" Mode Commands") simula-mode-menu
)))
334 (define-derived-mode simula-mode prog-mode
"Simula"
335 "Major mode for editing SIMULA code.
337 Variables controlling indentation style:
338 `simula-tab-always-indent'
339 Non-nil means TAB in SIMULA mode should always reindent the current line,
340 regardless of where in the line point is when the TAB command is used.
341 `simula-indent-level'
342 Indentation of SIMULA statements with respect to containing block.
343 `simula-substatement-offset'
344 Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.
345 `simula-continued-statement-offset' 3
346 Extra indentation for lines not starting a statement or substatement,
347 e.g. a nested FOR-loop. If value is a list, each line in a multiple-
348 line continued statement will have the car of the list extra indentation
349 with respect to the previous line of the statement.
350 `simula-label-offset' -4711
351 Offset of SIMULA label lines relative to usual indentation.
352 `simula-if-indent' '(0 . 0)
353 Extra indentation of THEN and ELSE with respect to the starting IF.
354 Value is a cons cell, the car is extra THEN indentation and the cdr
355 extra ELSE indentation. IF after ELSE is indented as the starting IF.
356 `simula-inspect-indent' '(0 . 0)
357 Extra indentation of WHEN and OTHERWISE with respect to the
358 corresponding INSPECT. Value is a cons cell, the car is
359 extra WHEN indentation and the cdr extra OTHERWISE indentation.
360 `simula-electric-indent' nil
361 If this variable is non-nil, `simula-indent-line'
362 will check the previous line to see if it has to be reindented.
363 `simula-abbrev-keyword' 'upcase
364 Determine how SIMULA keywords will be expanded. Value is one of
365 the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table',
366 or nil if they should not be changed.
367 `simula-abbrev-stdproc' 'abbrev-table
368 Determine how standard SIMULA procedure and class names will be
369 expanded. Value is one of the symbols `upcase', `downcase', `capitalize',
370 (as in) `abbrev-table', or nil if they should not be changed.
372 Turning on SIMULA mode calls the value of the variable simula-mode-hook
373 with no arguments, if that value is non-nil."
374 (set (make-local-variable 'comment-column
) 40)
375 ;; (set (make-local-variable 'end-comment-column) 75)
376 (set (make-local-variable 'paragraph-start
) "[ \t]*$\\|\\f")
377 (set (make-local-variable 'paragraph-separate
) paragraph-start
)
378 (set (make-local-variable 'indent-line-function
) 'simula-indent-line
)
379 (set (make-local-variable 'comment-start
) "! ")
380 (set (make-local-variable 'comment-end
) " ;")
381 (set (make-local-variable 'comment-start-skip
) "!+ *")
382 (set (make-local-variable 'parse-sexp-ignore-comments
) nil
)
383 (set (make-local-variable 'comment-multi-line
) t
)
384 (set (make-local-variable 'font-lock-defaults
)
385 '((simula-font-lock-keywords simula-font-lock-keywords-1
386 simula-font-lock-keywords-2 simula-font-lock-keywords-3
)
388 (set (make-local-variable 'syntax-propertize-function
)
389 simula-syntax-propertize-function
)
392 (defun simula-indent-exp ()
393 "Indent SIMULA expression following point."
396 (simula-electric-indent nil
)
398 (simula-skip-comment-forward)
403 (simula-next-statement 1)
404 (setq end
(point-marker))
405 (simula-previous-statement 1)
407 (while (< (point) end
)
408 (if (not (looking-at "[ \t]*$"))
409 (simula-indent-line))
411 (and end
(set-marker end nil
))))))
414 (defun simula-indent-line ()
415 "Indent this line as SIMULA code.
416 If `simula-electric-indent' is non-nil, indent previous line if necessary."
417 (let ((origin (- (point-max) (point)))
418 (indent (simula-calculate-indent))
419 (case-fold-search t
))
421 (if simula-electric-indent
424 ;; manually expand abbrev on last line, if any
428 ;; now maybe we should reindent that line
430 (skip-chars-forward " \t\f")
433 "\\(end\\|if\\|then\\|else\\|when\\|otherwise\\)\\>")
434 (not (simula-context)))
436 (let ((post-indent (simula-calculate-indent)))
437 (if (eq (current-indentation) post-indent
)
439 (delete-horizontal-space)
440 (indent-to post-indent
))))))
441 (goto-char (- (point-max) origin
))
442 (if (eq (current-indentation) indent
)
443 (back-to-indentation)
444 (delete-horizontal-space)
445 (indent-to indent
)))))
448 (defun simula-indent-command (&optional whole-exp
)
449 "Indent current line as SIMULA code, or insert TAB character.
450 If `simula-tab-always-indent' is non-nil, always indent current line.
451 Otherwise, indent only if point is before any non-whitespace
452 character on the line.
454 A numeric argument, regardless of its value, means indent rigidly
455 all the lines of the SIMULA statement after point so that this line
456 becomes properly indented.
457 The relative indentation among the lines of the statement are preserved."
459 (let ((case-fold-search t
))
460 (if (or whole-exp simula-tab-always-indent
462 (skip-chars-backward " \t\f")
464 ;; reindent current line
465 (let ((indent (save-excursion
467 (simula-calculate-indent)))
468 (current (current-indentation))
469 (origin (- (point-max) (point)))
471 (skip-chars-backward " \t\f")
475 (if (eq current indent
)
477 (skip-chars-backward " \t\f")
479 (back-to-indentation))
481 (delete-horizontal-space)
484 (goto-char (- (point-max) origin
))))
485 (setq origin
(point))
488 (beginning-of-line 2)
491 (simula-next-statement 1)
493 (if (and (> end beg
) (not (eq indent current
)))
494 (indent-code-rigidly beg end
(- indent current
) "%")))))
498 (defun simula-context ()
499 "Return value according to syntactic SIMULA context of point.
500 0 point inside COMMENT comment
501 1 point on SIMULA-compiler directive line
502 2 point inside END comment
503 3 point inside string
504 4 point inside character constant
506 ;; first, find out if this is a compiler directive line
509 (eq (following-char) ?%
))
513 ;; The current line is NOT a compiler directive line.
514 ;; Now, the strategy is to search backward to find a semicolon
515 ;; that is NOT inside a string. The point after semicolon MUST be
516 ;; outside a comment, since semicolons are comment-ending and
517 ;; comments are non-recursive. We take advantage of the fact
518 ;; that strings MUST end on the same line as they started, so
519 ;; that we can easily decide whether we are inside a string or not.
520 (let (return-value (origin (point)))
521 (skip-chars-backward "^;" (point-min))
522 ;; found semicolon or beginning of buffer
523 (let (loopvalue (saved-point origin
))
524 (while (and (not (bobp))
527 ;; compiler directive line? If so, cont searching..
528 (eq (following-char) ?%
))
530 (while (< (point) saved-point
)
531 (skip-chars-forward "^;\"'")
534 ((eq (preceding-char) ?\
;)
535 (setq saved-point
(point)))
536 ((eq (preceding-char) ?
\")
537 (skip-chars-forward "^\";")
538 (if (eq (following-char) ?\
;)
539 (setq saved-point
(point) loopvalue t
)
542 (if (eq (following-char) ?
')
544 (skip-chars-forward "^';")
545 (if (eq (following-char) ?\
;)
546 (setq saved-point
(point) loopvalue t
)
550 (skip-chars-backward "^;")
551 (setq saved-point
(point) loopvalue nil
)))
552 ;; Now we are CERTAIN that we are outside comments and strings.
553 ;; The job now is to search forward again towards the origin
554 ;; skipping directives, comments and strings correctly,
555 ;; so that we know what context we are in when we find the origin.
559 "\\<end\\>\\|!\\|\"\\|'\\|^%\\|\\<comment\\>" origin
'move
))
561 ((memq (preceding-char) '(?d ?D
))
562 (setq return-value
2)
563 (while (and (re-search-forward
564 ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>\\|^%"
566 ;; found another END?
567 (or (memq (preceding-char) '(?d ?D
))
568 ;; if directive, skip line
569 (and (eq (preceding-char) ?%
)
570 (beginning-of-line 2))
571 ;; found other keyword, out of END comment
572 (setq return-value nil
))))
573 (if (and (eq (char-syntax (preceding-char)) ?w
)
574 (eq (char-syntax (following-char)) ?w
))
577 (if (looking-at "end\\>\\|else\\>\\|otherwise\\>\\|when\\>")
578 (setq return-value nil
)))))
579 ((memq (preceding-char) '(?
! ?t ?T
))
581 (setq return-value
0)
582 (skip-chars-forward "^%;" origin
)
583 (while (and return-value
(< (point) origin
))
584 (if (eq (following-char) ?\
;)
585 (setq return-value nil
)
587 (beginning-of-line 2) ; skip directive inside comment
588 (forward-char 1)) ; or single '%'
589 (skip-chars-forward "^%;" origin
))))
590 ((eq (preceding-char) ?
\")
591 (if (not (search-forward "\"" origin
'move
))
592 (setq return-value
3)))
593 ((eq (preceding-char) ?
\')
594 (if (or (eq (point) origin
) (eobp))
595 (setq return-value
4)
597 (if (not (search-forward "'" origin
'move
))
598 (setq return-value
4))))
599 ;; compiler directive line - skip
600 (t (beginning-of-line 2))))
605 (defun simula-electric-label ()
606 "If this is a label that starts the line, reindent the line."
610 (let ((origin (- (point-max) (point)))
612 ;; don't mix a label with an assignment operator := :-
613 ;; therefore take a peek at next typed character...
614 (next-char (read-event)))
616 (setq unread-command-events
(append unread-command-events
618 ;; Problem: find out if character just read is a command char
619 ;; that would insert something after ':' making it a label.
620 ;; At least \n, \r (and maybe \t) falls into this category.
621 ;; This is a real crock, it depends on traditional keymap
622 ;; bindings, that is, printing characters doing self-insert,
623 ;; and no other command sequence inserting '-' or '='.
624 ;; simula-electric-label can be easily fooled...
625 (if (and (not (memq next-char
'(?
= ?-
)))
626 (or (memq next-char
'(?
\n ?
\r))
627 (and (eq next-char ?
\t)
628 simula-tab-always-indent
)
629 (not (memq (following-char) '(?
= ?-
))))
630 (not (simula-context))
634 (skip-chars-backward " \t\f")
635 (skip-chars-backward "a-zA-Z0-9_")
636 (if (looking-at "virtual\\>")
638 (skip-chars-backward " \t\f")
640 (let ((amount (simula-calculate-indent)))
641 (delete-horizontal-space)
643 (goto-char (- (point-max) origin
)))))
646 (defun simula-backward-up-level (count)
647 "Move backward up COUNT block levels.
648 If COUNT is negative, move forward up block level instead."
650 (let ((origin (point))
651 (case-fold-search t
))
655 (re-search-backward "\\<begin\\>\\|\\<end\\>")
656 (if (not (simula-context))
657 (setq count
(if (memq (following-char) '(?b ?B
))
661 (re-search-forward "\\<begin\\>\\|\\<end\\>")
663 (if (not (simula-context))
664 (setq count
(if (memq (following-char) '(?e ?E
))
668 ;; If block level not found, jump back to origin and signal an error
671 (error "No higher block level")))
674 (signal 'quit nil
))))))
677 (defun simula-forward-down-level (count)
678 "Move forward down COUNT block levels.
679 If COUNT is negative, move backward down block level instead."
681 ;; When we search for a deeper block level, we must never
682 ;; get out of the block where we started -> count >= start-count
683 (let ((start-count count
)
685 (case-fold-search t
))
689 (re-search-backward "\\<begin\\>\\|\\<end\\>")
690 (if (not (simula-context))
691 (setq count
(if (memq (following-char) '(?e ?E
))
694 (if (< count start-count
) (signal 'error nil
)))
696 (re-search-forward "\\<begin\\>\\|\\<end\\>")
698 (if (not (simula-context))
699 (setq count
(if (memq (following-char) '(?b ?B
))
703 ;; deeper level has to be found within starting block
704 (if (> count start-count
) (signal 'error nil
))))
705 ;; If block level not found, jump back to origin and signal an error
708 (error "No containing block level")))
711 (signal 'quit nil
))))))
714 (defun simula-previous-statement (count)
715 "Move backward COUNT statements.
716 If COUNT is negative, move forward instead."
719 (simula-next-statement (- count
))
726 (simula-skip-comment-backward)
727 (if (memq (preceding-char) '(?n ?N
))
730 (if (not (looking-at "\\<begin\\>"))
732 (if (eq (preceding-char) ?\
;)
735 (while (and (natnump (setq count
(1- count
)))
736 (setq status
(simula-search-backward
737 ";\\|\\<begin\\>" nil
'move
))))
740 (if (eq (following-char) ?\
;)
742 (backward-word -
1))))
743 (simula-skip-comment-forward))
744 (error (progn (goto-char origin
)
745 (error "Incomplete statement (too many ENDs)")))
746 (quit (progn (goto-char origin
) (signal 'quit nil
)))))))
749 (defun simula-next-statement (count)
750 "Move forward COUNT statements.
751 If COUNT is negative, move backward instead."
754 (simula-previous-statement (- count
))
760 (simula-skip-comment-forward)
761 (if (looking-at "\\<end\\>") (forward-word 1))
762 (while (and (natnump (setq count
(1- count
)))
763 (setq status
(simula-search-forward
764 ";\\|\\<end\\>" (point-max) 'move
))))
765 (if (and status
(/= (preceding-char) ?\
;))
768 (simula-skip-comment-backward))))
769 (error (progn (goto-char origin
)
770 (error "Incomplete statement (too few ENDs)")))
771 (quit (progn (goto-char origin
) (signal 'quit nil
)))))))
774 (defun simula-skip-comment-backward (&optional stop-at-end
)
775 "Search towards bob to find first char that is outside a comment."
780 (skip-chars-backward " \t\n\f")
781 (if (eq (preceding-char) ?\
;)
784 (setq context
(simula-context))
785 (if (and stop-at-end
(eq context
2))
787 (setq context
(simula-context)))
789 ((memq context
'(nil 3 4))
790 ;; check to see if we found a label
791 (if (and (eq (preceding-char) ?
:)
792 (not (memq (following-char) '(?- ?
=)))
794 (skip-chars-backward ": \t\fa-zA-Z0-9_")
795 (not (looking-at "virtual\\>"))))
796 (skip-chars-backward ": \t\fa-zA-Z0-9_")
797 (throw 'simula-out nil
)))
799 ;; since we are inside a comment, it must start somewhere!
800 (while (and (re-search-backward "!\\|\\<comment\\>")
801 (memq (simula-context) '(0 1)))))
805 (throw 'simula-out nil
)
808 ;; an END-comment must belong to an END
809 (re-search-backward "\\<end\\>")
811 (throw 'simula-out nil
))
812 ;; should be impossible to get here..
816 (defun simula-skip-comment-forward ()
817 "Search towards eob to find first char that is outside a comment."
818 ;; this function assumes we start with point .outside a comment
822 (skip-chars-forward " \t\n\f")
823 ;; BUG: the following (0 2) branches don't take into account intermixing
826 ((looking-at "!\\|\\<comment\\>")
827 (search-forward ";" nil
'move
))
828 ((and (bolp) (eq (following-char) ?%
))
829 (beginning-of-line 2))
830 ((and (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]")
831 (not (looking-at "virtual\\>")))
832 (skip-chars-forward "a-zA-Z0-9_ \t\f:"))
834 (throw 'simula-out t
))))))
837 (defun simula-forward-up-level ()
838 (let ((continue-loop t
)
844 (if (re-search-backward "\\<begin\\>\\|\\<end\\>" (point-min) 'move
)
845 (setq temp
(simula-context)
846 return-value
(and (memq (preceding-char) '(?d ?D
))
847 (memq temp
'(nil 2)))
848 continue-loop
(and (not return-value
)
849 (simula-forward-up-level)))
850 (setq continue-loop nil
)))
857 (defun simula-calculate-indent ()
859 (let ((where (simula-context))
871 ;; If comment started on previous non-blank line, indent to the
872 ;; column where the comment started, else indent as that line.
874 (skip-chars-backward " \t\n\f")
875 (while (and (not (bolp)) (eq (simula-context) 0))
876 (re-search-backward "^\\|!\\|\\<comment\\>"))
877 (skip-chars-forward " \t\n\f")
883 ;; Directive. Always 0.
887 ;; Detect missing string delimiters
890 (error "Inside string"))
892 (error "Inside character constant"))
894 ;; check to see if inside ()'s
896 ((setq temp
(simula-inside-parens))
899 ;; Calculate non-comment indentation
901 ;; first, find out if this line starts with something that needs
902 ;; special indentation (END/IF/THEN/ELSE/WHEN/OTHERWISE or label)
904 (skip-chars-forward " \t\f")
909 ((looking-at "end\\>")
910 (setq indent
(- simula-indent-level
)
915 ((looking-at "if\\>\\|then\\>\\|else\\>")
916 ;; search for the *starting* IF
918 ((memq (following-char) '(?T ?t
))
919 (setq indent
(car simula-if-indent
)))
920 ((memq (following-char) '(?E ?e
))
921 (setq indent
(cdr simula-if-indent
)))
929 ((looking-at "when\\>\\|otherwise\\>")
930 ;; search for corresponding INSPECT
931 (if (memq (following-char) '(?W ?w
))
932 (setq indent
(car simula-inspect-indent
))
933 (setq indent
(cdr simula-inspect-indent
)))
934 (simula-find-inspect))
938 ((and (not (looking-at "virtual\\>"))
939 (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]"))
940 (setq indent simula-label-offset
)))
941 ;; find line with non-comment text
942 (simula-skip-comment-backward 'dont-skip-end
)
944 (not (eq (preceding-char) ?\
;))
945 (if (memq (preceding-char) '(?N ?n
))
948 (not (looking-at "begin\\>")))
951 (simula-previous-statement 1)
952 (simula-skip-comment-backward)))
954 (line-beginning-position)
955 ;; - perhaps this is a continued statement
960 (if (eq (char-syntax (preceding-char)) ?w
)
964 "begin\\|then\\|else\\|when\\|otherwise\\|do"
966 (not (memq (preceding-char) '(?
: ?\
;)))))))
968 ;; MAIN calculation loop - count BEGIN/DO etc.
971 (if (re-search-backward
972 ";\\|\\<\\(begin\\|end\\|if\\|else\\|then\\|when\\|otherwise\\|do\\)\\>"
975 ();; found something in a comment/string - ignore
976 (setq temp
(following-char))
979 (simula-previous-statement 1))
980 ((looking-at "begin\\>")
981 (setq indent
(+ indent simula-indent-level
)))
982 ((looking-at "end\\>")
984 (simula-previous-statement 1))
985 ((looking-at "do\\>")
986 (setq indent
(+ indent simula-substatement-offset
))
987 (simula-find-do-match))
988 ((looking-at "\\(if\\|then\\|else\\)\\>")
989 (if (memq temp
'(?I ?i
))
991 (setq indent
(+ indent
992 simula-substatement-offset
993 (if (memq temp
'(?T ?t
))
994 (car simula-if-indent
)
995 (cdr simula-if-indent
)))))
997 ((looking-at "\\<when\\>\\|\\<otherwise\\>")
998 (setq indent
(+ indent
999 simula-substatement-offset
1000 (if (memq temp
'(?W ?w
))
1001 (car simula-if-indent
)
1002 (cdr simula-if-indent
))))
1003 (simula-find-inspect)))
1004 ;; found the start of a [sub]statement
1005 ;; add indentation for continued statement
1009 (if (listp simula-continued-statement-offset
)
1010 (car simula-continued-statement-offset
)
1011 simula-continued-statement-offset
))))
1013 (line-beginning-position)
1015 ;; search failed .. point is at beginning of line
1016 ;; determine if we should continue searching
1017 ;; (at or before comment or label)
1018 ;; temp = t means finished
1020 (and (not (simula-context))
1022 (skip-chars-forward " \t\f")
1023 (or (looking-at "virtual")
1026 "!\\|comment\\>\\|[a-z0-9_]*[ \t\f]*:[^-=]")))))
1027 prev-cont continued
)
1028 ;; if we are finished, find current line's indentation
1030 (setq indent
(+ indent
(current-indentation))))
1031 ;; find next line with non-comment SIMULA text
1032 ;; maybe indent extra if statement continues
1033 (simula-skip-comment-backward)
1036 (if (eq (char-syntax (preceding-char)) ?w
)
1040 "begin\\|then\\|else\\|when\\|otherwise\\|do")))
1041 (not (memq (preceding-char) '(?
: ?\
;))))))
1042 ;; if we the state of the continued-variable
1043 ;; changed, add indentation for continued statement
1044 (if (or (and prev-cont
(not continued
))
1046 (listp simula-continued-statement-offset
)))
1049 (if (listp simula-continued-statement-offset
)
1050 (car simula-continued-statement-offset
)
1051 simula-continued-statement-offset
))))
1052 ;; while ends if point is at beginning of line at loop test
1054 (setq start-line
(line-beginning-position))
1055 (beginning-of-line))))
1057 ;; return indentation
1062 (defun simula-find-if ()
1063 "Find starting IF of a IF-THEN[-ELSE[-IF-THEN...]] statement."
1066 (if (and (simula-search-backward "\\<if\\>\\|;\\|\\<begin\\>"nil t
)
1067 (memq (following-char) '(?I ?i
)))
1070 ;; find out if this IF was really the start of the IF statement
1072 (simula-skip-comment-backward)
1073 (if (and (eq (char-syntax (preceding-char)) ?w
)
1076 (looking-at "else\\>")))
1078 (throw 'simula-out t
)))
1079 (if (not (looking-at "\\<if\\>"))
1080 (error "Missing IF or misplaced BEGIN or ';' (can't find IF)")
1082 ;; we were at the starting IF in the first place..
1084 (throw 'simula-out t
))))))
1087 (defun simula-find-inspect ()
1088 "Find INSPECT matching WHEN or OTHERWISE."
1092 ;; INSPECTs can be nested, have to find the corresponding one
1095 (if (and (simula-search-backward "\\<inspect\\>\\|\\<otherwise\\>\\|;"
1097 (/= (following-char) ?\
;))
1098 (if (memq (following-char) '(?O ?o
))
1099 (setq level
(1+ level
))
1101 (throw 'simula-out t
)
1102 (setq level
(1- level
))))
1103 (error "Missing INSPECT or misplaced ';' (can't find INSPECT)"))))))
1106 (defun simula-find-do-match ()
1107 "Find keyword matching DO: FOR, WHILE, INSPECT or WHEN."
1108 (while (and (re-search-backward
1109 "\\<\\(do\\|for\\|while\\|inspect\\|when\\|end\\|begin\\)\\>\\|;"
1112 (if (and (looking-at "\\<\\(for\\|while\\|inspect\\|when\\)\\>")
1113 (not (simula-context)))
1115 (error "No matching FOR, WHILE or INSPECT for DO, or misplaced ';'")))
1118 (defun simula-inside-parens ()
1119 "Return position after `(' on line if inside parentheses, nil otherwise."
1124 (if (re-search-backward "(\\|)\\|;" nil t
)
1125 (if (eq (simula-context) nil
)
1126 ;; found something - check it out
1128 ((eq (following-char) ?\
;)
1129 (if (zerop parlevel
)
1130 (throw 'simula-out nil
)
1131 (error "Parenthesis mismatch or misplaced ';'")))
1132 ((eq (following-char) ?\
()
1133 (if (zerop parlevel
)
1134 (throw 'simula-out
(1+ (current-column)))
1135 (setq parlevel
(1- parlevel
))))
1136 (t (setq parlevel
(1+ parlevel
))))
1137 );; nothing - inside comment or string
1139 (throw 'simula-out nil
)))))))
1142 (defun simula-goto-definition ()
1143 "Goto point of definition of variable, procedure or class."
1147 (defun simula-expand-stdproc ()
1148 (if (or (not simula-abbrev-stdproc
) (simula-context))
1151 ((eq simula-abbrev-stdproc
'upcase
) (upcase-word -
1))
1152 ((eq simula-abbrev-stdproc
'downcase
) (downcase-word -
1))
1153 ((eq simula-abbrev-stdproc
'capitalize
) (capitalize-word -
1))
1154 ((eq simula-abbrev-stdproc
'abbrev-table
)
1155 ;; If not in lowercase, expansions are always capitalized.
1156 ;; We then want to replace with the exact expansion.
1157 (if (equal (symbol-name last-abbrev
) last-abbrev-text
)
1160 (expand-abbrev))))))
1163 (defun simula-expand-keyword ()
1164 (if (or (not simula-abbrev-keyword
) (simula-context))
1167 ((eq simula-abbrev-keyword
'upcase
) (upcase-word -
1))
1168 ((eq simula-abbrev-keyword
'downcase
) (downcase-word -
1))
1169 ((eq simula-abbrev-keyword
'capitalize
) (capitalize-word -
1))
1170 ((eq simula-abbrev-stdproc
'abbrev-table
)
1171 (if (equal (symbol-name last-abbrev
) last-abbrev-text
)
1174 (expand-abbrev))))))
1177 (defun simula-electric-keyword ()
1178 "Expand SIMULA keyword. If it starts the line, reindent."
1180 (let ((show-char (eq this-command
'self-insert-command
)))
1181 ;; If the abbrev expansion results in reindentation, the user may have
1182 ;; to wait some time before the character he typed is displayed
1183 ;; (the char causing the expansion is inserted AFTER the hook function
1184 ;; is called). This is annoying in case of normal characters.
1185 ;; However, if the user pressed a key bound to newline, it is better
1186 ;; to have the line inserted after the begin-end match.
1189 (insert-char last-command-event
1)
1192 (if (let ((where (simula-context))
1193 (case-fold-search t
))
1195 (if (and (eq where
2) (eq (char-syntax (preceding-char)) ?w
))
1198 (not (looking-at "end\\>"))))))
1201 ((not simula-abbrev-keyword
) (unexpand-abbrev))
1202 ((eq simula-abbrev-keyword
'upcase
) (upcase-word -
1))
1203 ((eq simula-abbrev-keyword
'downcase
) (downcase-word -
1))
1204 ((eq simula-abbrev-keyword
'capitalize
) (capitalize-word -
1)))
1205 (let ((pos (- (point-max) (point)))
1206 (case-fold-search t
))
1209 ;; check if the expanded word is on the beginning of the line.
1210 (if (and (eq (char-syntax (preceding-char)) ?w
)
1213 (if (looking-at "end\\>")
1215 (simula-backward-up-level 1)
1216 (if (pos-visible-in-window-p)
1218 (message "Matches %s"
1221 (+ (point) (window-width)))))))
1222 (skip-chars-backward " \t\f")
1224 (let ((indent (simula-calculate-indent)))
1225 (if (eq indent
(current-indentation))
1227 (delete-horizontal-space)
1228 (indent-to indent
)))
1229 (skip-chars-forward " \t\f"))
1230 ;; check for END - blow whistles and ring bells
1232 (goto-char (- (point-max) pos
))
1235 (quit (goto-char (- (point-max) pos
))))))))
1238 (defun simula-search-backward (regexp &optional bound noerror
)
1239 "Search backward from point for regular expression REGEXP,
1240 ignoring matches found inside SIMULA comments, string literals,
1241 and BEGIN..END blocks.
1242 Set point to the end of the occurrence found, and return point.
1243 An optional second argument BOUND bounds the search, it is a buffer position.
1244 The match found must not extend after that position. Optional third argument
1245 NOERROR, if t, means if fail just return nil (no error).
1246 If not nil and not t, move to limit of search and return nil."
1247 (let ((comb-regexp (concat regexp
"\\|\\<end\\>"))
1248 (start-point (point))
1250 (catch 'simula-backward
1251 (while (re-search-backward comb-regexp bound
1)
1252 ;; We have a match, check SIMULA context at match-beginning
1253 ;; to see if we are outside comments etc.
1254 ;; Set MATCH to t if we found a true match,
1255 ;; set MATCH to 'BLOCK if we found a BEGIN..END block,
1256 ;; else set MATCH to nil.
1258 (setq context
(simula-context))
1261 (setq match
(if (looking-at regexp
) t
'BLOCK
)))
1262 ;; A comment-ending `;' is part of the comment, and shouldn't match.
1264 ;; (setq match (if (eq (following-char) ?\;) t nil)))
1266 (setq match
(if (and (looking-at regexp
)
1267 (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>"))
1269 (if (looking-at "\\<end\\>") 'BLOCK nil
))))
1270 (t (setq match nil
))))
1271 ;; Exit if true match
1272 (if (eq match t
) (throw 'simula-backward
(point)))
1273 (if (eq match
'BLOCK
)
1274 ;; We found the END of a block
1276 (while (natnump level
)
1277 (if (re-search-backward "\\<begin\\>\\|\\<end\\>" bound
1)
1278 (let ((context (simula-context)))
1279 ;; We found a BEGIN -> decrease level count
1280 (cond ((and (eq context nil
)
1281 (memq (following-char) '(?b ?B
)))
1282 (setq level
(1- level
)))
1283 ;; END -> increase level count
1284 ((and (memq context
'(nil 2))
1285 (memq (following-char) '(?e ?E
)))
1286 (setq level
(1+ level
)))))
1287 ;; Block search failed. Action depends on noerror.
1288 (if (or (not noerror
) (eq noerror t
))
1289 (goto-char start-point
))
1291 (signal 'search-failed
(list regexp
)))
1292 (throw 'simula-backward nil
))))))
1293 ;; Search failed. Action depends on noerror.
1294 (if (or (not noerror
) (eq noerror t
))
1295 (goto-char start-point
))
1298 (signal 'search-failed
(list regexp
))))))
1301 (defun simula-search-forward (regexp &optional bound noerror
)
1302 "Search forward from point for regular expression REGEXP,
1303 ignoring matches found inside SIMULA comments, string literals,
1304 and BEGIN..END blocks.
1305 Set point to the end of the occurrence found, and return point.
1306 An optional second argument BOUND bounds the search, it is a buffer position.
1307 The match found must not extend after that position. Optional third argument
1308 NOERROR, if t, means if fail just return nil (no error).
1309 If not nil and not t, move to limit of search and return nil."
1310 (let ((comb-regexp (concat regexp
"\\|\\<begin\\>"))
1311 (start-point (point))
1313 (catch 'simula-forward
1314 (while (re-search-forward comb-regexp bound
1)
1315 ;; We have a match, check SIMULA context at match-beginning
1316 ;; to see if we are outside comments.
1317 ;; Set MATCH to t if we found a true match,
1318 ;; set MATCH to 'BLOCK if we found a BEGIN..END block,
1319 ;; else set MATCH to nil.
1322 (goto-char (match-beginning 0))
1323 (setq context
(simula-context))
1326 (setq match
(if (looking-at regexp
) t
'BLOCK
)))
1327 ;; Comment-ending `;' is part of the comment, and shouldn't match.
1329 ;; (setq match (if (eq (following-char) ?\;) t nil)))
1331 (setq match
(if (and (looking-at regexp
)
1332 (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>")) t nil
)))
1333 (t (setq match nil
)))))
1334 ;; Exit if true match
1335 (if (eq match t
) (throw 'simula-forward
(point)))
1336 (if (eq match
'BLOCK
)
1337 ;; We found the BEGINning of a block
1339 (while (natnump level
)
1340 (if (re-search-forward "\\<begin\\>\\|\\<end\\>" bound
1)
1341 (let ((context (simula-context)))
1342 ;; We found a BEGIN -> increase level count
1343 (cond ((eq context nil
) (setq level
(1+ level
)))
1344 ;; END -> decrease level count
1345 ((and (eq context
2)
1346 ;; Don't match BEGIN inside END comment
1347 (memq (preceding-char) '(?d ?D
)))
1348 (setq level
(1- level
)))))
1349 ;; Block search failed. Action depends on noerror.
1350 (if (or (not noerror
) (eq noerror t
))
1351 (goto-char start-point
))
1353 (signal 'search-failed
(list regexp
)))
1354 (throw 'simula-forward nil
))))))
1355 ;; Search failed. Action depends on noerror.
1356 (if (or (not noerror
) (eq noerror t
))
1357 (goto-char start-point
))
1360 (signal 'search-failed
(list regexp
))))))
1363 (defun simula-install-standard-abbrevs ()
1364 "Define Simula keywords, procedures and classes in local abbrev table."
1365 ;; procedure and class names are as of the SIMULA 87 standard.
1368 '(("abs" "Abs" simula-expand-stdproc
)
1369 ("accum" "Accum" simula-expand-stdproc
)
1370 ("activate" "ACTIVATE" simula-expand-keyword
)
1371 ("addepsilon" "AddEpsilon" simula-expand-stdproc
)
1372 ("after" "AFTER" simula-expand-keyword
)
1373 ("and" "AND" simula-expand-keyword
)
1374 ("arccos" "ArcCos" simula-expand-stdproc
)
1375 ("arcsin" "ArcSin" simula-expand-stdproc
)
1376 ("arctan" "ArcTan" simula-expand-stdproc
)
1377 ("arctan2" "ArcTan2" simula-expand-stdproc
)
1378 ("array" "ARRAY" simula-expand-keyword
)
1379 ("at" "AT" simula-expand-keyword
)
1380 ("before" "BEFORE" simula-expand-keyword
)
1381 ("begin" "BEGIN" simula-expand-keyword
)
1382 ("blanks" "Blanks" simula-expand-stdproc
)
1383 ("boolean" "BOOLEAN" simula-expand-keyword
)
1384 ("breakoutimage" "BreakOutImage" simula-expand-stdproc
)
1385 ("bytefile" "ByteFile" simula-expand-stdproc
)
1386 ("call" "Call" simula-expand-stdproc
)
1387 ("cancel" "Cancel" simula-expand-stdproc
)
1388 ("cardinal" "Cardinal" simula-expand-stdproc
)
1389 ("char" "Char" simula-expand-stdproc
)
1390 ("character" "CHARACTER" simula-expand-keyword
)
1391 ("checkpoint" "CheckPoint" simula-expand-stdproc
)
1392 ("class" "CLASS" simula-expand-keyword
)
1393 ("clear" "Clear" simula-expand-stdproc
)
1394 ("clocktime" "ClockTime" simula-expand-stdproc
)
1395 ("close" "Close" simula-expand-stdproc
)
1396 ("comment" "COMMENT" simula-expand-keyword
)
1397 ("constant" "Constant" simula-expand-stdproc
)
1398 ("copy" "Copy" simula-expand-stdproc
)
1399 ("cos" "Cos" simula-expand-stdproc
)
1400 ("cosh" "CosH" simula-expand-stdproc
)
1401 ("cotan" "CoTan" simula-expand-stdproc
)
1402 ("cputime" "CpuTime" simula-expand-stdproc
)
1403 ("current" "Current" simula-expand-stdproc
)
1404 ("datetime" "DateTime" simula-expand-stdproc
)
1405 ("decimalmark" "DecimalMark" simula-expand-stdproc
)
1406 ("delay" "DELAY" simula-expand-keyword
)
1407 ("deleteimage" "DeleteImage" simula-expand-stdproc
)
1408 ("detach" "Detach" simula-expand-stdproc
)
1409 ("digit" "Digit" simula-expand-stdproc
)
1410 ("directbytefile" "DirectByteFile" simula-expand-stdproc
)
1411 ("directfile" "DirectFile" simula-expand-stdproc
)
1412 ("discrete" "Discrete" simula-expand-stdproc
)
1413 ("do" "DO" simula-expand-keyword
)
1414 ("downcase" "Downcase" simula-expand-stdproc
)
1415 ("draw" "Draw" simula-expand-stdproc
)
1416 ("eject" "Eject" simula-expand-stdproc
)
1417 ("else" "ELSE" simula-electric-keyword
)
1418 ("empty" "Empty" simula-expand-stdproc
)
1419 ("end" "END" simula-electric-keyword
)
1420 ("endfile" "Endfile" simula-expand-stdproc
)
1421 ("entier" "Entier" simula-expand-stdproc
)
1422 ("eq" "EQ" simula-expand-keyword
)
1423 ("eqv" "EQV" simula-expand-keyword
)
1424 ("erlang" "Erlang" simula-expand-stdproc
)
1425 ("error" "Error" simula-expand-stdproc
)
1426 ("evtime" "EvTime" simula-expand-stdproc
)
1427 ("exp" "Exp" simula-expand-stdproc
)
1428 ("external" "EXTERNAL" simula-expand-keyword
)
1429 ("false" "FALSE" simula-expand-keyword
)
1430 ("field" "Field" simula-expand-stdproc
)
1431 ("file" "File" simula-expand-stdproc
)
1432 ("first" "First" simula-expand-stdproc
)
1433 ("follow" "Follow" simula-expand-stdproc
)
1434 ("for" "FOR" simula-expand-keyword
)
1435 ("ge" "GE" simula-expand-keyword
)
1436 ("getchar" "GetChar" simula-expand-stdproc
)
1437 ("getfrac" "GetFrac" simula-expand-stdproc
)
1438 ("getint" "GetInt" simula-expand-stdproc
)
1439 ("getreal" "GetReal" simula-expand-stdproc
)
1440 ("go" "GO" simula-expand-keyword
)
1441 ("goto" "GOTO" simula-expand-keyword
)
1442 ("gt" "GT" simula-expand-keyword
)
1443 ("head" "Head" simula-expand-stdproc
)
1444 ("hidden" "HIDDEN" simula-expand-keyword
)
1445 ("histd" "HistD" simula-expand-stdproc
)
1446 ("histo" "Histo" simula-expand-stdproc
)
1447 ("hold" "Hold" simula-expand-stdproc
)
1448 ("idle" "Idle" simula-expand-stdproc
)
1449 ("if" "IF" simula-expand-keyword
)
1450 ("image" "Image" simula-expand-stdproc
)
1451 ("imagefile" "ImageFile" simula-expand-stdproc
)
1452 ("imp" "IMP" simula-expand-keyword
)
1453 ("in" "IN" simula-expand-keyword
)
1454 ("inbyte" "InByte" simula-expand-stdproc
)
1455 ("inbytefile" "InByteFile" simula-expand-stdproc
)
1456 ("inchar" "InChar" simula-expand-stdproc
)
1457 ("infile" "InFile" simula-expand-stdproc
)
1458 ("infrac" "InFrac" simula-expand-stdproc
)
1459 ("inimage" "InImage" simula-expand-stdproc
)
1460 ("inint" "InInt" simula-expand-stdproc
)
1461 ("inner" "INNER" simula-expand-keyword
)
1462 ("inreal" "InReal" simula-expand-stdproc
)
1463 ("inrecord" "InRecord" simula-expand-stdproc
)
1464 ("inspect" "INSPECT" simula-expand-keyword
)
1465 ("integer" "INTEGER" simula-expand-keyword
)
1466 ("intext" "InText" simula-expand-stdproc
)
1467 ("into" "Into" simula-expand-stdproc
)
1468 ("is" "IS" simula-expand-keyword
)
1469 ("isochar" "ISOChar" simula-expand-stdproc
)
1470 ("isopen" "IsOpen" simula-expand-stdproc
)
1471 ("isorank" "ISORank" simula-expand-stdproc
)
1472 ("label" "LABEL" simula-expand-keyword
)
1473 ("last" "Last" simula-expand-stdproc
)
1474 ("lastitem" "LastItem" simula-expand-stdproc
)
1475 ("lastloc" "LastLoc" simula-expand-stdproc
)
1476 ("le" "LE" simula-expand-keyword
)
1477 ("length" "Length" simula-expand-stdproc
)
1478 ("letter" "Letter" simula-expand-stdproc
)
1479 ("line" "Line" simula-expand-stdproc
)
1480 ("linear" "Linear" simula-expand-stdproc
)
1481 ("linesperpage" "LinesPerPage" simula-expand-stdproc
)
1482 ("link" "Link" simula-expand-stdproc
)
1483 ("linkage" "Linkage" simula-expand-stdproc
)
1484 ("ln" "Ln" simula-expand-stdproc
)
1485 ("locate" "Locate" simula-expand-stdproc
)
1486 ("location" "Location" simula-expand-stdproc
)
1487 ("lock" "Lock" simula-expand-stdproc
)
1488 ("locked" "Locked" simula-expand-stdproc
)
1489 ("log10" "Log10" simula-expand-stdproc
)
1490 ("long" "LONG" simula-expand-keyword
)
1491 ("lowcase" "LowCase" simula-expand-stdproc
)
1492 ("lowerbound" "LowerBound" simula-expand-stdproc
)
1493 ("lowten" "LowTen" simula-expand-stdproc
)
1494 ("lt" "LT" simula-expand-keyword
)
1495 ("main" "Main" simula-expand-stdproc
)
1496 ("max" "Max" simula-expand-stdproc
)
1497 ("maxint" "MaxInt" simula-expand-stdproc
)
1498 ("maxlongreal" "MaxLongReal" simula-expand-stdproc
)
1499 ("maxloc" "MaxLoc" simula-expand-stdproc
)
1500 ("maxrank" "MaxRank" simula-expand-stdproc
)
1501 ("maxreal" "MaxReal" simula-expand-stdproc
)
1502 ("min" "Min" simula-expand-stdproc
)
1503 ("minint" "MinInt" simula-expand-stdproc
)
1504 ("minlongreal" "MinLongReal" simula-expand-stdproc
)
1505 ("minrank" "MinRank" simula-expand-stdproc
)
1506 ("minreal" "MinReal" simula-expand-stdproc
)
1507 ("mod" "Mod" simula-expand-stdproc
)
1508 ("more" "More" simula-expand-stdproc
)
1509 ("name" "NAME" simula-expand-keyword
)
1510 ("ne" "NE" simula-expand-keyword
)
1511 ("negexp" "NegExp" simula-expand-stdproc
)
1512 ("new" "NEW" simula-expand-keyword
)
1513 ("nextev" "NextEv" simula-expand-stdproc
)
1514 ("none" "NONE" simula-expand-keyword
)
1515 ("normal" "Normal" simula-expand-stdproc
)
1516 ("not" "NOT" simula-expand-keyword
)
1517 ("notext" "NOTEXT" simula-expand-keyword
)
1518 ("open" "Open" simula-expand-stdproc
)
1519 ("or" "OR" simula-expand-keyword
)
1520 ("otherwise" "OTHERWISE" simula-electric-keyword
)
1521 ("out" "Out" simula-expand-stdproc
)
1522 ("outbyte" "OutByte" simula-expand-stdproc
)
1523 ("outbytefile" "OutByteFile" simula-expand-stdproc
)
1524 ("outchar" "OutChar" simula-expand-stdproc
)
1525 ("outfile" "OutFile" simula-expand-stdproc
)
1526 ("outfix" "OutFix" simula-expand-stdproc
)
1527 ("outfrac" "OutFrac" simula-expand-stdproc
)
1528 ("outimage" "OutImage" simula-expand-stdproc
)
1529 ("outint" "OutInt" simula-expand-stdproc
)
1530 ("outreal" "OutReal" simula-expand-stdproc
)
1531 ("outrecord" "OutRecord" simula-expand-stdproc
)
1532 ("outtext" "OutText" simula-expand-stdproc
)
1533 ("page" "Page" simula-expand-stdproc
)
1534 ("passivate" "Passivate" simula-expand-stdproc
)
1535 ("poisson" "Poisson" simula-expand-stdproc
)
1536 ("pos" "Pos" simula-expand-stdproc
)
1537 ("precede" "Precede" simula-expand-stdproc
)
1538 ("pred" "Pred" simula-expand-stdproc
)
1539 ("prev" "Prev" simula-expand-stdproc
)
1540 ("printfile" "PrintFile" simula-expand-stdproc
)
1541 ("prior" "PRIOR" simula-expand-keyword
)
1542 ("procedure" "PROCEDURE" simula-expand-keyword
)
1543 ("process" "Process" simula-expand-stdproc
)
1544 ("protected" "PROTECTED" simula-expand-keyword
)
1545 ("putchar" "PutChar" simula-expand-stdproc
)
1546 ("putfix" "PutFix" simula-expand-stdproc
)
1547 ("putfrac" "PutFrac" simula-expand-stdproc
)
1548 ("putint" "PutInt" simula-expand-stdproc
)
1549 ("putreal" "PutReal" simula-expand-stdproc
)
1550 ("qua" "QUA" simula-expand-keyword
)
1551 ("randint" "RandInt" simula-expand-stdproc
)
1552 ("rank" "Rank" simula-expand-stdproc
)
1553 ("reactivate" "REACTIVATE" simula-expand-keyword
)
1554 ("real" "REAL" simula-expand-keyword
)
1555 ("ref" "REF" simula-expand-keyword
)
1556 ("resume" "Resume" simula-expand-stdproc
)
1557 ("setaccess" "SetAccess" simula-expand-stdproc
)
1558 ("setpos" "SetPos" simula-expand-stdproc
)
1559 ("short" "SHORT" simula-expand-keyword
)
1560 ("sign" "Sign" simula-expand-stdproc
)
1561 ("simset" "SimSet" simula-expand-stdproc
)
1562 ("simulaid" "SimulaId" simula-expand-stdproc
)
1563 ("simulation" "Simulation" simula-expand-stdproc
)
1564 ("sin" "Sin" simula-expand-stdproc
)
1565 ("sinh" "SinH" simula-expand-stdproc
)
1566 ("sourceline" "SourceLine" simula-expand-stdproc
)
1567 ("spacing" "Spacing" simula-expand-stdproc
)
1568 ("sqrt" "Sqrt" simula-expand-stdproc
)
1569 ("start" "Start" simula-expand-stdproc
)
1570 ("step" "STEP" simula-expand-keyword
)
1571 ("strip" "Strip" simula-expand-stdproc
)
1572 ("sub" "Sub" simula-expand-stdproc
)
1573 ("subepsilon" "SubEpsilon" simula-expand-stdproc
)
1574 ("suc" "Suc" simula-expand-stdproc
)
1575 ("switch" "SWITCH" simula-expand-keyword
)
1576 ("sysin" "SysIn" simula-expand-stdproc
)
1577 ("sysout" "SysOut" simula-expand-stdproc
)
1578 ("tan" "Tan" simula-expand-stdproc
)
1579 ("tanh" "TanH" simula-expand-stdproc
)
1580 ("terminate_program" "Terminate_Program" simula-expand-stdproc
)
1581 ("terminated" "Terminated" simula-expand-stdproc
)
1582 ("text" "TEXT" simula-expand-keyword
)
1583 ("then" "THEN" simula-electric-keyword
)
1584 ("this" "THIS" simula-expand-keyword
)
1585 ("time" "Time" simula-expand-stdproc
)
1586 ("to" "TO" simula-expand-keyword
)
1587 ("true" "TRUE" simula-expand-keyword
)
1588 ("uniform" "Uniform" simula-expand-stdproc
)
1589 ("unlock" "Unlock" simula-expand-stdproc
)
1590 ("until" "UNTIL" simula-expand-keyword
)
1591 ("upcase" "Upcase" simula-expand-stdproc
)
1592 ("upperbound" "UpperBound" simula-expand-stdproc
)
1593 ("value" "VALUE" simula-expand-keyword
)
1594 ("virtual" "VIRTUAL" simula-expand-keyword
)
1595 ("wait" "Wait" simula-expand-stdproc
)
1596 ("when" "WHEN" simula-electric-keyword
)
1597 ("while" "WHILE" simula-expand-keyword
)))
1598 (define-abbrev simula-mode-abbrev-table
1599 (nth 0 args
) (nth 1 args
) (nth 2 args
) nil
'system
)))
1601 (if simula-abbrev-file
1602 (read-abbrev-file simula-abbrev-file
))
1603 (let (abbrevs-changed)
1604 (simula-install-standard-abbrevs))
1606 ;; Hilit mode support.
1607 (when (fboundp 'hilit-set-mode-patterns
)
1608 (when (and (boundp 'hilit-patterns-alist
)
1609 (not (assoc 'simula-mode hilit-patterns-alist
)))
1610 (hilit-set-mode-patterns
1613 ("^%\\([ \t\f].*\\)?$" nil comment
)
1614 ("^%include\\>" nil include
)
1615 ("\"[^\"\n]*\"\\|'.'\\|'![0-9]+!'" nil string
)
1616 ("\\<\\(ACTIVATE\\|AFTER\\|AND\\|ARRAY\\|AT\\|BEFORE\\|BEGIN\\|BOOLEAN\\|CHARACTER\\|CLASS\\|DELAY\\|DO\\|ELSE\\|END\\|EQ\\|EQV\\|EXTERNAL\\|FALSE\\|FOR\\|GE\\|GO\\|GOTO\\|GT\\|HIDDEN\\|IF\\|IMP\\|IN\\|INNER\\|INSPECT\\|INTEGER\\|IS\\|LABEL\\|LE\\|LONG\\|LT\\|NAME\\|NE\\|NEW\\|NONE\\|NOT\\|NOTEXT\\|OR\\|OTHERWISE\\|PRIOR\\|PROCEDURE\\|PROTECTED\\|QUA\\|REACTIVATE\\|REAL\\|REF\\|SHORT\\|STEP\\|SWITCH\\|TEXT\\|THEN\\|THIS\\|TO\\|TRUE\\|UNTIL\\|VALUE\\|VIRTUAL\\|WHEN\\|WHILE\\)\\>" nil keyword
)
1617 ("!\\|\\<COMMENT\\>" ";" comment
))
1618 nil
'case-insensitive
)))
1620 ;; defuns for submitting bug reports
1622 (defconst simula-mode-help-address
"bug-gnu-emacs@gnu.org"
1623 "Address accepting submission of `simula-mode' bug reports.")
1625 (defun simula-submit-bug-report ()
1626 "Submit via mail a bug report on `simula-mode'."
1629 (y-or-n-p "Do you want to submit a report on simula-mode? ")
1630 (reporter-submit-bug-report
1631 simula-mode-help-address
1632 (concat "simula-mode from Emacs " emacs-version
)
1634 ;; report only the vars that affect indentation
1635 'simula-indent-level
1636 'simula-substatement-offset
1637 'simula-continued-statement-offset
1638 'simula-label-offset
1640 'simula-inspect-indent
1641 'simula-electric-indent
1642 'simula-abbrev-keyword
1643 'simula-abbrev-stdproc
1645 'simula-tab-always-indent
1650 ;;; simula.el ends here