annotate lisp/progmodes/simula.el @ 15084:01518892abad

(compilation-error-regexp-alist): Add regexp for Microsoft VC++ error messages containing drive letters.
author Richard M. Stallman <rms@gnu.org>
date Fri, 26 Apr 1996 19:45:16 +0000
parents df34d8bec5fc
children 3c57dbbf9d95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1 ;;; simula.el --- SIMULA 87 code editing commands for Emacs
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
15054
df34d8bec5fc (simula-submit-bug-report): Use emacs-version.
Richard M. Stallman <rms@gnu.org>
parents: 15053
diff changeset
3 ;; Copyright (C) 1992, 1994, 1996 Free Software Foundation, Inc.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
4
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 805
diff changeset
5 ;; Author: Hans Henrik Eriksen <hhe@ifi.uio.no>
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 805
diff changeset
6 ;; Maintainer: simula-mode@ifi.uio.no
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 805
diff changeset
7 ;; Adapted-By: ESR
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 805
diff changeset
8 ;; Keywords: languages
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 805
diff changeset
9
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; any later version.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 10895
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 10895
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 10895
diff changeset
25 ;; Boston, MA 02111-1307, USA.
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 805
diff changeset
27 ;;; Commentary:
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 805
diff changeset
28
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2024
diff changeset
29 ;; A major mode for editing the Simula language. It knows about Simula
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2024
diff changeset
30 ;; syntax and standard indentation commands. It also provides convenient
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2024
diff changeset
31 ;; abbrevs for Simula keywords.
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2024
diff changeset
32 ;;
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2024
diff changeset
33 ;; Hans Henrik Eriksen (the author) may be reached at:
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 ;; Institutt for informatikk,
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35 ;; Universitetet i Oslo
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
36
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 805
diff changeset
37 ;;; Code:
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
39
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
40 (defconst simula-tab-always-indent-default nil
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
41 "Non-nil means TAB in SIMULA mode should always reindent the current line.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
42 Otherwise TAB indents only when point is within
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
43 the run of whitespace at the beginning of the line.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
45 (defvar simula-tab-always-indent simula-tab-always-indent-default
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
46 "*Non-nil means TAB in SIMULA mode should always reindent the current line.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
47 Otherwise TAB indents only when point is within
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
48 the run of whitespace at the beginning of the line.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
50 (defconst simula-indent-level-default 3
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
51 "Indentation of SIMULA statements with respect to containing block.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
52
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
53 (defvar simula-indent-level simula-indent-level-default
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54 "*Indentation of SIMULA statements with respect to containing block.")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
56 (defconst simula-substatement-offset-default 3
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
57 "Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
58
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
59 (defvar simula-substatement-offset simula-substatement-offset-default
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60 "*Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
62 (defconst simula-continued-statement-offset-default 3
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
63 "Extra indentation for lines not starting a statement or substatement.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
64 If value is a list, each line in a multipleline continued statement
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
65 will have the car of the list extra indentation with respect to
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
66 the previous line of the statement.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
67
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
68 (defvar simula-continued-statement-offset simula-continued-statement-offset-default
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 "*Extra indentation for lines not starting a statement or substatement.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70 If value is a list, each line in a multipleline continued statement
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 will have the car of the list extra indentation with respect to
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
72 the previous line of the statement.")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
73
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
74 (defconst simula-label-offset-default -4711
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
75 "Offset of SIMULA label lines relative to usual indentation.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
76
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
77 (defvar simula-label-offset simula-label-offset-default
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
78 "*Offset of SIMULA label lines relative to usual indentation.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
79
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
80 (defconst simula-if-indent-default '(0 . 0)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
81 "Extra indentation of THEN and ELSE with respect to the starting IF.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
82 Value is a cons cell, the car is extra THEN indentation and the cdr
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
83 extra ELSE indentation. IF after ELSE is indented as the starting IF.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
84
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
85 (defvar simula-if-indent simula-if-indent-default
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 "*Extra indentation of THEN and ELSE with respect to the starting IF.
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
87 Value is a cons cell, the car is extra THEN indentation and the cdr
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
88 extra ELSE indentation. IF after ELSE is indented as the starting IF.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
89
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
90 (defconst simula-inspect-indent-default '(0 . 0)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
91 "Extra indentation of WHEN and OTHERWISE with respect to the INSPECT.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
92 Value is a cons cell, the car is extra WHEN indentation
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
93 and the cdr extra OTHERWISE indentation.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
94
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
95 (defvar simula-inspect-indent simula-inspect-indent-default
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
96 "*Extra indentation of WHEN and OTHERWISE with respect to the INSPECT.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
97 Value is a cons cell, the car is extra WHEN indentation
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
98 and the cdr extra OTHERWISE indentation.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
99
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
100 (defconst simula-electric-indent-default nil
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
101 "Non-nil means `simula-indent-line' function may reindent previous line.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
102
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
103 (defvar simula-electric-indent simula-electric-indent-default
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
104 "*Non-nil means `simula-indent-line' function may reindent previous line.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
105
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
106 (defconst simula-abbrev-keyword-default 'upcase
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
107 "Specify how to convert case for SIMULA keywords.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
108 Value is one of the symbols `upcase', `downcase', `capitalize',
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
109 (as in) `abbrev-table' or nil if they should not be changed.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
110
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
111 (defvar simula-abbrev-keyword simula-abbrev-keyword-default
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
112 "*Specify how to convert case for SIMULA keywords.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
113 Value is one of the symbols `upcase', `downcase', `capitalize',
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
114 (as in) `abbrev-table' or nil if they should not be changed.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
115
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
116 (defconst simula-abbrev-stdproc-default 'abbrev-table
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
117 "Specify how to convert case for standard SIMULA procedure and class names.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
118 Value is one of the symbols `upcase', `downcase', `capitalize',
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
119 (as in) `abbrev-table', or nil if they should not be changed.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
120
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
121 (defvar simula-abbrev-stdproc simula-abbrev-stdproc-default
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
122 "*Specify how to convert case for standard SIMULA procedure and class names.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
123 Value is one of the symbols `upcase', `downcase', `capitalize',
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
124 (as in) `abbrev-table', or nil if they should not be changed.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
125
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
126 (defvar simula-abbrev-file nil
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
127 "*File with extra abbrev definitions for use in SIMULA mode.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
128 These are used together with the standard abbrev definitions for SIMULA.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
129 Please note that the standard definitions are required
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
130 for SIMULA mode to function correctly.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
131
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
132 (defvar simula-mode-syntax-table nil
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
133 "Syntax table in SIMULA mode buffers.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
134
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
135 ; The following function is taken from cc-mode.el,
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
136 ; it determines the flavor of the Emacs running
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
137 (defconst simula-emacs-features
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
138 (let ((major (and (boundp 'emacs-major-version)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
139 emacs-major-version))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
140 (minor (and (boundp 'emacs-minor-version)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
141 emacs-minor-version))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
142 flavor comments)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
143 ;; figure out version numbers if not already discovered
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
144 (and (or (not major) (not minor))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
145 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
146 (setq major (string-to-int (substring emacs-version
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
147 (match-beginning 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
148 (match-end 1)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
149 minor (string-to-int (substring emacs-version
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
150 (match-beginning 2)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
151 (match-end 2)))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
152 (if (not (and major minor))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
153 (error "Cannot figure out the major and minor version numbers."))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
154 ;; calculate the major version
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
155 (cond
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
156 ((= major 18) (setq major 'v18)) ;Emacs 18
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
157 ((= major 4) (setq major 'v18)) ;Epoch 4
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
158 ((= major 19) (setq major 'v19 ;Emacs 19
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
159 flavor (if (string-match "Lucid" emacs-version)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
160 'Lucid 'FSF)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
161 ;; I don't know
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
162 (t (error "Cannot recognize major version number: %s" major)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
163 (list major flavor comments))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
164 "A list of features extant in the Emacs you are using.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
165 There are many flavors of Emacs out there, each with different
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
166 features supporting those needed by simula-mode. Here's the current
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
167 supported list, along with the values for this variable:
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
168
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
169 Emacs 19: (v19 FSF 1-bit)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
170 Vanilla Emacs 18/Epoch 4: (v18 no-dual-comments)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
171 Emacs 18/Epoch 4 (patch2): (v18 8-bit)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
172 Lucid Emacs 19: (v19 Lucid 8-bit).")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
173
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
174 (defvar simula-mode-menu
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
175 '(["Report Bug" simula-submit-bug-report t]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
176 ["Indent Line" simula-indent-line t]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
177 ["Backward Statement" simula-previous-statement t]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
178 ["Forward Statement" simula-next-statement t]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
179 ["Backward Up Level" simula-backward-up-level t]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
180 ["Forward Down Statement" simula-forward-down-level t]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
181 )
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
182 "Lucid Emacs menu for SIMULA mode.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
183
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
184 (if simula-mode-syntax-table
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
185 ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
186 (setq simula-mode-syntax-table (copy-syntax-table (standard-syntax-table)))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
187 (modify-syntax-entry ?! "<" simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
188 (modify-syntax-entry ?$ "." simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
189 (modify-syntax-entry ?% "." simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
190 (modify-syntax-entry ?' "\"" simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
191 (modify-syntax-entry ?\( "()" simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
192 (modify-syntax-entry ?\) ")(" simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
193 (modify-syntax-entry ?\; ">" simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
194 (modify-syntax-entry ?\[ "." simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
195 (modify-syntax-entry ?\\ "." simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
196 (modify-syntax-entry ?\] "." simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
197 (modify-syntax-entry ?_ "w" simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
198 (modify-syntax-entry ?\| "." simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
199 (modify-syntax-entry ?\{ "." simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
200 (modify-syntax-entry ?\} "." simula-mode-syntax-table))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
201
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
202 (defvar simula-mode-map ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
203 "Keymap used in SIMULA mode.")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
204
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
205 (if simula-mode-map
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
206 ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
207 (setq simula-mode-map (make-sparse-keymap))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
208 (define-key simula-mode-map "\C-c\C-u" 'simula-backward-up-level)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
209 (define-key simula-mode-map "\C-c\C-p" 'simula-previous-statement)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
210 (define-key simula-mode-map "\C-c\C-d" 'simula-forward-down-level)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
211 (define-key simula-mode-map "\C-c\C-n" 'simula-next-statement)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
212 ;(define-key simula-mode-map "\C-c\C-g" 'simula-goto-definition)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
213 ;(define-key simula-mode-map "\C-c\C-h" 'simula-standard-help)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
214 (define-key simula-mode-map "\177" 'backward-delete-char-untabify)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
215 (define-key simula-mode-map ":" 'simula-electric-label)
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
216 (define-key simula-mode-map "\e\C-q" 'simula-indent-exp)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
217 (define-key simula-mode-map "\t" 'simula-indent-command)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
218 ;; Emacs 19 defines menus in the mode map
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
219 (if (memq 'FSF simula-emacs-features)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
220 (progn
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
221 (define-key simula-mode-map [menu-bar] (make-sparse-keymap))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
222
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
223 (define-key simula-mode-map [menu-bar simula]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
224 (cons "SIMULA" (make-sparse-keymap "SIMULA")))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
225 (define-key simula-mode-map [menu-bar simula bug-report]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
226 '("Submit Bug Report" . simula-submit-bug-report))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
227 (define-key simula-mode-map [menu-bar simula separator-indent]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
228 '("--"))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
229 (define-key simula-mode-map [menu-bar simula indent-exp]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
230 '("Indent Expression" . simula-indent-exp))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
231 (define-key simula-mode-map [menu-bar simula indent-line]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
232 '("Indent Line" . simula-indent-command))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
233 (define-key simula-mode-map [menu-bar simula separator-navigate]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
234 '("--"))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
235 (define-key simula-mode-map [menu-bar simula backward-stmt]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
236 '("Previous Statement" . simula-previous-statement))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
237 (define-key simula-mode-map [menu-bar simula forward-stmt]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
238 '("Next Statement" . simula-next-statement))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
239 (define-key simula-mode-map [menu-bar simula backward-up]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
240 '("Backward Up Level" . simula-backward-up-level))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
241 (define-key simula-mode-map [menu-bar simula forward-down]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
242 '("Forward Down Statement" . simula-forward-down-level))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
243
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
244 (put 'simula-next-statement 'menu-enable '(not (eobp)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
245 (put 'simula-previous-statement 'menu-enable '(not (bobp)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
246 (put 'simula-forward-down-level 'menu-enable '(not (eobp)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
247 (put 'simula-backward-up-level 'menu-enable '(not (bobp)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
248 (put 'simula-indent-command 'menu-enable '(not buffer-read-only))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
249 (put 'simula-indent-exp 'menu-enable '(not buffer-read-only))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
250
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
251 ;; RMS: mouse-3 should not select this menu. mouse-3's global
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
252 ;; definition is useful in SIMULA mode and we should not interfere
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
253 ;; with that. The menu is mainly for beginners, and for them,
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
254 ;; the menubar requires less memory than a special click.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
255 ;; in Lucid Emacs, we want the menu to popup when the 3rd button is
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
256 ;; hit. In 19.10 and beyond this is done automatically if we put
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
257 ;; the menu on mode-popup-menu variable, see c-common-init [cc-mode.el]
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
258 (if (memq 'Lucid simula-emacs-features)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
259 (if (not (boundp 'mode-popup-menu))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
260 (define-key simula-mode-map 'button3 'simula-popup-menu))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
261
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
262 ;; menus for Lucid
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
263 (defun simula-popup-menu (e)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
264 "Pops up the SIMULA menu."
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
265 (interactive "@e")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
266 (popup-menu (cons (concat mode-name " Mode Commands") simula-mode-menu))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
267 (simula-keep-region-active))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
268
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
269 ;; active regions, and auto-newline/hungry delete key
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
270 (defun simula-keep-region-active ()
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
271 ;; do whatever is necessary to keep the region active in
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
272 ;; Lucid. ignore byte-compiler warnings you might see
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
273 (and (boundp 'zmacs-region-stays)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
274 (setq zmacs-region-stays t)))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
275
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
276 (defvar simula-mode-abbrev-table nil
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
277 "Abbrev table in SIMULA mode buffers")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
278
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
279
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
280 (defun simula-mode ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
281 "Major mode for editing SIMULA code.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
282 \\{simula-mode-map}
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
283 Variables controlling indentation style:
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
284 simula-tab-always-indent
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
285 Non-nil means TAB in SIMULA mode should always reindent the current line,
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
286 regardless of where in the line point is when the TAB command is used.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
287 simula-indent-level
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
288 Indentation of SIMULA statements with respect to containing block.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
289 simula-substatement-offset
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
290 Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
291 simula-continued-statement-offset 3
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
292 Extra indentation for lines not starting a statement or substatement,
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
293 e.g. a nested FOR-loop. If value is a list, each line in a multiple-
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
294 line continued statement will have the car of the list extra indentation
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
295 with respect to the previous line of the statement.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
296 simula-label-offset -4711
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
297 Offset of SIMULA label lines relative to usual indentation.
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
298 simula-if-indent '(0 . 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
299 Extra indentation of THEN and ELSE with respect to the starting IF.
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
300 Value is a cons cell, the car is extra THEN indentation and the cdr
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
301 extra ELSE indentation. IF after ELSE is indented as the starting IF.
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
302 simula-inspect-indent '(0 . 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
303 Extra indentation of WHEN and OTHERWISE with respect to the
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
304 corresponding INSPECT. Value is a cons cell, the car is
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
305 extra WHEN indentation and the cdr extra OTHERWISE indentation.
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
306 simula-electric-indent nil
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
307 If this variable is non-nil, `simula-indent-line'
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
308 will check the previous line to see if it has to be reindented.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
309 simula-abbrev-keyword 'upcase
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
310 Determine how SIMULA keywords will be expanded. Value is one of
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
311 the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table',
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
312 or nil if they should not be changed.
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
313 simula-abbrev-stdproc 'abbrev-table
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
314 Determine how standard SIMULA procedure and class names will be
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
315 expanded. Value is one of the symbols `upcase', `downcase', `capitalize',
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
316 (as in) `abbrev-table', or nil if they should not be changed.
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
317
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
318 Turning on SIMULA mode calls the value of the variable simula-mode-hook
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
319 with no arguments, if that value is non-nil
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
320
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
321 Warning: simula-mode-hook should not read in an abbrev file without calling
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
322 the function simula-install-standard-abbrevs afterwards, preferably not
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
323 at all."
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
324 (interactive)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
325 (kill-all-local-variables)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
326 (use-local-map simula-mode-map)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
327 (setq major-mode 'simula-mode)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
328 (setq mode-name "SIMULA")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
329 (make-local-variable 'comment-column)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
330 (setq comment-column 40)
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
331 ; (make-local-variable 'end-comment-column)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
332 ; (setq end-comment-column 75)
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
333 (set-syntax-table simula-mode-syntax-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
334 (make-local-variable 'paragraph-start)
10895
27b6776dc562 (simula-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents: 7639
diff changeset
335 (setq paragraph-start "[ \t]*$\\|\\f")
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
336 (make-local-variable 'paragraph-separate)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
337 (setq paragraph-separate paragraph-start)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
338 (make-local-variable 'indent-line-function)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
339 (setq indent-line-function 'simula-indent-line)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
340 (make-local-variable 'require-final-newline)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
341 (setq require-final-newline t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
342 (make-local-variable 'comment-start)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
343 (setq comment-start "! ")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
344 (make-local-variable 'comment-end)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
345 (setq comment-end " ;")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
346 (make-local-variable 'comment-start-skip)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
347 (setq comment-start-skip "!+ *")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
348 (make-local-variable 'parse-sexp-ignore-comments)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
349 (setq parse-sexp-ignore-comments nil)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
350 (make-local-variable 'comment-multi-line)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
351 (setq comment-multi-line t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
352 (if simula-mode-abbrev-table
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
353 ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
354 (if simula-abbrev-file
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
355 (read-abbrev-file simula-abbrev-file)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
356 (define-abbrev-table 'simula-mode-abbrev-table ()))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
357 (let (abbrevs-changed)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
358 (simula-install-standard-abbrevs)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
359 (setq local-abbrev-table simula-mode-abbrev-table)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
360 (abbrev-mode 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
361 (run-hooks 'simula-mode-hook))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
362
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
363
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
364 (defun simula-indent-exp ()
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
365 "Indent SIMULA expression following point."
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
366 (interactive)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
367 (let ((here (point))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
368 (simula-electric-indent nil)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
369 end)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
370 (simula-skip-comment-forward)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
371 (if (eobp)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
372 (goto-char here)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
373 (unwind-protect
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
374 (progn
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
375 (simula-next-statement 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
376 (setq end (point-marker))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
377 (simula-previous-statement 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
378 (beginning-of-line)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
379 (while (< (point) end)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
380 (if (not (looking-at "[ \t]*$"))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
381 (simula-indent-line))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
382 (forward-line 1)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
383 (and end (set-marker end nil))))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
384
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
385
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
386 (defun simula-indent-line ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
387 "Indent this line as SIMULA code.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
388 If `simula-electric-indent' is non-nil, indent previous line if necessary."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
389 (let ((origin (- (point-max) (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
390 (indent (simula-calculate-indent))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
391 (case-fold-search t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
392 (unwind-protect
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
393 (if simula-electric-indent
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
394 (progn
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
395 ;;
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
396 ;; manually expand abbrev on last line, if any
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
397 ;;
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
398 (end-of-line 0)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
399 (expand-abbrev)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
400 ;; now maybe we should reindent that line
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
401 (beginning-of-line)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
402 (skip-chars-forward " \t\f")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
403 (if (and
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
404 (looking-at
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
405 "\\(end\\|if\\|then\\|else\\|when\\|otherwise\\)\\>")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
406 (not (simula-context)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
407 ;; yes - reindent
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
408 (let ((post-indent (simula-calculate-indent)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
409 (if (eq (current-indentation) post-indent)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
410 ()
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
411 (delete-horizontal-space)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
412 (indent-to post-indent))))))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
413 (goto-char (- (point-max) origin))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
414 (if (eq (current-indentation) indent)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
415 (back-to-indentation)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
416 (delete-horizontal-space)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
417 (indent-to indent)))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
418
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
419
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
420 (defun simula-indent-command (&optional whole-exp)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
421 "Indent current line as SIMULA code, or insert TAB character.
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
422 If `simula-tab-always-indent' is non-nil, always indent current line.
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
423 Otherwise, indent only if point is before any non-whitespace
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
424 character on the line.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
425
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
426 A numeric argument, regardless of its value, means indent rigidly
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
427 all the lines of the SIMULA statement after point so that this line
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
428 becomes properly indented.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
429 The relative indentation among the lines of the statement are preserved."
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
430 (interactive "P")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
431 (let ((case-fold-search t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
432 (if (or whole-exp simula-tab-always-indent
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
433 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
434 (skip-chars-backward " \t\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
435 (bolp)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
436 ;; reindent current line
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
437 (let ((indent (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
438 (beginning-of-line)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
439 (simula-calculate-indent)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
440 (current (current-indentation))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
441 (origin (- (point-max) (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
442 (bol (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
443 (skip-chars-backward " \t\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
444 (bolp)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
445 beg end)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
446 (unwind-protect
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
447 (if (eq current indent)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
448 (if (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
449 (skip-chars-backward " \t\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
450 (bolp))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
451 (back-to-indentation))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
452 (beginning-of-line)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
453 (delete-horizontal-space)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
454 (indent-to indent))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
455 (if (not bol)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
456 (goto-char (- (point-max) origin))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
457 (setq origin (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
458 (if whole-exp
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
459 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
460 (beginning-of-line 2)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
461 (setq beg (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
462 (goto-char origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
463 (simula-next-statement 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
464 (setq end (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
465 (if (and (> end beg) (not (eq indent current)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
466 (indent-code-rigidly beg end (- indent current) "%")))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
467 (insert-tab))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
468
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
469
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
470 (defun simula-context ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
471 "Returns value according to syntactic SIMULA context of point.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
472 0 point inside COMMENT comment
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
473 1 point on SIMULA-compiler directive line
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
474 2 point inside END comment
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
475 3 point inside string
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
476 4 point inside character constant
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
477 nil otherwise."
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
478 ;; first, find out if this is a compiler directive line
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
479 (if (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
480 (beginning-of-line)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
481 (eq (following-char) ?%))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
482 ;; YES - return 1
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
483 1
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
484 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
485 ;; The current line is NOT a compiler directive line.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
486 ;; Now, the strategy is to search backward to find a semicolon
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
487 ;; that is NOT inside a string. The point after semicolon MUST be
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
488 ;; outside a comment, since semicolons are comment-ending and
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
489 ;; comments are non-recursive. We take advantage of the fact
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
490 ;; that strings MUST end on the same line as they started, so
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
491 ;; that we can easily decide whether we are inside a string or not.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
492 (let (return-value (origin (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
493 (skip-chars-backward "^;" (point-min))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
494 ;; found semicolon or beginning of buffer
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
495 (let (loopvalue (saved-point origin))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
496 (while (and (not (bobp))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
497 (if (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
498 (beginning-of-line)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
499 ;; compiler directive line? If so, cont searching..
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
500 (eq (following-char) ?%))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
501 t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
502 (while (< (point) saved-point)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
503 (skip-chars-forward "^;\"'")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
504 (forward-char 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
505 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
506 ((eq (preceding-char) ?\;)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
507 (setq saved-point (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
508 ((eq (preceding-char) ?\")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
509 (skip-chars-forward "^\";")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
510 (if (eq (following-char) ?\;)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
511 (setq saved-point (point) loopvalue t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
512 (forward-char 1)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
513 (t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
514 (if (eq (following-char) ?')
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
515 (forward-char 1))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
516 (skip-chars-forward "^';")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
517 (if (eq (following-char) ?\;)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
518 (setq saved-point (point) loopvalue t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
519 (forward-char 1)))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
520 loopvalue))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
521 (backward-char 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
522 (skip-chars-backward "^;")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
523 (setq saved-point (point) loopvalue nil)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
524 ;; Now we are CERTAIN that we are outside comments and strings.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
525 ;; The job now is to search forward again towards the origin
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
526 ;; skipping directives, comments and strings correctly,
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
527 ;; so that we know what context we are in when we find the origin.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
528 (while (and
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
529 (< (point) origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
530 (re-search-forward
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
531 "\\<end\\>\\|!\\|\"\\|'\\|^%\\|\\<comment\\>" origin 'move))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
532 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
533 ((memq (preceding-char) '(?d ?D))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
534 (setq return-value 2)
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
535 (while (and (re-search-forward
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
536 ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>\\|^%"
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
537 origin 'move)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
538 ;; found another END?
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
539 (or (memq (preceding-char) '(?d ?D))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
540 ;; if directive, skip line
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
541 (and (eq (preceding-char) ?%)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
542 (beginning-of-line 2))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
543 ;; found other keyword, out of END comment
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
544 (setq return-value nil))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
545 (if (and (eq (char-syntax (preceding-char)) ?w)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
546 (eq (char-syntax (following-char)) ?w))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
547 (save-excursion
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
548 (backward-word 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
549 (if (looking-at "end\\>\\|else\\>\\|otherwise\\>\\|when\\>")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
550 (setq return-value nil)))))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
551 ((memq (preceding-char) '(?! ?t ?T))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
552 ; skip comment
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
553 (setq return-value 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
554 (skip-chars-forward "^%;" origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
555 (while (and return-value (< (point) origin))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
556 (if (eq (following-char) ?\;)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
557 (setq return-value nil)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
558 (if (bolp)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
559 (beginning-of-line 2) ; skip directive inside comment
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
560 (forward-char 1)) ; or single '%'
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
561 (skip-chars-forward "^%;" origin))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
562 ((eq (preceding-char) ?\")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
563 (if (not (search-forward "\"" origin 'move))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
564 (setq return-value 3)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
565 ((eq (preceding-char) ?\')
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
566 (if (or (eq (point) origin) (eobp))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
567 (setq return-value 4)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
568 (forward-char 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
569 (if (not (search-forward "'" origin 'move))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
570 (setq return-value 4))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
571 ;; compiler directive line - skip
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
572 (t (beginning-of-line 2))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
573 return-value)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
574 )))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
575
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
576
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
577 (defun simula-electric-label ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
578 "If this is a label that starts the line, reindent the line."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
579 (interactive)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
580 (expand-abbrev)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
581 (insert ?:)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
582 (let ((origin (- (point-max) (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
583 (case-fold-search t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
584 ;; don't mix a label with an assignment operator := :-
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
585 ;; therefore take a peek at next typed character...
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
586 (next-char (read-event)))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
587 (unwind-protect
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
588 (setq unread-command-events (append unread-command-events
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
589 (list next-char)))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
590 ;; Problem: find out if character just read is a command char
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
591 ;; that would insert something after ':' making it a label.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
592 ;; At least \n, \r (and maybe \t) falls into this category.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
593 ;; This is a real crock, it depends on traditional keymap
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
594 ;; bindings, that is, printing characters doing self-insert,
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
595 ;; and no other command sequence inserting '-' or '='.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
596 ;; simula-electric-label can be easily fooled...
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
597 (if (and (not (memq next-char '(?= ?-)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
598 (or (memq next-char '(?\n ?\r))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
599 (and (eq next-char ?\t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
600 simula-tab-always-indent)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
601 (not (memq (following-char) '(?= ?-))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
602 (not (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
603 ;; label?
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
604 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
605 (backward-char 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
606 (skip-chars-backward " \t\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
607 (skip-chars-backward "a-zA-Z0-9_")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
608 (if (looking-at "virtual\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
609 nil
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
610 (skip-chars-backward " \t\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
611 (bolp))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
612 (let ((amount (simula-calculate-indent)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
613 (delete-horizontal-space)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
614 (indent-to amount)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
615 (goto-char (- (point-max) origin)))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
616
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
617
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
618 (defun simula-backward-up-level (count)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
619 "Move backward up COUNT block levels.
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
620 If COUNT is negative, move forward up block level instead."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
621 (interactive "p")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
622 (let ((origin (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
623 (case-fold-search t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
624 (condition-case ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
625 (if (> count 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
626 (while (> count 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
627 (re-search-backward "\\<begin\\>\\|\\<end\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
628 (if (not (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
629 (setq count (if (memq (following-char) '(?b ?B))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
630 (1- count)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
631 (1+ count)))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
632 (while (< count 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
633 (re-search-forward "\\<begin\\>\\|\\<end\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
634 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
635 (if (not (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
636 (setq count (if (memq (following-char) '(?e ?E))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
637 (1+ count)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
638 (1- count))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
639 (backward-word -1)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
640 ;; If block level not found, jump back to origin and signal an error
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
641 (error (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
642 (goto-char origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
643 (error "No higher block level")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
644 (quit (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
645 (goto-char origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
646 (signal 'quit nil))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
647
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
648
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
649 (defun simula-forward-down-level (count)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
650 "Move forward down COUNT block levels.
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
651 If COUNT is negative, move backward down block level instead."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
652 (interactive "p")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
653 ;; When we search for a deeper block level, we must never
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
654 ;; get out of the block where we started -> count >= start-count
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
655 (let ((start-count count)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
656 (origin (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
657 (case-fold-search t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
658 (condition-case ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
659 (if (< count 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
660 (while (< count 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
661 (re-search-backward "\\<begin\\>\\|\\<end\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
662 (if (not (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
663 (setq count (if (memq (following-char) '(?e ?E))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
664 (1+ count)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
665 (1- count))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
666 (if (< count start-count) (signal 'error nil)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
667 (while (> count 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
668 (re-search-forward "\\<begin\\>\\|\\<end\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
669 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
670 (if (not (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
671 (setq count (if (memq (following-char) '(?b ?B))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
672 (1- count)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
673 (1+ count))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
674 (backward-word -1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
675 ;; deeper level has to be found within starting block
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
676 (if (> count start-count) (signal 'error nil))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
677 ;; If block level not found, jump back to origin and signal an error
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
678 (error (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
679 (goto-char origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
680 (error "No containing block level")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
681 (quit (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
682 (goto-char origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
683 (signal 'quit nil))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
684
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
685
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
686 (defun simula-previous-statement (count)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
687 "Move backward COUNT statements.
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
688 If COUNT is negative, move forward instead."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
689 (interactive "p")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
690 (if (< count 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
691 (simula-next-statement (- count))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
692 (let (status
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
693 (case-fold-search t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
694 (origin (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
695 (condition-case ()
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
696 ;;
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
697 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
698 (simula-skip-comment-backward)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
699 (if (memq (preceding-char) '(?n ?N))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
700 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
701 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
702 (if (not (looking-at "\\<begin\\>"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
703 (backward-word -1)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
704 (if (eq (preceding-char) ?\;)
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
705 (backward-char 1))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
706 )
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
707 (while (and (natnump (setq count (1- count)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
708 (setq status (simula-search-backward
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
709 ";\\|\\<begin\\>" nil 'move))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
710 (if status
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
711 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
712 (if (eq (following-char) ?\;)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
713 (forward-char 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
714 (backward-word -1))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
715 (simula-skip-comment-forward))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
716 (error (progn (goto-char origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
717 (error "Incomplete statement (too many ENDs)")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
718 (quit (progn (goto-char origin) (signal 'quit nil)))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
719
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
720
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
721 (defun simula-next-statement (count)
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
722 "Move forward COUNT statements.
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
723 If COUNT is negative, move backward instead."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
724 (interactive "p")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
725 (if (< count 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
726 (simula-previous-statement (- count))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
727 (let (status
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
728 (case-fold-search t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
729 (origin (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
730 (condition-case ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
731 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
732 (simula-skip-comment-forward)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
733 (if (looking-at "\\<end\\>") (forward-word 1))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
734 (while (and (natnump (setq count (1- count)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
735 (setq status (simula-search-forward
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
736 ";\\|\\<end\\>" (point-max) 'move))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
737 (if (and status (/= (preceding-char) ?\;))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
738 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
739 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
740 (simula-skip-comment-backward))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
741 (error (progn (goto-char origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
742 (error "Incomplete statement (too few ENDs)")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
743 (quit (progn (goto-char origin) (signal 'quit nil)))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
744
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
745
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
746 (defun simula-skip-comment-backward (&optional stop-at-end)
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
747 "Search towards bob to find first char that is outside a comment."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
748 (interactive)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
749 (catch 'simula-out
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
750 (let (context)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
751 (while t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
752 (skip-chars-backward " \t\n\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
753 (if (eq (preceding-char) ?\;)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
754 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
755 (backward-char 1)
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
756 (setq context (simula-context))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
757 (if (and stop-at-end (eq context 2))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
758 (setq context nil)))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
759 (setq context (simula-context)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
760 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
761 ((memq context '(nil 3 4))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
762 ;; check to see if we found a label
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
763 (if (and (eq (preceding-char) ?:)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
764 (not (memq (following-char) '(?- ?=)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
765 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
766 (skip-chars-backward ": \t\fa-zA-Z0-9_")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
767 (not (looking-at "virtual\\>"))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
768 (skip-chars-backward ": \t\fa-zA-Z0-9_")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
769 (throw 'simula-out nil)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
770 ((eq context 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
771 ;; since we are inside a comment, it must start somewhere!
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
772 (while (and (re-search-backward "!\\|\\<comment\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
773 (memq (simula-context) '(0 1)))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
774 ((eq context 1)
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
775 (beginning-of-line)
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
776 (if (bobp)
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
777 (throw 'simula-out nil)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
778 (backward-char)))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
779 ((eq context 2)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
780 ;; an END-comment must belong to an END
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
781 (re-search-backward "\\<end\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
782 (forward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
783 (throw 'simula-out nil))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
784 ;; should be impossible to get here..
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
785 )))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
786
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
787
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
788 (defun simula-skip-comment-forward ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
789 "Search towards eob to find first char that is outside a comment."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
790 ;; this function assumes we start with point .outside a comment
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
791 (interactive)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
792 (catch 'simula-out
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
793 (while t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
794 (skip-chars-forward " \t\n\f")
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
795 ;; BUG: the following (0 2) branches don't take into account intermixing
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
796 ;; directive lines
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
797 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
798 ((looking-at "!\\|\\<comment\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
799 (search-forward ";" nil 'move))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
800 ((and (bolp) (eq (following-char) ?%))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
801 (beginning-of-line 2))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
802 ((and (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
803 (not (looking-at "virtual\\>")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
804 (skip-chars-forward "a-zA-Z0-9_ \t\f:"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
805 (t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
806 (throw 'simula-out t))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
807
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
808
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
809 (defun simula-forward-up-level ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
810 (let ((continue-loop t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
811 (origin (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
812 (case-fold-search t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
813 return-value
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
814 temp)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
815 (while continue-loop
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
816 (if (re-search-backward "\\<begin\\>\\|\\<end\\>" (point-min) 'move)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
817 (setq temp (simula-context)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
818 return-value (and (memq (preceding-char) '(?d ?D))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
819 (memq temp '(nil 2)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
820 continue-loop (and (not return-value)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
821 (simula-forward-up-level)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
822 (setq continue-loop nil)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
823 (if return-value
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
824 t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
825 (goto-char origin)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
826 nil)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
827
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
828
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
829 (defun simula-calculate-indent ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
830 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
831 (let ((where (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
832 (origin (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
833 (indent 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
834 continued
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
835 start-line
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
836 temp
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
837 found-end
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
838 prev-cont)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
839 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
840 ((eq where 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
841 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
842 ;; Comment.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
843 ;; If comment started on previous non-blank line, indent to the
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
844 ;; column where the comment started, else indent as that line.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
845 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
846 (skip-chars-backward " \t\n\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
847 (while (and (not (bolp)) (eq (simula-context) 0))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
848 (re-search-backward "^\\|!\\|\\<comment\\>"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
849 (skip-chars-forward " \t\n\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
850 (prog1
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
851 (current-column)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
852 (goto-char origin)))
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
853 ((eq where 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
854 ;;
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
855 ;; Directive. Always 0.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
856 ;;
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
857 0)
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
858 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
859 ;; Detect missing string delimiters
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
860 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
861 ((eq where 3)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
862 (error "Inside string"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
863 ((eq where 4)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
864 (error "Inside character constant"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
865 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
866 ;; check to see if inside ()'s
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
867 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
868 ((setq temp (simula-inside-parens))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
869 temp)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
870 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
871 ;; Calculate non-comment indentation
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
872 (t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
873 ;; first, find out if this line starts with something that needs
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
874 ;; special indentation (END/IF/THEN/ELSE/WHEN/OTHERWISE or label)
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
875 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
876 (skip-chars-forward " \t\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
877 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
878 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
879 ;; END
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
880 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
881 ((looking-at "end\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
882 (setq indent (- simula-indent-level)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
883 found-end t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
884 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
885 ;; IF/THEN/ELSE
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
886 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
887 ((looking-at "if\\>\\|then\\>\\|else\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
888 ;; search for the *starting* IF
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
889 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
890 ((memq (following-char) '(?T ?t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
891 (setq indent (car simula-if-indent)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
892 ((memq (following-char) '(?E ?e))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
893 (setq indent (cdr simula-if-indent)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
894 (t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
895 (forward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
896 (setq indent 0)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
897 (simula-find-if))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
898 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
899 ;; WHEN/OTHERWISE
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
900 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
901 ((looking-at "when\\>\\|otherwise\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
902 ;; search for corresponding INSPECT
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
903 (if (memq (following-char) '(?W ?w))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
904 (setq indent (car simula-inspect-indent))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
905 (setq indent (cdr simula-inspect-indent)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
906 (simula-find-inspect))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
907 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
908 ;; label:
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
909 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
910 ((and (not (looking-at "virtual\\>"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
911 (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
912 (setq indent simula-label-offset)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
913 ;; find line with non-comment text
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
914 (simula-skip-comment-backward 'dont-skip-end)
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
915 (if (and found-end
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
916 (not (eq (preceding-char) ?\;))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
917 (if (memq (preceding-char) '(?N ?n))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
918 (save-excursion
1621
ec2c000b8b69 * bytecomp.el: Declare unread-command-char an obsolete variable.
Jim Blandy <jimb@redhat.com>
parents: 841
diff changeset
919 (backward-word 1)
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
920 (not (looking-at "begin\\>")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
921 t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
922 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
923 (simula-previous-statement 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
924 (simula-skip-comment-backward)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
925 (setq start-line
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
926 (save-excursion (beginning-of-line) (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
927 ;; - perhaps this is a continued statement
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
928 continued
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
929 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
930 (and (not (bobp))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
931 ;; (not found-end)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
932 (if (eq (char-syntax (preceding-char)) ?w)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
933 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
934 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
935 (not (looking-at
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
936 "begin\\|then\\|else\\|when\\|otherwise\\|do"
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
937 )))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
938 (not (memq (preceding-char) '(?: ?\;)))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
939 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
940 ;; MAIN calculation loop - count BEGIN/DO etc.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
941 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
942 (while (not (bolp))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
943 (if (re-search-backward
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
944 ";\\|\\<\\(begin\\|end\\|if\\|else\\|then\\|when\\|otherwise\\|do\\)\\>"
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
945 start-line 'move)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
946 (if (simula-context)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
947 ();; found something in a comment/string - ignore
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
948 (setq temp (following-char))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
949 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
950 ((eq temp ?\;)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
951 (simula-previous-statement 1))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
952 ((looking-at "begin\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
953 (setq indent (+ indent simula-indent-level)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
954 ((looking-at "end\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
955 (forward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
956 (simula-previous-statement 1))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
957 ((looking-at "do\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
958 (setq indent (+ indent simula-substatement-offset))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
959 (simula-find-do-match))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
960 ((looking-at "\\(if\\|then\\|else\\)\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
961 (if (memq temp '(?I ?i))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
962 (forward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
963 (setq indent (+ indent
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
964 simula-substatement-offset
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
965 (if (memq temp '(?T ?t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
966 (car simula-if-indent)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
967 (cdr simula-if-indent)))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
968 (simula-find-if))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
969 ((looking-at "\\<when\\>\\|\\<otherwise\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
970 (setq indent (+ indent
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
971 simula-substatement-offset
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
972 (if (memq temp '(?W ?w))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
973 (car simula-if-indent)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
974 (cdr simula-if-indent))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
975 (simula-find-inspect)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
976 ;; found the start of a [sub]statement
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
977 ;; add indentation for continued statement
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
978 (if continued
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
979 (setq indent
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
980 (+ indent
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
981 (if (listp simula-continued-statement-offset)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
982 (car simula-continued-statement-offset)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
983 simula-continued-statement-offset))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
984 (setq start-line
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
985 (save-excursion (beginning-of-line) (point))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
986 continued nil))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
987 ;; search failed .. point is at beginning of line
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
988 ;; determine if we should continue searching
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
989 ;; (at or before comment or label)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
990 ;; temp = t means finished
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
991 (setq temp
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
992 (and (not (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
993 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
994 (skip-chars-forward " \t\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
995 (or (looking-at "virtual")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
996 (not
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
997 (looking-at
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
998 "!\\|comment\\>\\|[a-z0-9_]*[ \t\f]*:[^-=]")))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
999 prev-cont continued)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1000 ;; if we are finished, find current line's indentation
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1001 (if temp
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1002 (setq indent (+ indent (current-indentation))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1003 ;; find next line with non-comment SIMULA text
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1004 ;; maybe indent extra if statement continues
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1005 (simula-skip-comment-backward)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1006 (setq continued
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1007 (and (not (bobp))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1008 (if (eq (char-syntax (preceding-char)) ?w)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1009 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1010 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1011 (not (looking-at
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1012 "begin\\|then\\|else\\|when\\|otherwise\\|do")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1013 (not (memq (preceding-char) '(?: ?\;))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1014 ;; if we the state of the continued-variable
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
1015 ;; changed, add indentation for continued statement
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1016 (if (or (and prev-cont (not continued))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1017 (and continued
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1018 (listp simula-continued-statement-offset)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1019 (setq indent
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1020 (+ indent
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1021 (if (listp simula-continued-statement-offset)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1022 (car simula-continued-statement-offset)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1023 simula-continued-statement-offset))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1024 ;; while ends if point is at beginning of line at loop test
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1025 (if (not temp)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1026 (setq start-line (save-excursion (beginning-of-line) (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1027 (beginning-of-line))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1028 ;;
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
1029 ;; return indentation
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1030 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1031 indent)))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1032
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1033
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1034 (defun simula-find-if ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1035 "Find starting IF of a IF-THEN[-ELSE[-IF-THEN...]] statement."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1036 (catch 'simula-out
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1037 (while t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1038 (if (and (simula-search-backward "\\<if\\>\\|;\\|\\<begin\\>"nil t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1039 (memq (following-char) '(?I ?i)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1040 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1041 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1042 ;; find out if this IF was really the start of the IF statement
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1043 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1044 (simula-skip-comment-backward)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1045 (if (and (eq (char-syntax (preceding-char)) ?w)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1046 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1047 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1048 (looking-at "else\\>")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1049 ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1050 (throw 'simula-out t)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1051 (if (not (looking-at "\\<if\\>"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1052 (error "Missing IF or misplaced BEGIN or ';' (can't find IF)")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1053 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1054 ;; we were at the starting IF in the first place..
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1055 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1056 (throw 'simula-out t))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1057
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1058
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1059 (defun simula-find-inspect ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1060 "Find INSPECT matching WHEN or OTHERWISE."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1061 (catch 'simula-out
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1062 (let ((level 0))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1063 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1064 ;; INSPECTs can be nested, have to find the corresponding one
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1065 ;;
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1066 (while t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1067 (if (and (simula-search-backward "\\<inspect\\>\\|\\<otherwise\\>\\|;"
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1068 nil t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1069 (/= (following-char) ?\;))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1070 (if (memq (following-char) '(?O ?o))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1071 (setq level (1+ level))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1072 (if (zerop level)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1073 (throw 'simula-out t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1074 (setq level (1- level))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1075 (error "Missing INSPECT or misplaced ';' (can't find INSPECT)"))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1076
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1077
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1078 (defun simula-find-do-match ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1079 "Find keyword matching DO: FOR, WHILE, INSPECT or WHEN"
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1080 (while (and (re-search-backward
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1081 "\\<\\(do\\|for\\|while\\|inspect\\|when\\|end\\|begin\\)\\>\\|;"
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1082 nil 'move)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1083 (simula-context)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1084 (if (and (looking-at "\\<\\(for\\|while\\|inspect\\|when\\)\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1085 (not (simula-context)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1086 () ;; found match
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1087 (error "No matching FOR, WHILE or INSPECT for DO, or misplaced ';'")))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1088
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1089
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1090 (defun simula-inside-parens ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1091 "Return position after `(' on line if inside parentheses, nil otherwise."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1092 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1093 (let ((parlevel 0))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1094 (catch 'simula-out
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1095 (while t
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1096 (if (re-search-backward "(\\|)\\|;" nil t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1097 (if (eq (simula-context) nil)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1098 ;; found something - check it out
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1099 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1100 ((eq (following-char) ?\;)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1101 (if (zerop parlevel)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1102 (throw 'simula-out nil)
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
1103 (error "Parenthesis mismatch or misplaced ';'")))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1104 ((eq (following-char) ?\()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1105 (if (zerop parlevel)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1106 (throw 'simula-out (1+ (current-column)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1107 (setq parlevel (1- parlevel))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1108 (t (setq parlevel (1+ parlevel))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1109 );; nothing - inside comment or string
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1110 ;; search failed
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1111 (throw 'simula-out nil)))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1112
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1113
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1114 (defun simula-goto-definition ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1115 "Goto point of definition of variable, procedure or class."
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1116 (interactive))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1117
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1118
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1119 (defun simula-expand-stdproc ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1120 (if (or (not simula-abbrev-stdproc) (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1121 (unexpand-abbrev)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1122 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1123 ((eq simula-abbrev-stdproc 'upcase) (upcase-word -1))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1124 ((eq simula-abbrev-stdproc 'downcase) (downcase-word -1))
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1125 ((eq simula-abbrev-stdproc 'capitalize) (capitalize-word -1))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1126 ((eq simula-abbrev-stdproc 'abbrev-table)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1127 ;; If not in lowercase, expansions are always capitalized.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1128 ;; We then want to replace with the exact expansion.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1129 (if (equal (symbol-name last-abbrev) last-abbrev-text)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1130 ()
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1131 (downcase-word -1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1132 (expand-abbrev))))))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1133
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1134
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1135 (defun simula-expand-keyword ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1136 (if (or (not simula-abbrev-keyword) (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1137 (unexpand-abbrev)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1138 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1139 ((eq simula-abbrev-keyword 'upcase) (upcase-word -1))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1140 ((eq simula-abbrev-keyword 'downcase) (downcase-word -1))
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1141 ((eq simula-abbrev-keyword 'capitalize) (capitalize-word -1))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1142 ((eq simula-abbrev-stdproc 'abbrev-table)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1143 (if (equal (symbol-name last-abbrev) last-abbrev-text)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1144 ()
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1145 (downcase-word -1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1146 (expand-abbrev))))))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1147
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1148
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1149 (defun simula-electric-keyword ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1150 "Expand SIMULA keyword. If it starts the line, reindent."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1151 ;; redisplay
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1152 (let ((show-char (eq this-command 'self-insert-command)))
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2315
diff changeset
1153 ;; If the abbrev expansion results in reindentation, the user may have
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1154 ;; to wait some time before the character he typed is displayed
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1155 ;; (the char causing the expansion is inserted AFTER the hook function
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1156 ;; is called). This is annoying in case of normal characters.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1157 ;; However, if the user pressed a key bound to newline, it is better
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1158 ;; to have the line inserted after the begin-end match.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1159 (if show-char
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1160 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1161 (insert-char last-command-char 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1162 (sit-for 0)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1163 (backward-char 1)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1164 (if (let ((where (simula-context))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1165 (case-fold-search t))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1166 (if where
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1167 (if (and (eq where 2) (eq (char-syntax (preceding-char)) ?w))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1168 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1169 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1170 (not (looking-at "end\\>"))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1171 (unexpand-abbrev)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1172 (cond
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1173 ((not simula-abbrev-keyword) (unexpand-abbrev))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1174 ((eq simula-abbrev-keyword 'upcase) (upcase-word -1))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1175 ((eq simula-abbrev-keyword 'downcase) (downcase-word -1))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1176 ((eq simula-abbrev-keyword 'capitalize) (capitalize-word -1)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1177 (let ((pos (- (point-max) (point)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1178 (case-fold-search t)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1179 null)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1180 (condition-case null
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1181 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1182 ;; check if the expanded word is on the beginning of the line.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1183 (if (and (eq (char-syntax (preceding-char)) ?w)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1184 (progn
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1185 (backward-word 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1186 (if (looking-at "end\\>")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1187 (save-excursion
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1188 (simula-backward-up-level 1)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1189 (if (pos-visible-in-window-p)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1190 (sit-for 1)
14330
35a18ea09b7b (simula-electric-keyword): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
1191 (message "Matches %s"
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1192 (buffer-substring
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1193 (point)
14330
35a18ea09b7b (simula-electric-keyword): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
1194 (+ (point) (window-width)))))))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1195 (skip-chars-backward " \t\f")
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1196 (bolp)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1197 (let ((indent (simula-calculate-indent)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1198 (if (eq indent (current-indentation))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1199 ()
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1200 (delete-horizontal-space)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1201 (indent-to indent)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1202 (skip-chars-forward " \t\f"))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1203 ;; check for END - blow whistles and ring bells
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1204
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1205 (goto-char (- (point-max) pos))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1206 (if show-char
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1207 (delete-char 1)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1208 (quit (goto-char (- (point-max) pos))))))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1209
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1210
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1211 (defun simula-search-backward (regexp &optional bound noerror)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1212 "Search backward from point for regular expression REGEXP, ignoring matches
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1213 found inside SIMULA comments, string literals, and BEGIN..END blocks.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1214 Set point to the end of the occurrence found, and return point.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1215 An optional second argument BOUND bounds the search, it is a buffer position.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1216 The match found must not extend after that position. Optional third argument
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1217 NOERROR, if t, means if fail just return nil (no error).
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1218 If not nil and not t, move to limit of search and return nil."
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1219 (let (begin end context (comb-regexp (concat regexp "\\|\\<end\\>"))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1220 match (start-point (point)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1221 (catch 'simula-backward
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1222 (while (re-search-backward comb-regexp bound 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1223 ;; We have a match, check SIMULA context at match-beginning
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1224 ;; to see if we are outside comments etc.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1225 ;; Set MATCH to t if we found a true match,
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1226 ;; set MATCH to 'BLOCK if we found a BEGIN..END block,
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1227 ;; else set MATCH to nil.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1228 (save-match-data
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1229 (setq context (simula-context))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1230 (cond
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1231 ((eq context nil)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1232 (setq match (if (looking-at regexp) t 'BLOCK)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1233 ;;; A comment-ending semicolon is part of the comment, and shouldn't match.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1234 ;;; ((eq context 0)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1235 ;;; (setq match (if (eq (following-char) ?\;) t nil)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1236 ((eq context 2)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1237 (setq match (if (and (looking-at regexp)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1238 (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>"))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1239 t
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1240 (if (looking-at "\\<end\\>") 'BLOCK nil))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1241 (t (setq match nil))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1242 ;; Exit if true match
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1243 (if (eq match t) (throw 'simula-backward (point)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1244 (if (eq match 'BLOCK)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1245 ;; We found the END of a block
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1246 (let ((level 0))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1247 (while (natnump level)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1248 (if (re-search-backward "\\<begin\\>\\|\\<end\\>" bound 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1249 (let ((context (simula-context)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1250 ;; We found a BEGIN -> decrease level count
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1251 (cond ((and (eq context nil)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1252 (memq (following-char) '(?b ?B)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1253 (setq level (1- level)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1254 ;; END -> increase level count
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1255 ((and (memq context '(nil 2))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1256 (memq (following-char) '(?e ?E)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1257 (setq level (1+ level)))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1258 ;; Block search failed. Action depends on noerror.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1259 (if (or (not noerror) (eq noerror t))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1260 (goto-char start-point))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1261 (if (not noerror)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1262 (signal 'search-failed (list regexp)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1263 (throw 'simula-backward nil))))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1264 ;; Search failed. Action depends on noerror.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1265 (if (or (not noerror) (eq noerror t))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1266 (goto-char start-point))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1267 (if noerror
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1268 nil
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1269 (signal 'search-failed (list regexp))))))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1270
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1271
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1272 (defun simula-search-forward (regexp &optional bound noerror)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1273 "Search forward from point for regular expression REGEXP, ignoring matches
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1274 found inside SIMULA comments, string literals, and BEGIN..END blocks.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1275 Set point to the end of the occurrence found, and return point.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1276 An optional second argument BOUND bounds the search, it is a buffer position.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1277 The match found must not extend after that position. Optional third argument
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1278 NOERROR, if t, means if fail just return nil (no error).
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1279 If not nil and not t, move to limit of search and return nil."
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1280 (let (begin end context (comb-regexp (concat regexp "\\|\\<begin\\>"))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1281 match (start-point (point)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1282 (catch 'simula-forward
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1283 (while (re-search-forward comb-regexp bound 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1284 ;; We have a match, check SIMULA context at match-beginning
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1285 ;; to see if we are outside comments.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1286 ;; Set MATCH to t if we found a true match,
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1287 ;; set MATCH to 'BLOCK if we found a BEGIN..END block,
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1288 ;; else set MATCH to nil.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1289 (save-match-data
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1290 (save-excursion
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1291 (goto-char (match-beginning 0))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1292 (setq context (simula-context))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1293 (cond
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1294 ((not context)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1295 (setq match (if (looking-at regexp) t 'BLOCK)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1296 ;;; A comment-ending semicolon is part of the comment, and shouldn't match.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1297 ;;; ((eq context 0)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1298 ;;; (setq match (if (eq (following-char) ?\;) t nil)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1299 ((eq context 2)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1300 (setq match (if (and (looking-at regexp)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1301 (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>")) t nil)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1302 (t (setq match nil)))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1303 ;; Exit if true match
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1304 (if (eq match t) (throw 'simula-forward (point)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1305 (if (eq match 'BLOCK)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1306 ;; We found the BEGINning of a block
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1307 (let ((level 0))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1308 (while (natnump level)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1309 (if (re-search-forward "\\<begin\\>\\|\\<end\\>" bound 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1310 (let ((context (simula-context)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1311 ;; We found a BEGIN -> increase level count
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1312 (cond ((eq context nil) (setq level (1+ level)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1313 ;; END -> decrease level count
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1314 ((and (eq context 2)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1315 ;; Don't match BEGIN inside END comment
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1316 (memq (preceding-char) '(?d ?D)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1317 (setq level (1- level)))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1318 ;; Block search failed. Action depends on noerror.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1319 (if (or (not noerror) (eq noerror t))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1320 (goto-char start-point))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1321 (if (not noerror)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1322 (signal 'search-failed (list regexp)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1323 (throw 'simula-forward nil))))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1324 ;; Search failed. Action depends on noerror.
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1325 (if (or (not noerror) (eq noerror t))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1326 (goto-char start-point))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1327 (if noerror
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1328 nil
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1329 (signal 'search-failed (list regexp))))))
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1330
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1331
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1332 (defun simula-install-standard-abbrevs ()
4664
b26469d5e812 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1333 "Define Simula keywords, procedures and classes in local abbrev table."
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1334 ;; procedure and class names are as of the SIMULA 87 standard.
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1335 (interactive)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1336 (mapcar (function (lambda (args)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1337 (apply 'define-abbrev simula-mode-abbrev-table args)))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1338 '(("abs" "Abs" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1339 ("accum" "Accum" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1340 ("activate" "ACTIVATE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1341 ("addepsilon" "AddEpsilon" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1342 ("after" "AFTER" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1343 ("and" "AND" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1344 ("arccos" "ArcCos" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1345 ("arcsin" "ArcSin" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1346 ("arctan" "ArcTan" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1347 ("arctan2" "ArcTan2" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1348 ("array" "ARRAY" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1349 ("at" "AT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1350 ("before" "BEFORE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1351 ("begin" "BEGIN" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1352 ("blanks" "Blanks" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1353 ("boolean" "BOOLEAN" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1354 ("breakoutimage" "BreakOutImage" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1355 ("bytefile" "ByteFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1356 ("call" "Call" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1357 ("cancel" "Cancel" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1358 ("cardinal" "Cardinal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1359 ("char" "Char" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1360 ("character" "CHARACTER" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1361 ("checkpoint" "CheckPoint" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1362 ("class" "CLASS" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1363 ("clear" "Clear" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1364 ("clocktime" "ClockTime" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1365 ("close" "Close" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1366 ("comment" "COMMENT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1367 ("constant" "Constant" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1368 ("copy" "Copy" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1369 ("cos" "Cos" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1370 ("cosh" "CosH" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1371 ("cotan" "CoTan" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1372 ("cputime" "CpuTime" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1373 ("current" "Current" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1374 ("datetime" "DateTime" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1375 ("decimalmark" "DecimalMark" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1376 ("delay" "DELAY" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1377 ("deleteimage" "DeleteImage" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1378 ("detach" "Detach" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1379 ("digit" "Digit" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1380 ("directbytefile" "DirectByteFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1381 ("directfile" "DirectFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1382 ("discrete" "Discrete" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1383 ("do" "DO" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1384 ("downcase" "Downcase" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1385 ("draw" "Draw" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1386 ("eject" "Eject" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1387 ("else" "ELSE" simula-electric-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1388 ("empty" "Empty" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1389 ("end" "END" simula-electric-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1390 ("endfile" "Endfile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1391 ("entier" "Entier" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1392 ("eq" "EQ" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1393 ("eqv" "EQV" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1394 ("erlang" "Erlang" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1395 ("error" "Error" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1396 ("evtime" "EvTime" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1397 ("exp" "Exp" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1398 ("external" "EXTERNAL" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1399 ("false" "FALSE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1400 ("field" "Field" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1401 ("file" "File" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1402 ("first" "First" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1403 ("follow" "Follow" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1404 ("for" "FOR" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1405 ("ge" "GE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1406 ("getchar" "GetChar" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1407 ("getfrac" "GetFrac" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1408 ("getint" "GetInt" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1409 ("getreal" "GetReal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1410 ("go" "GO" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1411 ("goto" "GOTO" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1412 ("gt" "GT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1413 ("head" "Head" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1414 ("hidden" "HIDDEN" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1415 ("histd" "HistD" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1416 ("histo" "Histo" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1417 ("hold" "Hold" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1418 ("idle" "Idle" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1419 ("if" "IF" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1420 ("image" "Image" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1421 ("imagefile" "ImageFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1422 ("imp" "IMP" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1423 ("in" "IN" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1424 ("inbyte" "InByte" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1425 ("inbytefile" "InByteFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1426 ("inchar" "InChar" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1427 ("infile" "InFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1428 ("infrac" "InFrac" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1429 ("inimage" "InImage" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1430 ("inint" "InInt" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1431 ("inner" "INNER" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1432 ("inreal" "InReal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1433 ("inrecord" "InRecord" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1434 ("inspect" "INSPECT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1435 ("integer" "INTEGER" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1436 ("intext" "InText" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1437 ("into" "Into" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1438 ("is" "IS" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1439 ("isochar" "ISOChar" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1440 ("isopen" "IsOpen" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1441 ("isorank" "ISORank" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1442 ("label" "LABEL" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1443 ("last" "Last" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1444 ("lastitem" "LastItem" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1445 ("lastloc" "LastLoc" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1446 ("le" "LE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1447 ("length" "Length" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1448 ("letter" "Letter" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1449 ("line" "Line" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1450 ("linear" "Linear" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1451 ("linesperpage" "LinesPerPage" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1452 ("link" "Link" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1453 ("linkage" "Linkage" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1454 ("ln" "Ln" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1455 ("locate" "Locate" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1456 ("location" "Location" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1457 ("lock" "Lock" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1458 ("locked" "Locked" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1459 ("log10" "Log10" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1460 ("long" "LONG" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1461 ("lowcase" "LowCase" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1462 ("lowerbound" "LowerBound" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1463 ("lowten" "LowTen" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1464 ("lt" "LT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1465 ("main" "Main" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1466 ("max" "Max" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1467 ("maxint" "MaxInt" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1468 ("maxlongreal" "MaxLongReal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1469 ("maxloc" "MaxLoc" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1470 ("maxrank" "MaxRank" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1471 ("maxreal" "MaxReal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1472 ("min" "Min" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1473 ("minint" "MinInt" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1474 ("minlongreal" "MinLongReal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1475 ("minrank" "MinRank" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1476 ("minreal" "MinReal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1477 ("mod" "Mod" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1478 ("more" "More" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1479 ("name" "NAME" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1480 ("ne" "NE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1481 ("negexp" "NegExp" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1482 ("new" "NEW" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1483 ("nextev" "NextEv" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1484 ("none" "NONE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1485 ("normal" "Normal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1486 ("not" "NOT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1487 ("notext" "NOTEXT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1488 ("open" "Open" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1489 ("or" "OR" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1490 ("otherwise" "OTHERWISE" simula-electric-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1491 ("out" "Out" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1492 ("outbyte" "OutByte" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1493 ("outbytefile" "OutByteFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1494 ("outchar" "OutChar" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1495 ("outfile" "OutFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1496 ("outfix" "OutFix" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1497 ("outfrac" "OutFrac" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1498 ("outimage" "OutImage" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1499 ("outint" "OutInt" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1500 ("outreal" "OutReal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1501 ("outrecord" "OutRecord" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1502 ("outtext" "OutText" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1503 ("page" "Page" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1504 ("passivate" "Passivate" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1505 ("poisson" "Poisson" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1506 ("pos" "Pos" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1507 ("precede" "Precede" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1508 ("pred" "Pred" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1509 ("prev" "Prev" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1510 ("printfile" "PrintFile" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1511 ("prior" "PRIOR" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1512 ("procedure" "PROCEDURE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1513 ("process" "Process" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1514 ("protected" "PROTECTED" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1515 ("putchar" "PutChar" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1516 ("putfix" "PutFix" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1517 ("putfrac" "PutFrac" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1518 ("putint" "PutInt" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1519 ("putreal" "PutReal" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1520 ("qua" "QUA" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1521 ("randint" "RandInt" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1522 ("rank" "Rank" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1523 ("reactivate" "REACTIVATE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1524 ("real" "REAL" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1525 ("ref" "REF" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1526 ("resume" "Resume" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1527 ("setaccess" "SetAccess" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1528 ("setpos" "SetPos" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1529 ("short" "SHORT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1530 ("sign" "Sign" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1531 ("simset" "SimSet" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1532 ("simulaid" "SimulaId" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1533 ("simulation" "Simulation" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1534 ("sin" "Sin" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1535 ("sinh" "SinH" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1536 ("sourceline" "SourceLine" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1537 ("spacing" "Spacing" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1538 ("sqrt" "Sqrt" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1539 ("start" "Start" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1540 ("step" "STEP" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1541 ("strip" "Strip" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1542 ("sub" "Sub" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1543 ("subepsilon" "SubEpsilon" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1544 ("suc" "Suc" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1545 ("switch" "SWITCH" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1546 ("sysin" "SysIn" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1547 ("sysout" "SysOut" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1548 ("tan" "Tan" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1549 ("tanh" "TanH" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1550 ("terminate_program" "Terminate_Program" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1551 ("terminated" "Terminated" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1552 ("text" "TEXT" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1553 ("then" "THEN" simula-electric-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1554 ("this" "THIS" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1555 ("time" "Time" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1556 ("to" "TO" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1557 ("true" "TRUE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1558 ("uniform" "Uniform" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1559 ("unlock" "Unlock" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1560 ("until" "UNTIL" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1561 ("upcase" "Upcase" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1562 ("upperbound" "UpperBound" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1563 ("value" "VALUE" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1564 ("virtual" "VIRTUAL" simula-expand-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1565 ("wait" "Wait" simula-expand-stdproc)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1566 ("when" "WHEN" simula-electric-keyword)
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1567 ("while" "WHILE" simula-expand-keyword))))
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1568
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1569 (if (and (fboundp 'hilit-set-mode-patterns)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1570 (boundp 'hilit-patterns-alist)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1571 (not (assoc 'simula-mode hilit-patterns-alist)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1572 (hilit-set-mode-patterns
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1573 'simula-mode
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1574 '(
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1575 ("^%\\([ \t\f].*\\)?$" nil comment)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1576 ("^%include\\>" nil include)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1577 ("\"[^\"\n]*\"\\|'.'\\|'![0-9]+!'" nil string)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1578 ("\\<\\(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)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1579 ("!\\|\\<COMMENT\\>" ";" comment))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1580 nil 'case-insensitive))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1581
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1582 (setq simula-find-comment-point -1
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1583 simula-find-comment-context nil)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1584
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1585 ;; function used by hilit19
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1586 (defun simula-find-next-comment-region (param)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1587 "Return region (start end) cons of comment after point, or NIL"
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1588 (let (start end)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1589 ;; This function is called repeatedly, check if point is
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1590 ;; where we left it in the last call
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1591 (if (not (eq simula-find-comment-point (point)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1592 (setq simula-find-comment-point (point)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1593 simula-find-comment-context (simula-context)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1594 ;; loop as long as we haven't found the end of a comment
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1595 (if (memq simula-find-comment-context '(0 1 2))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1596 (setq start (point))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1597 (if (re-search-forward "\\<end\\>\\|!\\|\"\\|'\\|^%\\|\\<comment\\>"
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1598 nil 'move)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1599 (let ((previous-char (preceding-char)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1600 (cond
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1601 ((memq previous-char '(?d ?D))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1602 (setq start (point)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1603 simula-find-comment-context 2))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1604 ((memq previous-char '(?t ?T ?\!))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1605 (setq start (point)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1606 simula-find-comment-context 0))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1607 ((eq previous-char ?%)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1608 (setq start (point)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1609 simula-find-comment-context 0))))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1610 ;; BUG: the following (0 2) branches don't take into account intermixing
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1611 ;; directive lines
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1612 (cond
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1613 ((eq simula-find-comment-context 0)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1614 (search-forward ";" nil 'move))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1615 ((eq simula-find-comment-context 1)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1616 (beginning-of-line 2))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1617 ((eq simula-find-comment-context 2)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1618 (re-search-forward ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>\\" (point-max) 'move)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1619 (if start
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1620 (setq end (point)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1621 ;; save point for later calls to this function
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1622 (setq simula-find-comment-point (if end (point) -1))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1623 (and end (cons start end))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1624
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1625 (if (not (fboundp 'save-match-data))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1626 (defmacro save-match-data (&rest body)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1627 "Execute the BODY forms, restoring the global value of the match data."
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1628 (let ((original (make-symbol "match-data")))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1629 (list
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1630 'let (list (list original '(match-data)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1631 (list 'unwind-protect
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1632 (cons 'progn body)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1633 (list 'store-match-data original))))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1634
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1635
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1636 ;; defuns for submitting bug reports
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1637
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1638 (defconst simula-mode-help-address "simula-mode@ifi.uio.no"
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1639 "Address accepting submission of simula-mode bug reports.")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1640
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1641 ;; get reporter-submit-bug-report when byte-compiling
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1642 (and (fboundp 'eval-when-compile)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1643 (eval-when-compile
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1644 (require 'reporter)))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1645
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1646 (defun simula-submit-bug-report ()
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1647 "Submit via mail a bug report on simula-mode."
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1648 (interactive)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1649 (and
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1650 (y-or-n-p "Do you want to submit a report on simula-mode? ")
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1651 (require 'reporter)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1652 (reporter-submit-bug-report
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1653 simula-mode-help-address
15054
df34d8bec5fc (simula-submit-bug-report): Use emacs-version.
Richard M. Stallman <rms@gnu.org>
parents: 15053
diff changeset
1654 (concat "simula-mode from Emacs " emacs-version)
15053
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1655 (list
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1656 ;; report only the vars that affect indentation
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1657 'simula-emacs-features
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1658 'simula-indent-level
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1659 'simula-substatement-offset
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1660 'simula-continued-statement-offset
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1661 'simula-label-offset
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1662 'simula-if-indent
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1663 'simula-inspect-indent
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1664 'simula-electric-indent
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1665 'simula-abbrev-keyword
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1666 'simula-abbrev-stdproc
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1667 'simula-abbrev-file
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1668 'simula-tab-always-indent
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1669 ))))
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1670
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1671 (provide 'simula-mode)
68d9a01cfb23 (simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents: 14330
diff changeset
1672
805
10f8af91ab47 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1673 ;;; simula.el ends here