annotate lisp/progmodes/modula2.el @ 112312:b9b02605a4af

* configure.in (AC_USE_SYSTEM_EXTENSIONS): Remove: gnulib does this.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 08 Jan 2011 23:40:01 -0800
parents b47e85affa59
children ef719132ddfa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
1 ;;; modula2.el --- Modula-2 editing support package
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
2
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38412
diff changeset
3 ;; Author: Michael Schmidt <michael@pbinfo.UUCP>
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
4 ;; Tom Perrine <Perrin@LOGICON.ARPA>
17996
be02a4e4cf47 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 17980
diff changeset
5 ;; Maintainer: FSF
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 791
diff changeset
6 ;; Keywords: languages
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
7
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 20960
diff changeset
8 ;; This file is part of GNU Emacs.
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 20960
diff changeset
9
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
10 ;; The authors distributed this without a copyright notice
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
11 ;; back in 1988, so it is in the public domain. The original included
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
12 ;; the following credit:
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
14 ;; Author Mick Jordan
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
15 ;; amended Peter Robinson
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
2308
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
17 ;;; Commentary:
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
18
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
19 ;; A major mode for editing Modula-2 code. It provides convenient abbrevs
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
20 ;; for Modula-2 keywords, knows about the standard layout rules, and supports
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
21 ;; a native compile command.
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
22
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
23 ;;; Code:
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
24
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
25 (require 'smie)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
26
20960
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
27 (defgroup modula2 nil
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
28 "Major mode for editing Modula-2 code."
66963
a11fdee52c05 Add :link (custom-group-link font-lock-faces) to defgroup.
Juri Linkov <juri@jurta.org>
parents: 63522
diff changeset
29 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
20960
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
30 :prefix "m2-"
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
31 :group 'languages)
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
32
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
33 ;;; Added by Tom Perrine (TEP)
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
34 (defvar m2-mode-syntax-table
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
35 (let ((table (make-syntax-table)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
36 (modify-syntax-entry ?\\ "\\" table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
37 (modify-syntax-entry ?/ ". 12" table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
38 (modify-syntax-entry ?\n ">" table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
39 (modify-syntax-entry ?\( "()1" table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
40 (modify-syntax-entry ?\) ")(4" table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
41 (modify-syntax-entry ?* ". 23nb" table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
42 (modify-syntax-entry ?+ "." table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
43 (modify-syntax-entry ?- "." table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
44 (modify-syntax-entry ?= "." table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
45 (modify-syntax-entry ?% "." table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
46 (modify-syntax-entry ?< "." table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
47 (modify-syntax-entry ?> "." table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
48 (modify-syntax-entry ?\' "\"" table)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
49 table)
231
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
50 "Syntax table in use in Modula-2 buffers.")
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
20960
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
52 (defcustom m2-compile-command "m2c"
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
53 "Command to compile Modula-2 programs."
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
54 :type 'string
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
55 :group 'modula2)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
20960
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
57 (defcustom m2-link-command "m2l"
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
58 "Command to link Modula-2 programs."
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
59 :type 'string
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
60 :group 'modula2)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
20960
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
62 (defcustom m2-link-name nil
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
63 "Name of the Modula-2 executable."
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
64 :type '(choice (const nil) string)
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
65 :group 'modula2)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
20960
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
67 (defcustom m2-end-comment-column 75
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
68 "*Column for aligning the end of a comment, in Modula-2."
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
69 :type 'integer
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
70 :group 'modula2)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;;; Added by TEP
110909
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 93975
diff changeset
73 (defvar m2-mode-map
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (let ((map (make-sparse-keymap)))
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
75 ;; FIXME: Many of those bindings are contrary to coding conventions.
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (define-key map "\C-cb" 'm2-begin)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (define-key map "\C-cc" 'm2-case)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (define-key map "\C-cd" 'm2-definition)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (define-key map "\C-ce" 'm2-else)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (define-key map "\C-cf" 'm2-for)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (define-key map "\C-ch" 'm2-header)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (define-key map "\C-ci" 'm2-if)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (define-key map "\C-cm" 'm2-module)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (define-key map "\C-cl" 'm2-loop)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (define-key map "\C-co" 'm2-or)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (define-key map "\C-cp" 'm2-procedure)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (define-key map "\C-c\C-w" 'm2-with)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (define-key map "\C-cr" 'm2-record)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (define-key map "\C-cs" 'm2-stdio)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (define-key map "\C-ct" 'm2-type)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (define-key map "\C-cu" 'm2-until)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (define-key map "\C-cv" 'm2-var)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (define-key map "\C-cw" 'm2-while)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (define-key map "\C-cx" 'm2-export)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (define-key map "\C-cy" 'm2-import)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (define-key map "\C-c{" 'm2-begin-comment)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (define-key map "\C-c}" 'm2-end-comment)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (define-key map "\C-c\C-z" 'suspend-emacs)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (define-key map "\C-c\C-v" 'm2-visit)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (define-key map "\C-c\C-t" 'm2-toggle)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (define-key map "\C-c\C-l" 'm2-link)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (define-key map "\C-c\C-c" 'm2-compile)
110909
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 93975
diff changeset
103 map)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 93975
diff changeset
104 "Keymap used in Modula-2 mode.")
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38412
diff changeset
106 (defcustom m2-indent 5
20960
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
107 "*This variable gives the indentation in Modula-2-Mode."
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
108 :type 'integer
2f9b7d0689a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20953
diff changeset
109 :group 'modula2)
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
110 (put 'm2-indent 'safe-local-variable
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
111 (lambda (v) (or (null v) (integerp v))))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
112
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
113 (defconst m2-smie-grammar
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
114 ;; An official definition can be found as "M2R10.pdf". This grammar does
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
115 ;; not really follow it, for lots of technical reasons, but it can still be
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
116 ;; useful to refer to it.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
117 (smie-prec2->grammar
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
118 (smie-merge-prec2s
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
119 (smie-bnf->prec2
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
120 '((range) (id) (epsilon)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
121 (fields (fields ";" fields) (ids ":" type))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
122 (proctype (id ":" type))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
123 (type ("RECORD" fields "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
124 ("POINTER" "TO" type)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
125 ;; The PROCEDURE type is indistinguishable from the beginning
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
126 ;; of a PROCEDURE definition, so we need a "PROCEDURE-type" to
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
127 ;; prevent SMIE from trying to find the matching END.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
128 ("PROCEDURE-type" proctype)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
129 ;; OF's right hand side should bind tighter than ; for array
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
130 ;; types, but should bind less tight than | which itself binds
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
131 ;; less tight than ;. So we use two distinct OFs.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
132 ("SET" "OF-type" id)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
133 ("ARRAY" range "OF-type" type))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
134 (args ("(" fargs ")"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
135 ;; VAR has lower precedence than ";" in formal args, but not
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
136 ;; in declarations. So we use "VAR-arg" for the formal arg case.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
137 (farg (ids ":" type) ("CONST-arg" farg) ("VAR-arg" farg))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
138 (fargs (fargs ";" fargs) (farg))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
139 ;; Handling of PROCEDURE in decls is problematic: we'd want
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
140 ;; TYPE/CONST/VAR/PROCEDURE's parent to be any previous
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
141 ;; CONST/TYPE/VAR/PROCEDURE, but we also want PROCEDURE to be an opener
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
142 ;; (so that its END has PROCEDURE as its parent). So instead, we treat
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
143 ;; the last ";" in those blocks as a separator (we call it ";-block").
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
144 ;; FIXME: This means that "TYPE \n VAR" is not indented properly
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
145 ;; because there's no ";-block" between the two.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
146 (decls (decls ";-block" decls)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
147 ("TYPE" typedecls) ("CONST" constdecls) ("VAR" vardecls)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
148 ;; END is usually a closer, but not quite for PROCEDURE...END.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
149 ;; We could use "END-proc" for the procedure case, but
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
150 ;; I preferred to just pretend PROCEDURE's END is the closer.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
151 ("PROCEDURE" decls "BEGIN" insts "END") ;END-proc id
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
152 ("PROCEDURE" decls "BEGIN" insts "FINALLY" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
153 ("PROCEDURE" decls "FORWARD")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
154 ;; ("IMPLEMENTATION" epsilon "MODULE" decls
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
155 ;; "BEGIN" insts "FINALLY" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
156 )
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
157 (typedecls (typedecls ";" typedecls) (id "=" type))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
158 (ids (ids "," ids))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
159 (vardecls (vardecls ";" vardecls) (ids ":" type))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
160 (constdecls (constdecls ";" constdecls) (id "=" exp))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
161 (exp (id "-anchor-" id) ("(" exp ")"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
162 (caselabel (caselabel ".." caselabel) (caselabel "," caselabel))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
163 ;; : for types binds tighter than ;, but the : for case labels binds
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
164 ;; less tight, so have to use two different :.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
165 (cases (cases "|" cases) (caselabel ":-case" insts))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
166 (forspec (exp "TO" exp))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
167 (insts (insts ";" insts)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
168 (id ":=" exp)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
169 ("CASE" exp "OF" cases "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
170 ("CASE" exp "OF" cases "ELSE" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
171 ("LOOP" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
172 ("WITH" exp "DO" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
173 ("REPEAT" insts "UNTIL" exp)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
174 ("WHILE" exp "DO" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
175 ("FOR" forspec "DO" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
176 ("IF" exp "THEN" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
177 ("IF" exp "THEN" insts "ELSE" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
178 ("IF" exp "THEN" insts
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
179 "ELSIF" exp "THEN" insts "ELSE" insts "END")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
180 ("IF" exp "THEN" insts
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
181 "ELSIF" exp "THEN" insts
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
182 "ELSIF" exp "THEN" insts "ELSE" insts "END"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
183 ;; This category is not used anywhere, but it adds some constraints that
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
184 ;; try to reduce the harm when an OF-type is not properly recognized.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
185 (error-OF ("ARRAY" range "OF" type) ("SET" "OF" id)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
186 '((assoc ";")) '((assoc ";-block")) '((assoc "|"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
187 ;; For case labels.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
188 '((assoc ",") (assoc ".."))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
189 ;; '((assoc "TYPE" "CONST" "VAR" "PROCEDURE"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
190 )
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
191 (smie-precs->prec2
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
192 '((nonassoc "-anchor-" "=")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
193 (nonassoc "<" "<=" ">=" ">" "<>" "#" "IN")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
194 (assoc "OR" "+" "-")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
195 (assoc "AND" "MOD" "DIV" "REM" "*" "/" "&")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
196 (nonassoc "NOT" "~")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
197 (left "." "^")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
198 ))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
199 )))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
200
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
201 (defun m2-smie-refine-colon ()
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
202 (let ((res nil))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
203 (while (not res)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
204 (let ((tok (smie-default-backward-token)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
205 (cond
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
206 ((zerop (length tok))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
207 (let ((forward-sexp-function nil))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
208 (condition-case nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
209 (forward-sexp -1)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
210 (scan-error (setq res ":")))))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
211 ((member tok '("|" "OF" "..")) (setq res ":-case"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
212 ((member tok '(":" "END" ";" "BEGIN" "VAR" "RECORD" "PROCEDURE"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
213 (setq res ":")))))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
214 res))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
215
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
216 (defun m2-smie-refine-of ()
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
217 (let ((tok (smie-default-backward-token)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
218 (when (zerop (length tok))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
219 (let ((forward-sexp-function nil))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
220 (condition-case nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
221 (backward-sexp 1)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
222 (scan-error nil))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
223 (setq tok (smie-default-backward-token))))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
224 (if (member tok '("ARRAY" "SET"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
225 "OF-type" "OF")))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
226
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
227 (defun m2-smie-refine-semi ()
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
228 (forward-comment (point-max))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
229 (if (looking-at (regexp-opt '("PROCEDURE" "TYPE" "VAR" "CONST" "BEGIN")))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
230 ";-block" ";"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
231
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
232 ;; FIXME: "^." are two tokens, not one.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
233 (defun m2-smie-forward-token ()
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
234 (pcase (smie-default-forward-token)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
235 (`"VAR" (if (zerop (car (syntax-ppss))) "VAR" "VAR-arg"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
236 (`"CONST" (if (zerop (car (syntax-ppss))) "CONST" "CONST-arg"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
237 (`";" (save-excursion (m2-smie-refine-semi)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
238 (`"OF" (save-excursion (forward-char -2) (m2-smie-refine-of)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
239 (`":" (save-excursion (forward-char -1) (m2-smie-refine-colon)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
240 ;; (`"END" (if (and (looking-at "[ \t\n]*\\(\\(?:\\sw\\|\\s_\\)+\\)")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
241 ;; (not (assoc (match-string 1) m2-smie-grammar)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
242 ;; "END-proc" "END"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
243 (token token)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
244
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
245 (defun m2-smie-backward-token ()
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
246 (pcase (smie-default-backward-token)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
247 (`"VAR" (if (zerop (car (syntax-ppss))) "VAR" "VAR-arg"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
248 (`"CONST" (if (zerop (car (syntax-ppss))) "CONST" "CONST-arg"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
249 (`";" (save-excursion (forward-char 1) (m2-smie-refine-semi)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
250 (`"OF" (save-excursion (m2-smie-refine-of)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
251 (`":" (save-excursion (m2-smie-refine-colon)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
252 ;; (`"END" (if (and (looking-at "\\sw+[ \t\n]+\\(\\(?:\\sw\\|\\s_\\)+\\)")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
253 ;; (not (assoc (match-string 1) m2-smie-grammar)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
254 ;; "END-proc" "END"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
255 (token token)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
256
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
257 (defun m2-smie-rules (kind token)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
258 ;; FIXME: Apparently, the usual indentation convention is something like:
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
259 ;;
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
260 ;; TYPE t1 = bar;
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
261 ;; VAR x : INTEGER;
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
262 ;; PROCEDURE f ();
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
263 ;; TYPE t2 = foo;
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
264 ;; PROCEDURE g ();
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
265 ;; BEGIN blabla END;
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
266 ;; VAR y : type;
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
267 ;; BEGIN blibli END
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
268 ;;
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
269 ;; This is inconsistent with the actual structure of the code in 2 ways:
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
270 ;; - The inner VAR/TYPE are indented just like the outer VAR/TYPE.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
271 ;; - The inner PROCEDURE is not aligned with its VAR/TYPE siblings.
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
272 (pcase (cons kind token)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
273 (`(:elem . basic) m2-indent)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
274 (`(:after . ":=") (or m2-indent smie-indent-basic))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
275 (`(:after . ,(or `"CONST" `"VAR" `"TYPE"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
276 (or m2-indent smie-indent-basic))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
277 ;; (`(:before . ,(or `"VAR" `"TYPE" `"CONST"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
278 ;; (if (smie-rule-parent-p "PROCEDURE") 0))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
279 (`(:after . ";-block")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
280 (if (smie-rule-parent-p "PROCEDURE")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
281 (smie-rule-parent (or m2-indent smie-indent-basic))))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
282 (`(:before . "|") (smie-rule-separator kind))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
283 ))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38412
diff changeset
284
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
285 ;;;###autoload
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
286 (defalias 'modula-2-mode 'm2-mode)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
287 ;;;###autoload
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
288 (define-derived-mode m2-mode prog-mode "Modula-2"
231
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
289 "This is a mode intended to support program development in Modula-2.
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
290 All control constructs of Modula-2 can be reached by typing C-c
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
291 followed by the first character of the construct.
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
292 \\<m2-mode-map>
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
293 \\[m2-begin] begin \\[m2-case] case
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
294 \\[m2-definition] definition \\[m2-else] else
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
295 \\[m2-for] for \\[m2-header] header
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
296 \\[m2-if] if \\[m2-module] module
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
297 \\[m2-loop] loop \\[m2-or] or
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
298 \\[m2-procedure] procedure Control-c Control-w with
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
299 \\[m2-record] record \\[m2-stdio] stdio
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
300 \\[m2-type] type \\[m2-until] until
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
301 \\[m2-var] var \\[m2-while] while
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
302 \\[m2-export] export \\[m2-import] import
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
303 \\[m2-begin-comment] begin-comment \\[m2-end-comment] end-comment
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
304 \\[suspend-emacs] suspend Emacs \\[m2-toggle] toggle
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
305 \\[m2-compile] compile \\[m2-next-error] next-error
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
306 \\[m2-link] link
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
231
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
308 `m2-indent' controls the number of spaces for each indentation.
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
309 `m2-compile-command' holds the command to compile a Modula-2 program.
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
310 `m2-link-command' holds the command to link a Modula-2 program."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
311 (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
312 (set (make-local-variable 'paragraph-separate) paragraph-start)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
313 (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
314 (set (make-local-variable 'comment-start) "(* ")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
315 (set (make-local-variable 'comment-end) " *)")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
316 (set (make-local-variable 'comment-start-skip) "\\(?:(\\*+\\|//+\\) *")
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
317 (set (make-local-variable 'parse-sexp-ignore-comments) t)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
318 (set (make-local-variable 'font-lock-defaults)
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
319 '((m3-font-lock-keywords
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
320 m3-font-lock-keywords-1 m3-font-lock-keywords-2)
18333
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
321 nil nil ((?_ . "w") (?. . "w") (?< . ". 1") (?> . ". 4")) nil
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
322 ))
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
323 (smie-setup m2-smie-grammar #'m2-smie-rules
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
324 :forward-token #'m2-smie-forward-token
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
325 :backward-token #'m2-smie-backward-token))
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
326
18333
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
327 ;; Regexps written with help from Ron Forrester <ron@orcad.com>
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
328 ;; and Spencer Allain <sallain@teknowledge.com>.
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
329 (defconst m3-font-lock-keywords-1
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
330 '(
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
331 ;;
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
332 ;; Module definitions.
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
333 ("\\<\\(INTERFACE\\|MODULE\\|PROCEDURE\\)\\>[ \t]*\\(\\sw+\\)?"
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
334 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
335 ;;
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
336 ;; Import directives.
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
337 ("\\<\\(EXPORTS\\|FROM\\|IMPORT\\)\\>"
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
338 (1 font-lock-keyword-face)
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
339 (font-lock-match-c-style-declaration-item-and-skip-to-next
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
340 nil (goto-char (match-end 0))
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 18383
diff changeset
341 (1 font-lock-constant-face)))
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
342 ;;
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
343 ;; Pragmas as warnings.
18333
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
344 ;; Spencer Allain <sallain@teknowledge.com> says do them as comments...
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
345 ;; ("<\\*.*\\*>" . font-lock-warning-face)
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
346 ;; ... but instead we fontify the first word.
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
347 ("<\\*[ \t]*\\(\\sw+\\)" 1 font-lock-warning-face prepend)
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
348 )
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
349 "Subdued level highlighting for Modula-3 modes.")
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
350
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
351 (defconst m3-font-lock-keywords-2
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
352 (append m3-font-lock-keywords-1
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
353 (eval-when-compile
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
354 (let ((m3-types
18333
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
355 (regexp-opt
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
356 '("INTEGER" "BITS" "BOOLEAN" "CARDINAL" "CHAR" "FLOAT" "REAL"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
357 "LONGREAL" "REFANY" "ADDRESS" "ARRAY" "SET" "TEXT"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
358 "MUTEX" "ROOT" "EXTENDED")))
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
359 (m3-keywords
18333
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
360 (regexp-opt
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
361 '("AND" "ANY" "AS" "BEGIN" "BRANDED" "BY" "CASE" "CONST" "DIV"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
362 "DO" "ELSE" "ELSIF" "EVAL" "EXCEPT" "EXIT" "FINALLY"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
363 "FOR" "GENERIC" "IF" "IN" "LOCK" "LOOP" "METHODS" "MOD" "NOT"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
364 "OBJECT" "OF" "OR" "OVERRIDES" "READONLY" "RECORD" "REF"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
365 "REPEAT" "RETURN" "REVEAL" "THEN" "TO" "TRY"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
366 "TYPE" "TYPECASE" "UNSAFE" "UNTIL" "UNTRACED" "VAR" "VALUE"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
367 "WHILE" "WITH")))
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
368 (m3-builtins
18333
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
369 (regexp-opt
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
370 '("ABS" "ADR" "ADRSIZE" "BITSIZE" "BYTESIZE" "CEILING"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
371 "DEC" "DISPOSE" "FIRST" "FLOOR" "INC" "ISTYPE" "LAST"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
372 "LOOPHOLE" "MAX" "MIN" "NARROW" "NEW" "NUMBER" "ORD"
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
373 "ROUND" "SUBARRAY" "TRUNC" "TYPECODE" "VAL")))
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
374 )
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
375 (list
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
376 ;;
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
377 ;; Keywords except those fontified elsewhere.
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
378 (concat "\\<\\(" m3-keywords "\\)\\>")
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
379 ;;
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
380 ;; Builtins.
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
381 (cons (concat "\\<\\(" m3-builtins "\\)\\>") 'font-lock-builtin-face)
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
382 ;;
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
383 ;; Type names.
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
384 (cons (concat "\\<\\(" m3-types "\\)\\>") 'font-lock-type-face)
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
385 ;;
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
386 ;; Fontify tokens as function names.
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
387 '("\\<\\(END\\|EXCEPTION\\|RAISES?\\)\\>[ \t{]*"
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
388 (1 font-lock-keyword-face)
18333
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
389 (font-lock-match-c-style-declaration-item-and-skip-to-next
ff12edf576bf Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents: 17996
diff changeset
390 nil (goto-char (match-end 0))
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
391 (1 font-lock-function-name-face)))
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
392 ;;
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
393 ;; Fontify constants as references.
20953
f3f9df46d008 Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents: 18383
diff changeset
394 '("\\<\\(FALSE\\|NIL\\|NULL\\|TRUE\\)\\>" . font-lock-constant-face)
17496
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
395 ))))
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
396 "Gaudy level highlighting for Modula-3 modes.")
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
397
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
398 (defvar m3-font-lock-keywords m3-font-lock-keywords-1
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
399 "Default expressions to highlight in Modula-3 modes.")
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
400
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
401 ;; We don't actually have different keywords for Modula-2. Volunteers?
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
402 (defconst m2-font-lock-keywords-1 m3-font-lock-keywords-1
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
403 "Subdued level highlighting for Modula-2 modes.")
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
404
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
405 (defconst m2-font-lock-keywords-2 m3-font-lock-keywords-2
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
406 "Gaudy level highlighting for Modula-2 modes.")
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
407
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
408 (defvar m2-font-lock-keywords m2-font-lock-keywords-1
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
409 "Default expressions to highlight in Modula-2 modes.")
4cb9ccf6b6b8 Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 13997
diff changeset
410
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
411 (define-skeleton m2-begin
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
412 "Insert a BEGIN keyword and indent for the next line."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
413 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
414 \n "BEGIN" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
416 (define-skeleton m2-case
13997
a56ed7721b43 (m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 12953
diff changeset
417 "Build skeleton CASE statement, prompting for the <expression>."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
418 "Case-Expression: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
419 \n "CASE " str " OF" > \n _ \n "END (* " str " *);" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
421 (define-skeleton m2-definition
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 "Build skeleton DEFINITION MODULE, prompting for the <module name>."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
423 "Name: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
424 \n "DEFINITION MODULE " str ";" > \n \n _ \n \n "END " str "." > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
426 (define-skeleton m2-else
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 "Insert ELSE keyword and indent for next line."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
428 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
429 \n "ELSE" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
431 (define-skeleton m2-for
13997
a56ed7721b43 (m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 12953
diff changeset
432 "Build skeleton FOR loop statement, prompting for the loop parameters."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
433 "Loop Initializer: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
434 ;; FIXME: this seems to be lacking a "<var> :=".
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
435 \n "FOR " str " TO "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
436 (setq v1 (read-string "Limit: "))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
437 (let ((by (read-string "Step: ")))
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (if (not (string-equal by ""))
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
439 (concat " BY " by)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
440 " DO" > \n _ \n "END (* for " str " to " v1 " *);" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
442 (define-skeleton m2-header
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 "Insert a comment block containing the module title, author, etc."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
444 "Title: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
445 "(*\n Title: \t" str
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
446 "\n Created: \t" (current-time-string)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
447 "\n Author: \t" (user-full-name) " <" user-mail-address ">\n"
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
448 "*)" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
450 (define-skeleton m2-if
13997
a56ed7721b43 (m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 12953
diff changeset
451 "Insert skeleton IF statement, prompting for <boolean-expression>."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
452 "<boolean-expression>: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
453 \n "IF " str " THEN" > \n _ \n "END (* if " str " *);" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
455 (define-skeleton m2-loop
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 "Build skeleton LOOP (with END)."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
457 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
458 \n "LOOP" > \n _ \n "END (* loop *);" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
460 (define-skeleton m2-module
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 "Build skeleton IMPLEMENTATION MODULE, prompting for <module-name>."
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
462 "Name: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
463 \n "IMPLEMENTATION MODULE " str ";" > \n \n
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
464 '(m2-header)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
465 '(m2-type) \n
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
466 '(m2-var) \n _ \n \n
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
467 '(m2-begin)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
468 '(m2-begin-comment)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
469 " Module " str " Initialisation Code "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
470 '(m2-end-comment)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
471 \n \n "END " str "." > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
473 (define-skeleton m2-or
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
474 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
475 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
476 \n "|" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
478 (define-skeleton m2-procedure
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
479 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
480 "Name: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
481 \n "PROCEDURE " str " (" (read-string "Arguments: ") ")"
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
482 (let ((args (read-string "Result Type: ")))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
483 (if (not (equal args "")) (concat " : " args)))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
484 ";" > \n "BEGIN" > \n _ \n "END " str ";" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
486 (define-skeleton m2-with
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
487 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
488 "Record-Type: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
489 \n "WITH " str " DO" > \n _ \n "END (* with " str " *);" > \n)
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
490
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
491 (define-skeleton m2-record
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
492 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
493 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
494 \n "RECORD" > \n _ \n "END (* record *);" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
496 (define-skeleton m2-stdio
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
497 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
498 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
499 \n "FROM TextIO IMPORT"
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
500 > \n "WriteCHAR, ReadCHAR, WriteINTEGER, ReadINTEGER,"
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
501 > \n "WriteCARDINAL, ReadCARDINAL, WriteBOOLEAN, ReadBOOLEAN,"
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
502 > \n "WriteREAL, ReadREAL, WriteBITSET, ReadBITSET,"
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
503 > \n "WriteBasedCARDINAL, ReadBasedCARDINAL, WriteChars, ReadChars,"
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
504 > \n "WriteString, ReadString, WhiteSpace, EndOfLine;"
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
505 > \n \n "FROM SysStreams IMPORT sysIn, sysOut, sysErr;" > \n \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
507 (define-skeleton m2-type
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
508 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
509 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
510 \n "TYPE" > \n ";" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
512 (define-skeleton m2-until
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
513 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
514 "<boolean-expression>: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
515 \n "REPEAT" > \n _ \n "UNTIL " str ";" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
517 (define-skeleton m2-var
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
518 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
519 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
520 \n "VAR" > \n ";" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
522 (define-skeleton m2-while
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
523 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
524 "<boolean-expression>: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
525 \n "WHILE " str " DO" > \n _ \n "END (* while " str " *);" > \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
527 (define-skeleton m2-export
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
528 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
529 nil
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
530 \n "EXPORT QUALIFIED " > _ \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
532 (define-skeleton m2-import
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
533 "No doc."
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
534 "Module: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
535 \n "FROM " str " IMPORT " > _ \n)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (defun m2-begin-comment ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (if (not (bolp))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (indent-to comment-column 0))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 (insert "(* "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (defun m2-end-comment ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (if (not (bolp))
17532
5c77f95c5dd1 (m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 17496
diff changeset
546 (indent-to m2-end-comment-column))
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (insert "*)"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (defun m2-compile ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (interactive)
17532
5c77f95c5dd1 (m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 17496
diff changeset
551 (compile (concat m2-compile-command " " (buffer-name))))
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (defun m2-link ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (interactive)
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
555 (compile (concat m2-link-command " "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
556 (or m2-link-name
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
557 (setq m2-link-name (read-string "Name of executable: "
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
558 (buffer-name)))))))
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559
12953
e0db27f18a43 (m2-execute-monitor-command): Renamed from execute-monitor-command.
Richard M. Stallman <rms@gnu.org>
parents: 10885
diff changeset
560 (defun m2-execute-monitor-command (command)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (let* ((shell shell-file-name)
111498
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
562 ;; (csh (equal (file-name-nondirectory shell) "csh"))
d9d916379aff * lisp/progmodes/modula2.el: Use SMIE and skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110909
diff changeset
563 )
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (call-process shell nil t t "-cf" (concat "exec " command))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (defun m2-visit ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (let ((deffile nil)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (modfile nil)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 modulename)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (save-excursion
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (setq modulename
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (read-string "Module name: "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (switch-to-buffer "*Command Execution*")
12953
e0db27f18a43 (m2-execute-monitor-command): Renamed from execute-monitor-command.
Richard M. Stallman <rms@gnu.org>
parents: 10885
diff changeset
575 (m2-execute-monitor-command (concat "m2whereis " modulename))
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (goto-char (point-min))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (condition-case ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (progn (re-search-forward "\\(.*\\.def\\) *$")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (setq deffile (buffer-substring (match-beginning 1)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (match-end 1))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (search-failed ()))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (condition-case ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (progn (re-search-forward "\\(.*\\.mod\\) *$")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (setq modfile (buffer-substring (match-beginning 1)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (match-end 1))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (search-failed ()))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (if (not (or deffile modfile))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (error "I can find neither definition nor implementation of %s"
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 modulename)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (cond (deffile
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (find-file deffile)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (if modfile
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (save-excursion
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (find-file modfile))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (modfile
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (find-file modfile)))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (defun m2-toggle ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 "Toggle between .mod and .def files for the module."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (cond ((string-equal (substring (buffer-name) -4) ".def")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (find-file-other-window
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (concat (substring (buffer-name) 0 -4) ".mod")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 ((string-equal (substring (buffer-name) -4) ".mod")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (find-file-other-window
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (concat (substring (buffer-name) 0 -4) ".def")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 ((string-equal (substring (buffer-name) -3) ".mi")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (find-file-other-window
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (concat (substring (buffer-name) 0 -3) ".md")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 ((string-equal (substring (buffer-name) -3) ".md")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (find-file-other-window
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (concat (substring (buffer-name) 0 -3) ".mi")))))
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
613
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 18333
diff changeset
614 (provide 'modula2)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 18333
diff changeset
615
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78683
diff changeset
616 ;; arch-tag: a21df1cb-5ece-4709-9219-1e7cd2d85d90
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
617 ;;; modula2.el ends here