annotate lisp/progmodes/simula.el @ 52896:f992824e67f0

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