1992-07-16 21:46:36 +00:00
|
|
|
|
;;; simula.el --- SIMULA 87 code editing commands for Emacs
|
|
|
|
|
|
2014-01-01 07:43:34 +00:00
|
|
|
|
;; Copyright (C) 1992, 1994, 1996, 2001-2014 Free Software Foundation,
|
2013-01-01 09:11:05 +00:00
|
|
|
|
;; Inc.
|
1992-07-22 02:58:48 +00:00
|
|
|
|
|
2008-12-19 05:24:35 +00:00
|
|
|
|
;; Author: Hans Henrik Eriksen <hhe@ifi.uio.no>
|
|
|
|
|
;; Maintainer: simula-mode@ifi.uio.no
|
|
|
|
|
;; (above email addresses invalid as of April 2008)
|
1992-07-17 07:10:46 +00:00
|
|
|
|
;; Adapted-By: ESR
|
|
|
|
|
;; Keywords: languages
|
|
|
|
|
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1992-07-17 07:10:46 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
1993-03-22 16:53:22 +00:00
|
|
|
|
;; A major mode for editing the Simula language. It knows about Simula
|
|
|
|
|
;; syntax and standard indentation commands. It also provides convenient
|
|
|
|
|
;; abbrevs for Simula keywords.
|
|
|
|
|
;;
|
|
|
|
|
;; Hans Henrik Eriksen (the author) may be reached at:
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; Institutt for informatikk,
|
|
|
|
|
;; Universitetet i Oslo
|
|
|
|
|
|
1992-07-17 07:10:46 +00:00
|
|
|
|
;;; Code:
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defgroup simula nil
|
|
|
|
|
"Major mode for editing Simula code."
|
2005-11-17 07:40:11 +00:00
|
|
|
|
:link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
|
1998-02-22 19:51:45 +00:00
|
|
|
|
:prefix "simula-"
|
|
|
|
|
:group 'languages)
|
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-tab-always-indent-default nil
|
|
|
|
|
"Non-nil means TAB in SIMULA mode should always reindent the current line.
|
|
|
|
|
Otherwise TAB indents only when point is within
|
|
|
|
|
the run of whitespace at the beginning of the line.")
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-tab-always-indent simula-tab-always-indent-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Non-nil means TAB in SIMULA mode should always reindent the current line.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
Otherwise TAB indents only when point is within
|
1998-02-22 19:51:45 +00:00
|
|
|
|
the run of whitespace at the beginning of the line."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-indent-level-default 3
|
|
|
|
|
"Indentation of SIMULA statements with respect to containing block.")
|
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-indent-level simula-indent-level-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Indentation of SIMULA statements with respect to containing block."
|
1998-02-22 19:51:45 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'simula)
|
|
|
|
|
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-substatement-offset-default 3
|
|
|
|
|
"Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.")
|
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-substatement-offset simula-substatement-offset-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE."
|
1998-02-22 19:51:45 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-continued-statement-offset-default 3
|
|
|
|
|
"Extra indentation for lines not starting a statement or substatement.
|
|
|
|
|
If value is a list, each line in a multipleline continued statement
|
|
|
|
|
will have the car of the list extra indentation with respect to
|
|
|
|
|
the previous line of the statement.")
|
|
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(defcustom simula-continued-statement-offset
|
1998-02-22 19:51:45 +00:00
|
|
|
|
simula-continued-statement-offset-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Extra indentation for lines not starting a statement or substatement.
|
1992-07-16 21:46:36 +00:00
|
|
|
|
If value is a list, each line in a multipleline continued statement
|
|
|
|
|
will have the car of the list extra indentation with respect to
|
1998-02-22 19:51:45 +00:00
|
|
|
|
the previous line of the statement."
|
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-label-offset-default -4711
|
|
|
|
|
"Offset of SIMULA label lines relative to usual indentation.")
|
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-label-offset simula-label-offset-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Offset of SIMULA label lines relative to usual indentation."
|
1998-02-22 19:51:45 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-if-indent-default '(0 . 0)
|
|
|
|
|
"Extra indentation of THEN and ELSE with respect to the starting IF.
|
|
|
|
|
Value is a cons cell, the car is extra THEN indentation and the cdr
|
|
|
|
|
extra ELSE indentation. IF after ELSE is indented as the starting IF.")
|
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-if-indent simula-if-indent-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Extra indentation of THEN and ELSE with respect to the starting IF.
|
1993-06-09 11:59:12 +00:00
|
|
|
|
Value is a cons cell, the car is extra THEN indentation and the cdr
|
1998-02-22 19:51:45 +00:00
|
|
|
|
extra ELSE indentation. IF after ELSE is indented as the starting IF."
|
|
|
|
|
:type '(cons integer integer)
|
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-inspect-indent-default '(0 . 0)
|
|
|
|
|
"Extra indentation of WHEN and OTHERWISE with respect to the INSPECT.
|
|
|
|
|
Value is a cons cell, the car is extra WHEN indentation
|
|
|
|
|
and the cdr extra OTHERWISE indentation.")
|
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-inspect-indent simula-inspect-indent-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Extra indentation of WHEN and OTHERWISE with respect to the INSPECT.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
Value is a cons cell, the car is extra WHEN indentation
|
1998-02-22 19:51:45 +00:00
|
|
|
|
and the cdr extra OTHERWISE indentation."
|
|
|
|
|
:type '(cons integer integer)
|
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-electric-indent-default nil
|
|
|
|
|
"Non-nil means `simula-indent-line' function may reindent previous line.")
|
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-electric-indent simula-electric-indent-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Non-nil means `simula-indent-line' function may reindent previous line."
|
1998-02-22 19:51:45 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defconst simula-abbrev-keyword-default 'upcase
|
|
|
|
|
"Specify how to convert case for SIMULA keywords.
|
|
|
|
|
Value is one of the symbols `upcase', `downcase', `capitalize',
|
2002-08-24 14:26:06 +00:00
|
|
|
|
\(as in) `abbrev-table' or nil if they should not be changed.")
|
1996-04-21 01:39:51 +00:00
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-abbrev-keyword simula-abbrev-keyword-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Specify how to convert case for SIMULA keywords.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
Value is one of the symbols `upcase', `downcase', `capitalize',
|
2002-08-24 14:26:06 +00:00
|
|
|
|
\(as in) `abbrev-table' or nil if they should not be changed."
|
1998-02-22 19:51:45 +00:00
|
|
|
|
:type '(choice (const upcase) (const downcase) (const capitalize)(const nil))
|
|
|
|
|
:group 'simula)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
|
|
|
|
|
(defconst simula-abbrev-stdproc-default 'abbrev-table
|
|
|
|
|
"Specify how to convert case for standard SIMULA procedure and class names.
|
|
|
|
|
Value is one of the symbols `upcase', `downcase', `capitalize',
|
2002-08-24 14:26:06 +00:00
|
|
|
|
\(as in) `abbrev-table', or nil if they should not be changed.")
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-abbrev-stdproc simula-abbrev-stdproc-default
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"Specify how to convert case for standard SIMULA procedure and class names.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
Value is one of the symbols `upcase', `downcase', `capitalize',
|
2002-08-24 14:26:06 +00:00
|
|
|
|
\(as in) `abbrev-table', or nil if they should not be changed."
|
1998-02-22 19:51:45 +00:00
|
|
|
|
:type '(choice (const upcase) (const downcase) (const capitalize)
|
2003-02-11 21:19:36 +00:00
|
|
|
|
(const abbrev-table) (const nil))
|
1998-02-22 19:51:45 +00:00
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1998-02-22 19:51:45 +00:00
|
|
|
|
(defcustom simula-abbrev-file nil
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"File with extra abbrev definitions for use in SIMULA mode.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
These are used together with the standard abbrev definitions for SIMULA.
|
|
|
|
|
Please note that the standard definitions are required
|
1998-02-22 19:51:45 +00:00
|
|
|
|
for SIMULA mode to function correctly."
|
|
|
|
|
:type '(choice file (const nil))
|
|
|
|
|
:group 'simula)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
|
|
|
|
(defvar simula-mode-syntax-table nil
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Syntax table in SIMULA mode buffers.")
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
New syntax-propertize functionality.
* lisp/font-lock.el (font-lock-syntactic-keywords): Make obsolete.
(font-lock-fontify-syntactic-keywords-region): Move handling of
font-lock-syntactically-fontified to...
(font-lock-default-fontify-region): ...here.
Let syntax-propertize-function take precedence.
(font-lock-fontify-syntactically-region): Cal syntax-propertize.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt-depth): Skip named groups.
* lisp/emacs-lisp/syntax.el (syntax-propertize-function)
(syntax-propertize-chunk-size, syntax-propertize--done)
(syntax-propertize-extend-region-functions): New vars.
(syntax-propertize-wholelines, syntax-propertize-multiline)
(syntax-propertize--shift-groups, syntax-propertize-via-font-lock)
(syntax-propertize): New functions.
(syntax-propertize-rules): New macro.
(syntax-ppss-flush-cache): Set syntax-propertize--done.
(syntax-ppss): Call syntax-propertize.
* lisp/progmodes/ada-mode.el (ada-set-syntax-table-properties)
(ada-after-change-function, ada-initialize-syntax-table-properties)
(ada-handle-syntax-table-properties): Only define when
syntax-propertize is not available.
(ada-mode): Use syntax-propertize-function.
* lisp/progmodes/autoconf.el (autoconf-mode):
Use syntax-propertize-function.
(autoconf-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cfengine.el (cfengine-mode):
Use syntax-propertize-function.
(cfengine-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cperl-mode.el (cperl-mode): Use syntax-propertize-function.
* lisp/progmodes/fortran.el (fortran-mode): Use syntax-propertize-function.
(fortran--font-lock-syntactic-keywords): New var.
(fortran-line-length): Update syntax-propertize-function and
fortran--font-lock-syntactic-keywords.
* lisp/progmodes/gud.el (gdb-script-syntax-propertize-function): New var;
replaces gdb-script-font-lock-syntactic-keywords.
(gdb-script-mode): Use it.
* lisp/progmodes/js.el (js--regexp-literal): Define while compiling.
(js-syntax-propertize-function): New var; replaces
js-font-lock-syntactic-keywords.
(js-mode): Use it.
* lisp/progmodes/make-mode.el (makefile-syntax-propertize-function):
New var; replaces makefile-font-lock-syntactic-keywords.
(makefile-mode): Use it.
(makefile-imake-mode): Adjust.
* lisp/progmodes/mixal-mode.el (mixal-syntax-propertize-function): New var;
replaces mixal-font-lock-syntactic-keywords.
(mixal-mode): Use it.
* lisp/progmodes/octave-mod.el (octave-syntax-propertize-sqs): New function
to replace octave-font-lock-close-quotes.
(octave-syntax-propertize-function): New function to replace
octave-font-lock-syntactic-keywords.
(octave-mode): Use it.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): New fun to
replace perl-font-lock-syntactic-keywords.
(perl-syntax-propertize-special-constructs): New fun to replace
perl-font-lock-special-syntactic-constructs.
(perl-font-lock-syntactic-face-function): New fun.
(perl-mode): Use it.
* lisp/progmodes/python.el (python-syntax-propertize-function): New var to
replace python-font-lock-syntactic-keywords.
(python-mode): Use it.
(python-quote-syntax): Simplify and adjust to new use.
* lisp/progmodes/ruby-mode.el (ruby-here-doc-beg-re):
Define while compiling.
(ruby-here-doc-end-re, ruby-here-doc-beg-match)
(ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
(syntax-ppss, ruby-in-ppss-context-p, ruby-in-here-doc-p)
(ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
(ruby-here-doc-end-syntax): Only define when
syntax-propertize is not available.
(ruby-syntax-propertize-function, ruby-syntax-propertize-heredoc):
New functions.
(ruby-in-ppss-context-p): Update to new syntax of heredocs.
(electric-indent-chars): Silence bytecompiler.
(ruby-mode): Use prog-mode, syntax-propertize-function, and
electric-indent-chars.
* lisp/progmodes/sh-script.el (sh-st-symbol): Remove.
(sh-font-lock-close-heredoc, sh-font-lock-open-heredoc): Add eol arg.
(sh-font-lock-flush-syntax-ppss-cache, sh-font-lock-here-doc): Remove.
(sh-font-lock-quoted-subshell): Assume we've already matched $(.
(sh-font-lock-paren): Set syntax-multiline.
(sh-font-lock-syntactic-keywords): Remove.
(sh-syntax-propertize-function): New function to replace it.
(sh-mode): Use it.
* lisp/progmodes/simula.el (simula-syntax-propertize-function): New var to
replace simula-font-lock-syntactic-keywords.
(simula-mode): Use it.
* lisp/progmodes/tcl.el (tcl-syntax-propertize-function): New var to
replace tcl-font-lock-syntactic-keywords.
(tcl-mode): Use it.
* lisp/progmodes/vhdl-mode.el (vhdl-mode): Use syntax-propertize-function
if available.
(vhdl-fontify-buffer): Adjust.
* lisp/textmodes/bibtex.el (bibtex-mode): Use syntax-propertize-function.
* lisp/textmodes/reftex.el (font-lock-syntactic-keywords): Don't declare
since we don't use it.
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-function): New var to
replace sgml-font-lock-syntactic-keywords.
(sgml-mode): Use it.
* lisp/textmodes/tex-mode.el (tex-common-initialization, doctex-mode):
Use syntax-propertize-function.
* lisp/textmodes/texinfo.el (texinfo-syntax-propertize-function): New fun
to replace texinfo-font-lock-syntactic-keywords.
(texinfo-mode): Use it.
* test/indent/octave.m: Remove some `fixindent' not needed any more.
2010-09-10 23:13:42 +00:00
|
|
|
|
(defconst simula-syntax-propertize-function
|
|
|
|
|
(syntax-propertize-rules
|
|
|
|
|
;; `comment' directive.
|
|
|
|
|
("\\<\\(c\\)omment\\>" (1 "<"))
|
|
|
|
|
;; end comments
|
|
|
|
|
((concat "\\<end\\>\\([^;\n]\\).*?\\(\n\\|\\(.\\)\\(;\\|"
|
|
|
|
|
(regexp-opt '("end" "else" "when" "otherwise"))
|
|
|
|
|
"\\)\\)")
|
|
|
|
|
(1 "< b")
|
|
|
|
|
(3 "> b"))
|
|
|
|
|
;; non-quoted single-quote char.
|
|
|
|
|
("'\\('\\)'" (1 "."))))
|
2003-02-11 21:19:36 +00:00
|
|
|
|
|
1996-10-23 09:45:11 +00:00
|
|
|
|
;; Regexps written with help from Alf-Ivar Holm <alfh@ifi.uio.no>.
|
|
|
|
|
(defconst simula-font-lock-keywords-1
|
2003-02-11 21:19:36 +00:00
|
|
|
|
'(;;
|
|
|
|
|
;; Compiler directives.
|
|
|
|
|
("^%\\([^ \t\n].*\\)" 1 font-lock-constant-face t)
|
|
|
|
|
;;
|
|
|
|
|
;; Class and procedure names.
|
|
|
|
|
("\\<\\(class\\|procedure\\)\\>[ \t]*\\(\\sw+\\)?"
|
|
|
|
|
(1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)))
|
1996-10-23 09:45:11 +00:00
|
|
|
|
"Subdued level highlighting for Simula mode.")
|
|
|
|
|
|
|
|
|
|
(defconst simula-font-lock-keywords-2
|
|
|
|
|
(append simula-font-lock-keywords-1
|
|
|
|
|
(list
|
|
|
|
|
;;
|
1998-02-20 14:58:27 +00:00
|
|
|
|
;; Constants.
|
|
|
|
|
'("\\<\\(false\\|none\\|notext\\|true\\)\\>" . font-lock-constant-face)
|
1996-10-23 09:45:11 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Keywords.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
(regexp-opt
|
|
|
|
|
'("activate" "after" "and" "at" "before" "begin" "delay" "do"
|
|
|
|
|
"else" "end" "eq" "eqv" "external" "for" "ge" "go" "goto" "gt"
|
|
|
|
|
"hidden" "if" "imp" "in" "inner" "inspect" "is" "label" "le"
|
|
|
|
|
"lt" "ne" "new" "not" "or" "otherwise" "prior" "protected"
|
|
|
|
|
"qua" "reactivate" "step" "switch" "then" "this" "to" "until"
|
|
|
|
|
"virtual" "when" "while") 'words)
|
1996-10-23 09:45:11 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Types.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
(cons (regexp-opt
|
|
|
|
|
'("array" "boolean" "character" "integer"
|
|
|
|
|
"long" "name" "real" "short" "text" "value" "ref") 'words)
|
|
|
|
|
'font-lock-type-face)))
|
1996-10-23 09:45:11 +00:00
|
|
|
|
"Medium level highlighting for Simula mode.")
|
|
|
|
|
|
|
|
|
|
(defconst simula-font-lock-keywords-3
|
|
|
|
|
(append simula-font-lock-keywords-2
|
|
|
|
|
(list
|
|
|
|
|
;;
|
|
|
|
|
;; Super-class names and super-slow.
|
|
|
|
|
'("\\<\\(\\sw+\\)[ \t]+class\\>" 1 font-lock-function-name-face)
|
|
|
|
|
;;
|
|
|
|
|
;; Types and their declarations.
|
|
|
|
|
(list (concat "\\<\\(array\\|boolean\\|character\\|integer\\|"
|
|
|
|
|
"long\\|name\\|real\\|short\\|text\\|value\\)\\>"
|
|
|
|
|
"\\([ \t]+\\sw+\\>\\)*")
|
1996-11-16 13:42:45 +00:00
|
|
|
|
'(font-lock-match-c-style-declaration-item-and-skip-to-next
|
1996-10-23 09:45:11 +00:00
|
|
|
|
;; Start with point after all type specifiers.
|
|
|
|
|
(goto-char (or (match-beginning 2) (match-end 1)))
|
|
|
|
|
;; Finish with point after first type specifier.
|
|
|
|
|
(goto-char (match-end 1))
|
|
|
|
|
;; Fontify as a variable name.
|
|
|
|
|
(1 font-lock-variable-name-face)))
|
|
|
|
|
;;
|
|
|
|
|
;; Object references and their declarations.
|
|
|
|
|
'("\\<\\(ref\\)\\>[ \t]*\\((\\(\\sw+\\))\\)?"
|
|
|
|
|
(3 font-lock-function-name-face nil t)
|
1996-11-16 13:42:45 +00:00
|
|
|
|
(font-lock-match-c-style-declaration-item-and-skip-to-next nil nil
|
1996-10-23 09:45:11 +00:00
|
|
|
|
(1 font-lock-variable-name-face)))
|
|
|
|
|
))
|
|
|
|
|
"Gaudy level highlighting for Simula mode.")
|
|
|
|
|
|
|
|
|
|
(defvar simula-font-lock-keywords simula-font-lock-keywords-1
|
|
|
|
|
"Default expressions to highlight in Simula mode.")
|
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
; The following function is taken from cc-mode.el,
|
|
|
|
|
; it determines the flavor of the Emacs running
|
|
|
|
|
|
|
|
|
|
(defvar simula-mode-menu
|
2013-02-23 21:49:41 +00:00
|
|
|
|
'(["Indent Line" simula-indent-line t]
|
1996-04-21 01:39:51 +00:00
|
|
|
|
["Backward Statement" simula-previous-statement t]
|
|
|
|
|
["Forward Statement" simula-next-statement t]
|
|
|
|
|
["Backward Up Level" simula-backward-up-level t]
|
2003-02-11 21:19:36 +00:00
|
|
|
|
["Forward Down Statement" simula-forward-down-level t])
|
1996-04-21 01:39:51 +00:00
|
|
|
|
"Lucid Emacs menu for SIMULA mode.")
|
|
|
|
|
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(if simula-mode-syntax-table
|
|
|
|
|
()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
(setq simula-mode-syntax-table (copy-syntax-table (standard-syntax-table)))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(modify-syntax-entry ?! "<" simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?$ "." simula-mode-syntax-table)
|
2003-02-11 21:19:36 +00:00
|
|
|
|
(modify-syntax-entry ?% "< b" simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\n "> b" simula-mode-syntax-table)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(modify-syntax-entry ?' "\"" simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\( "()" simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\) ")(" simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\; ">" simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\[ "." simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\\ "." simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\] "." simula-mode-syntax-table)
|
1996-10-23 09:45:11 +00:00
|
|
|
|
(modify-syntax-entry ?_ "_" simula-mode-syntax-table)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(modify-syntax-entry ?\| "." simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\{ "." simula-mode-syntax-table)
|
|
|
|
|
(modify-syntax-entry ?\} "." simula-mode-syntax-table))
|
|
|
|
|
|
2003-02-11 21:19:36 +00:00
|
|
|
|
(defvar simula-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map "\C-c\C-u" 'simula-backward-up-level)
|
|
|
|
|
(define-key map "\C-c\C-p" 'simula-previous-statement)
|
|
|
|
|
(define-key map "\C-c\C-d" 'simula-forward-down-level)
|
|
|
|
|
(define-key map "\C-c\C-n" 'simula-next-statement)
|
|
|
|
|
;; (define-key map "\C-c\C-g" 'simula-goto-definition)
|
|
|
|
|
;; (define-key map "\C-c\C-h" 'simula-standard-help)
|
|
|
|
|
(define-key map "\177" 'backward-delete-char-untabify)
|
|
|
|
|
(define-key map ":" 'simula-electric-label)
|
|
|
|
|
(define-key map "\e\C-q" 'simula-indent-exp)
|
|
|
|
|
(define-key map "\t" 'simula-indent-command)
|
|
|
|
|
;; Emacs 19 defines menus in the mode map
|
|
|
|
|
(define-key map [menu-bar simula]
|
|
|
|
|
(cons "SIMULA" (make-sparse-keymap "SIMULA")))
|
|
|
|
|
(define-key map [menu-bar simula indent-exp]
|
|
|
|
|
'("Indent Expression" . simula-indent-exp))
|
|
|
|
|
(define-key map [menu-bar simula indent-line]
|
|
|
|
|
'("Indent Line" . simula-indent-command))
|
|
|
|
|
(define-key map [menu-bar simula separator-navigate]
|
|
|
|
|
'("--"))
|
|
|
|
|
(define-key map [menu-bar simula backward-stmt]
|
|
|
|
|
'("Previous Statement" . simula-previous-statement))
|
|
|
|
|
(define-key map [menu-bar simula forward-stmt]
|
|
|
|
|
'("Next Statement" . simula-next-statement))
|
|
|
|
|
(define-key map [menu-bar simula backward-up]
|
|
|
|
|
'("Backward Up Level" . simula-backward-up-level))
|
|
|
|
|
(define-key map [menu-bar simula forward-down]
|
|
|
|
|
'("Forward Down Statement" . simula-forward-down-level))
|
|
|
|
|
|
|
|
|
|
(put 'simula-next-statement 'menu-enable '(not (eobp)))
|
|
|
|
|
(put 'simula-previous-statement 'menu-enable '(not (bobp)))
|
|
|
|
|
(put 'simula-forward-down-level 'menu-enable '(not (eobp)))
|
|
|
|
|
(put 'simula-backward-up-level 'menu-enable '(not (bobp)))
|
|
|
|
|
(put 'simula-indent-command 'menu-enable '(not buffer-read-only))
|
|
|
|
|
(put 'simula-indent-exp 'menu-enable '(not buffer-read-only))
|
|
|
|
|
|
|
|
|
|
;; RMS: mouse-3 should not select this menu. mouse-3's global
|
|
|
|
|
;; definition is useful in SIMULA mode and we should not interfere
|
|
|
|
|
;; with that. The menu is mainly for beginners, and for them,
|
|
|
|
|
;; the menubar requires less memory than a special click.
|
|
|
|
|
;; in Lucid Emacs, we want the menu to popup when the 3rd button is
|
|
|
|
|
;; hit. In 19.10 and beyond this is done automatically if we put
|
|
|
|
|
;; the menu on mode-popup-menu variable, see c-common-init [cc-mode.el]
|
|
|
|
|
;;(if (not (boundp 'mode-popup-menu))
|
|
|
|
|
;; (define-key simula-mode-map 'button3 'simula-popup-menu))
|
|
|
|
|
map)
|
|
|
|
|
"Keymap used in `simula-mode'.")
|
1996-04-21 01:39:51 +00:00
|
|
|
|
|
|
|
|
|
;; menus for Lucid
|
2011-04-22 18:44:26 +00:00
|
|
|
|
(defun simula-popup-menu (_e)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
"Pops up the SIMULA menu."
|
|
|
|
|
(interactive "@e")
|
2003-02-11 21:19:36 +00:00
|
|
|
|
(popup-menu (cons (concat mode-name " Mode Commands") simula-mode-menu)))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-10-23 09:45:11 +00:00
|
|
|
|
;;;###autoload
|
2010-07-27 16:37:25 +00:00
|
|
|
|
(define-derived-mode simula-mode prog-mode "Simula"
|
1992-07-16 21:46:36 +00:00
|
|
|
|
"Major mode for editing SIMULA code.
|
|
|
|
|
\\{simula-mode-map}
|
|
|
|
|
Variables controlling indentation style:
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-tab-always-indent'
|
1992-07-16 21:46:36 +00:00
|
|
|
|
Non-nil means TAB in SIMULA mode should always reindent the current line,
|
|
|
|
|
regardless of where in the line point is when the TAB command is used.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-indent-level'
|
1992-07-16 21:46:36 +00:00
|
|
|
|
Indentation of SIMULA statements with respect to containing block.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-substatement-offset'
|
1992-07-16 21:46:36 +00:00
|
|
|
|
Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-continued-statement-offset' 3
|
1992-07-16 21:46:36 +00:00
|
|
|
|
Extra indentation for lines not starting a statement or substatement,
|
1993-09-06 12:59:18 +00:00
|
|
|
|
e.g. a nested FOR-loop. If value is a list, each line in a multiple-
|
1992-07-16 21:46:36 +00:00
|
|
|
|
line continued statement will have the car of the list extra indentation
|
|
|
|
|
with respect to the previous line of the statement.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-label-offset' -4711
|
1993-09-06 12:59:18 +00:00
|
|
|
|
Offset of SIMULA label lines relative to usual indentation.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-if-indent' '(0 . 0)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
Extra indentation of THEN and ELSE with respect to the starting IF.
|
1993-06-09 11:59:12 +00:00
|
|
|
|
Value is a cons cell, the car is extra THEN indentation and the cdr
|
1993-09-06 12:59:18 +00:00
|
|
|
|
extra ELSE indentation. IF after ELSE is indented as the starting IF.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-inspect-indent' '(0 . 0)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
Extra indentation of WHEN and OTHERWISE with respect to the
|
1993-09-06 12:59:18 +00:00
|
|
|
|
corresponding INSPECT. Value is a cons cell, the car is
|
1993-06-09 11:59:12 +00:00
|
|
|
|
extra WHEN indentation and the cdr extra OTHERWISE indentation.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-electric-indent' nil
|
1993-09-06 12:59:18 +00:00
|
|
|
|
If this variable is non-nil, `simula-indent-line'
|
1992-07-16 21:46:36 +00:00
|
|
|
|
will check the previous line to see if it has to be reindented.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-abbrev-keyword' 'upcase
|
1993-09-06 12:59:18 +00:00
|
|
|
|
Determine how SIMULA keywords will be expanded. Value is one of
|
|
|
|
|
the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table',
|
|
|
|
|
or nil if they should not be changed.
|
2003-02-11 21:19:36 +00:00
|
|
|
|
`simula-abbrev-stdproc' 'abbrev-table
|
1992-07-16 21:46:36 +00:00
|
|
|
|
Determine how standard SIMULA procedure and class names will be
|
1993-09-06 12:59:18 +00:00
|
|
|
|
expanded. Value is one of the symbols `upcase', `downcase', `capitalize',
|
|
|
|
|
(as in) `abbrev-table', or nil if they should not be changed.
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
|
|
|
|
Turning on SIMULA mode calls the value of the variable simula-mode-hook
|
2003-02-11 21:19:36 +00:00
|
|
|
|
with no arguments, if that value is non-nil."
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 20:00:25 +00:00
|
|
|
|
(set (make-local-variable 'comment-column) 40)
|
|
|
|
|
;; (set (make-local-variable 'end-comment-column) 75)
|
|
|
|
|
(set (make-local-variable 'paragraph-start) "[ \t]*$\\|\\f")
|
|
|
|
|
(set (make-local-variable 'paragraph-separate) paragraph-start)
|
|
|
|
|
(set (make-local-variable 'indent-line-function) 'simula-indent-line)
|
|
|
|
|
(set (make-local-variable 'comment-start) "! ")
|
|
|
|
|
(set (make-local-variable 'comment-end) " ;")
|
|
|
|
|
(set (make-local-variable 'comment-start-skip) "!+ *")
|
|
|
|
|
(set (make-local-variable 'parse-sexp-ignore-comments) nil)
|
|
|
|
|
(set (make-local-variable 'comment-multi-line) t)
|
|
|
|
|
(set (make-local-variable 'font-lock-defaults)
|
|
|
|
|
'((simula-font-lock-keywords simula-font-lock-keywords-1
|
|
|
|
|
simula-font-lock-keywords-2 simula-font-lock-keywords-3)
|
|
|
|
|
nil t ((?_ . "w"))))
|
New syntax-propertize functionality.
* lisp/font-lock.el (font-lock-syntactic-keywords): Make obsolete.
(font-lock-fontify-syntactic-keywords-region): Move handling of
font-lock-syntactically-fontified to...
(font-lock-default-fontify-region): ...here.
Let syntax-propertize-function take precedence.
(font-lock-fontify-syntactically-region): Cal syntax-propertize.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt-depth): Skip named groups.
* lisp/emacs-lisp/syntax.el (syntax-propertize-function)
(syntax-propertize-chunk-size, syntax-propertize--done)
(syntax-propertize-extend-region-functions): New vars.
(syntax-propertize-wholelines, syntax-propertize-multiline)
(syntax-propertize--shift-groups, syntax-propertize-via-font-lock)
(syntax-propertize): New functions.
(syntax-propertize-rules): New macro.
(syntax-ppss-flush-cache): Set syntax-propertize--done.
(syntax-ppss): Call syntax-propertize.
* lisp/progmodes/ada-mode.el (ada-set-syntax-table-properties)
(ada-after-change-function, ada-initialize-syntax-table-properties)
(ada-handle-syntax-table-properties): Only define when
syntax-propertize is not available.
(ada-mode): Use syntax-propertize-function.
* lisp/progmodes/autoconf.el (autoconf-mode):
Use syntax-propertize-function.
(autoconf-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cfengine.el (cfengine-mode):
Use syntax-propertize-function.
(cfengine-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cperl-mode.el (cperl-mode): Use syntax-propertize-function.
* lisp/progmodes/fortran.el (fortran-mode): Use syntax-propertize-function.
(fortran--font-lock-syntactic-keywords): New var.
(fortran-line-length): Update syntax-propertize-function and
fortran--font-lock-syntactic-keywords.
* lisp/progmodes/gud.el (gdb-script-syntax-propertize-function): New var;
replaces gdb-script-font-lock-syntactic-keywords.
(gdb-script-mode): Use it.
* lisp/progmodes/js.el (js--regexp-literal): Define while compiling.
(js-syntax-propertize-function): New var; replaces
js-font-lock-syntactic-keywords.
(js-mode): Use it.
* lisp/progmodes/make-mode.el (makefile-syntax-propertize-function):
New var; replaces makefile-font-lock-syntactic-keywords.
(makefile-mode): Use it.
(makefile-imake-mode): Adjust.
* lisp/progmodes/mixal-mode.el (mixal-syntax-propertize-function): New var;
replaces mixal-font-lock-syntactic-keywords.
(mixal-mode): Use it.
* lisp/progmodes/octave-mod.el (octave-syntax-propertize-sqs): New function
to replace octave-font-lock-close-quotes.
(octave-syntax-propertize-function): New function to replace
octave-font-lock-syntactic-keywords.
(octave-mode): Use it.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): New fun to
replace perl-font-lock-syntactic-keywords.
(perl-syntax-propertize-special-constructs): New fun to replace
perl-font-lock-special-syntactic-constructs.
(perl-font-lock-syntactic-face-function): New fun.
(perl-mode): Use it.
* lisp/progmodes/python.el (python-syntax-propertize-function): New var to
replace python-font-lock-syntactic-keywords.
(python-mode): Use it.
(python-quote-syntax): Simplify and adjust to new use.
* lisp/progmodes/ruby-mode.el (ruby-here-doc-beg-re):
Define while compiling.
(ruby-here-doc-end-re, ruby-here-doc-beg-match)
(ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
(syntax-ppss, ruby-in-ppss-context-p, ruby-in-here-doc-p)
(ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
(ruby-here-doc-end-syntax): Only define when
syntax-propertize is not available.
(ruby-syntax-propertize-function, ruby-syntax-propertize-heredoc):
New functions.
(ruby-in-ppss-context-p): Update to new syntax of heredocs.
(electric-indent-chars): Silence bytecompiler.
(ruby-mode): Use prog-mode, syntax-propertize-function, and
electric-indent-chars.
* lisp/progmodes/sh-script.el (sh-st-symbol): Remove.
(sh-font-lock-close-heredoc, sh-font-lock-open-heredoc): Add eol arg.
(sh-font-lock-flush-syntax-ppss-cache, sh-font-lock-here-doc): Remove.
(sh-font-lock-quoted-subshell): Assume we've already matched $(.
(sh-font-lock-paren): Set syntax-multiline.
(sh-font-lock-syntactic-keywords): Remove.
(sh-syntax-propertize-function): New function to replace it.
(sh-mode): Use it.
* lisp/progmodes/simula.el (simula-syntax-propertize-function): New var to
replace simula-font-lock-syntactic-keywords.
(simula-mode): Use it.
* lisp/progmodes/tcl.el (tcl-syntax-propertize-function): New var to
replace tcl-font-lock-syntactic-keywords.
(tcl-mode): Use it.
* lisp/progmodes/vhdl-mode.el (vhdl-mode): Use syntax-propertize-function
if available.
(vhdl-fontify-buffer): Adjust.
* lisp/textmodes/bibtex.el (bibtex-mode): Use syntax-propertize-function.
* lisp/textmodes/reftex.el (font-lock-syntactic-keywords): Don't declare
since we don't use it.
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-function): New var to
replace sgml-font-lock-syntactic-keywords.
(sgml-mode): Use it.
* lisp/textmodes/tex-mode.el (tex-common-initialization, doctex-mode):
Use syntax-propertize-function.
* lisp/textmodes/texinfo.el (texinfo-syntax-propertize-function): New fun
to replace texinfo-font-lock-syntactic-keywords.
(texinfo-mode): Use it.
* test/indent/octave.m: Remove some `fixindent' not needed any more.
2010-09-10 23:13:42 +00:00
|
|
|
|
(set (make-local-variable 'syntax-propertize-function)
|
|
|
|
|
simula-syntax-propertize-function)
|
2003-02-11 21:19:36 +00:00
|
|
|
|
(abbrev-mode 1))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defun simula-indent-exp ()
|
|
|
|
|
"Indent SIMULA expression following point."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((here (point))
|
|
|
|
|
(simula-electric-indent nil)
|
|
|
|
|
end)
|
|
|
|
|
(simula-skip-comment-forward)
|
|
|
|
|
(if (eobp)
|
|
|
|
|
(goto-char here)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(simula-next-statement 1)
|
|
|
|
|
(setq end (point-marker))
|
|
|
|
|
(simula-previous-statement 1)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
(if (not (looking-at "[ \t]*$"))
|
|
|
|
|
(simula-indent-line))
|
|
|
|
|
(forward-line 1)))
|
|
|
|
|
(and end (set-marker end nil))))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
|
|
|
|
(defun simula-indent-line ()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Indent this line as SIMULA code.
|
|
|
|
|
If `simula-electric-indent' is non-nil, indent previous line if necessary."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(let ((origin (- (point-max) (point)))
|
|
|
|
|
(indent (simula-calculate-indent))
|
|
|
|
|
(case-fold-search t))
|
|
|
|
|
(unwind-protect
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(if simula-electric-indent
|
|
|
|
|
(progn
|
|
|
|
|
;;
|
|
|
|
|
;; manually expand abbrev on last line, if any
|
|
|
|
|
;;
|
|
|
|
|
(end-of-line 0)
|
|
|
|
|
(expand-abbrev)
|
|
|
|
|
;; now maybe we should reindent that line
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(skip-chars-forward " \t\f")
|
|
|
|
|
(if (and
|
|
|
|
|
(looking-at
|
|
|
|
|
"\\(end\\|if\\|then\\|else\\|when\\|otherwise\\)\\>")
|
|
|
|
|
(not (simula-context)))
|
|
|
|
|
;; yes - reindent
|
|
|
|
|
(let ((post-indent (simula-calculate-indent)))
|
|
|
|
|
(if (eq (current-indentation) post-indent)
|
|
|
|
|
()
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(indent-to post-indent))))))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(goto-char (- (point-max) origin))
|
|
|
|
|
(if (eq (current-indentation) indent)
|
|
|
|
|
(back-to-indentation)
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(indent-to indent)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-indent-command (&optional whole-exp)
|
|
|
|
|
"Indent current line as SIMULA code, or insert TAB character.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
If `simula-tab-always-indent' is non-nil, always indent current line.
|
1992-07-16 21:46:36 +00:00
|
|
|
|
Otherwise, indent only if point is before any non-whitespace
|
|
|
|
|
character on the line.
|
|
|
|
|
|
|
|
|
|
A numeric argument, regardless of its value, means indent rigidly
|
|
|
|
|
all the lines of the SIMULA statement after point so that this line
|
|
|
|
|
becomes properly indented.
|
|
|
|
|
The relative indentation among the lines of the statement are preserved."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(if (or whole-exp simula-tab-always-indent
|
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-backward " \t\f")
|
|
|
|
|
(bolp)))
|
|
|
|
|
;; reindent current line
|
|
|
|
|
(let ((indent (save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(simula-calculate-indent)))
|
|
|
|
|
(current (current-indentation))
|
|
|
|
|
(origin (- (point-max) (point)))
|
|
|
|
|
(bol (save-excursion
|
|
|
|
|
(skip-chars-backward " \t\f")
|
|
|
|
|
(bolp)))
|
|
|
|
|
beg end)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(if (eq current indent)
|
|
|
|
|
(if (save-excursion
|
|
|
|
|
(skip-chars-backward " \t\f")
|
|
|
|
|
(bolp))
|
|
|
|
|
(back-to-indentation))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(indent-to indent))
|
|
|
|
|
(if (not bol)
|
|
|
|
|
(goto-char (- (point-max) origin))))
|
|
|
|
|
(setq origin (point))
|
|
|
|
|
(if whole-exp
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line 2)
|
|
|
|
|
(setq beg (point))
|
|
|
|
|
(goto-char origin)
|
|
|
|
|
(simula-next-statement 1)
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(if (and (> end beg) (not (eq indent current)))
|
|
|
|
|
(indent-code-rigidly beg end (- indent current) "%")))))
|
|
|
|
|
(insert-tab))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-context ()
|
2003-02-11 21:19:36 +00:00
|
|
|
|
"Return value according to syntactic SIMULA context of point.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
0 point inside COMMENT comment
|
1992-07-16 21:46:36 +00:00
|
|
|
|
1 point on SIMULA-compiler directive line
|
|
|
|
|
2 point inside END comment
|
|
|
|
|
3 point inside string
|
|
|
|
|
4 point inside character constant
|
|
|
|
|
nil otherwise."
|
|
|
|
|
;; first, find out if this is a compiler directive line
|
|
|
|
|
(if (save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(eq (following-char) ?%))
|
|
|
|
|
;; YES - return 1
|
|
|
|
|
1
|
|
|
|
|
(save-excursion
|
|
|
|
|
;; The current line is NOT a compiler directive line.
|
|
|
|
|
;; Now, the strategy is to search backward to find a semicolon
|
|
|
|
|
;; that is NOT inside a string. The point after semicolon MUST be
|
|
|
|
|
;; outside a comment, since semicolons are comment-ending and
|
|
|
|
|
;; comments are non-recursive. We take advantage of the fact
|
|
|
|
|
;; that strings MUST end on the same line as they started, so
|
|
|
|
|
;; that we can easily decide whether we are inside a string or not.
|
|
|
|
|
(let (return-value (origin (point)))
|
|
|
|
|
(skip-chars-backward "^;" (point-min))
|
|
|
|
|
;; found semicolon or beginning of buffer
|
|
|
|
|
(let (loopvalue (saved-point origin))
|
|
|
|
|
(while (and (not (bobp))
|
|
|
|
|
(if (progn
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
;; compiler directive line? If so, cont searching..
|
|
|
|
|
(eq (following-char) ?%))
|
|
|
|
|
t
|
|
|
|
|
(while (< (point) saved-point)
|
|
|
|
|
(skip-chars-forward "^;\"'")
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(cond
|
|
|
|
|
((eq (preceding-char) ?\;)
|
|
|
|
|
(setq saved-point (point)))
|
|
|
|
|
((eq (preceding-char) ?\")
|
|
|
|
|
(skip-chars-forward "^\";")
|
|
|
|
|
(if (eq (following-char) ?\;)
|
|
|
|
|
(setq saved-point (point) loopvalue t)
|
|
|
|
|
(forward-char 1)))
|
|
|
|
|
(t
|
|
|
|
|
(if (eq (following-char) ?')
|
|
|
|
|
(forward-char 1))
|
|
|
|
|
(skip-chars-forward "^';")
|
|
|
|
|
(if (eq (following-char) ?\;)
|
|
|
|
|
(setq saved-point (point) loopvalue t)
|
|
|
|
|
(forward-char 1)))))
|
|
|
|
|
loopvalue))
|
|
|
|
|
(backward-char 1)
|
|
|
|
|
(skip-chars-backward "^;")
|
|
|
|
|
(setq saved-point (point) loopvalue nil)))
|
|
|
|
|
;; Now we are CERTAIN that we are outside comments and strings.
|
|
|
|
|
;; The job now is to search forward again towards the origin
|
|
|
|
|
;; skipping directives, comments and strings correctly,
|
|
|
|
|
;; so that we know what context we are in when we find the origin.
|
|
|
|
|
(while (and
|
|
|
|
|
(< (point) origin)
|
|
|
|
|
(re-search-forward
|
|
|
|
|
"\\<end\\>\\|!\\|\"\\|'\\|^%\\|\\<comment\\>" origin 'move))
|
|
|
|
|
(cond
|
|
|
|
|
((memq (preceding-char) '(?d ?D))
|
|
|
|
|
(setq return-value 2)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(while (and (re-search-forward
|
|
|
|
|
";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>\\|^%"
|
|
|
|
|
origin 'move)
|
|
|
|
|
;; found another END?
|
|
|
|
|
(or (memq (preceding-char) '(?d ?D))
|
|
|
|
|
;; if directive, skip line
|
|
|
|
|
(and (eq (preceding-char) ?%)
|
|
|
|
|
(beginning-of-line 2))
|
|
|
|
|
;; found other keyword, out of END comment
|
|
|
|
|
(setq return-value nil))))
|
|
|
|
|
(if (and (eq (char-syntax (preceding-char)) ?w)
|
|
|
|
|
(eq (char-syntax (following-char)) ?w))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(if (looking-at "end\\>\\|else\\>\\|otherwise\\>\\|when\\>")
|
|
|
|
|
(setq return-value nil)))))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
((memq (preceding-char) '(?! ?t ?T))
|
|
|
|
|
; skip comment
|
|
|
|
|
(setq return-value 0)
|
|
|
|
|
(skip-chars-forward "^%;" origin)
|
|
|
|
|
(while (and return-value (< (point) origin))
|
|
|
|
|
(if (eq (following-char) ?\;)
|
|
|
|
|
(setq return-value nil)
|
|
|
|
|
(if (bolp)
|
|
|
|
|
(beginning-of-line 2) ; skip directive inside comment
|
|
|
|
|
(forward-char 1)) ; or single '%'
|
|
|
|
|
(skip-chars-forward "^%;" origin))))
|
|
|
|
|
((eq (preceding-char) ?\")
|
|
|
|
|
(if (not (search-forward "\"" origin 'move))
|
|
|
|
|
(setq return-value 3)))
|
|
|
|
|
((eq (preceding-char) ?\')
|
|
|
|
|
(if (or (eq (point) origin) (eobp))
|
|
|
|
|
(setq return-value 4)
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(if (not (search-forward "'" origin 'move))
|
|
|
|
|
(setq return-value 4))))
|
|
|
|
|
;; compiler directive line - skip
|
|
|
|
|
(t (beginning-of-line 2))))
|
|
|
|
|
return-value)
|
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-electric-label ()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"If this is a label that starts the line, reindent the line."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(expand-abbrev)
|
|
|
|
|
(insert ?:)
|
|
|
|
|
(let ((origin (- (point-max) (point)))
|
|
|
|
|
(case-fold-search t)
|
|
|
|
|
;; don't mix a label with an assignment operator := :-
|
1996-04-21 01:39:51 +00:00
|
|
|
|
;; therefore take a peek at next typed character...
|
|
|
|
|
(next-char (read-event)))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(unwind-protect
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(setq unread-command-events (append unread-command-events
|
|
|
|
|
(list next-char)))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; Problem: find out if character just read is a command char
|
|
|
|
|
;; that would insert something after ':' making it a label.
|
|
|
|
|
;; At least \n, \r (and maybe \t) falls into this category.
|
|
|
|
|
;; This is a real crock, it depends on traditional keymap
|
|
|
|
|
;; bindings, that is, printing characters doing self-insert,
|
|
|
|
|
;; and no other command sequence inserting '-' or '='.
|
|
|
|
|
;; simula-electric-label can be easily fooled...
|
|
|
|
|
(if (and (not (memq next-char '(?= ?-)))
|
|
|
|
|
(or (memq next-char '(?\n ?\r))
|
|
|
|
|
(and (eq next-char ?\t)
|
|
|
|
|
simula-tab-always-indent)
|
|
|
|
|
(not (memq (following-char) '(?= ?-))))
|
|
|
|
|
(not (simula-context))
|
|
|
|
|
;; label?
|
|
|
|
|
(progn
|
|
|
|
|
(backward-char 1)
|
|
|
|
|
(skip-chars-backward " \t\f")
|
|
|
|
|
(skip-chars-backward "a-zA-Z0-9_")
|
|
|
|
|
(if (looking-at "virtual\\>")
|
|
|
|
|
nil
|
|
|
|
|
(skip-chars-backward " \t\f")
|
|
|
|
|
(bolp))))
|
|
|
|
|
(let ((amount (simula-calculate-indent)))
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(indent-to amount)))
|
|
|
|
|
(goto-char (- (point-max) origin)))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
|
|
|
|
(defun simula-backward-up-level (count)
|
|
|
|
|
"Move backward up COUNT block levels.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
If COUNT is negative, move forward up block level instead."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(let ((origin (point))
|
|
|
|
|
(case-fold-search t))
|
|
|
|
|
(condition-case ()
|
|
|
|
|
(if (> count 0)
|
|
|
|
|
(while (> count 0)
|
|
|
|
|
(re-search-backward "\\<begin\\>\\|\\<end\\>")
|
|
|
|
|
(if (not (simula-context))
|
|
|
|
|
(setq count (if (memq (following-char) '(?b ?B))
|
|
|
|
|
(1- count)
|
|
|
|
|
(1+ count)))))
|
|
|
|
|
(while (< count 0)
|
|
|
|
|
(re-search-forward "\\<begin\\>\\|\\<end\\>")
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(if (not (simula-context))
|
|
|
|
|
(setq count (if (memq (following-char) '(?e ?E))
|
|
|
|
|
(1+ count)
|
|
|
|
|
(1- count))))
|
|
|
|
|
(backward-word -1)))
|
|
|
|
|
;; If block level not found, jump back to origin and signal an error
|
|
|
|
|
(error (progn
|
|
|
|
|
(goto-char origin)
|
|
|
|
|
(error "No higher block level")))
|
|
|
|
|
(quit (progn
|
|
|
|
|
(goto-char origin)
|
|
|
|
|
(signal 'quit nil))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-forward-down-level (count)
|
|
|
|
|
"Move forward down COUNT block levels.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
If COUNT is negative, move backward down block level instead."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
;; When we search for a deeper block level, we must never
|
|
|
|
|
;; get out of the block where we started -> count >= start-count
|
|
|
|
|
(let ((start-count count)
|
|
|
|
|
(origin (point))
|
|
|
|
|
(case-fold-search t))
|
|
|
|
|
(condition-case ()
|
|
|
|
|
(if (< count 0)
|
|
|
|
|
(while (< count 0)
|
|
|
|
|
(re-search-backward "\\<begin\\>\\|\\<end\\>")
|
|
|
|
|
(if (not (simula-context))
|
|
|
|
|
(setq count (if (memq (following-char) '(?e ?E))
|
|
|
|
|
(1+ count)
|
|
|
|
|
(1- count))))
|
|
|
|
|
(if (< count start-count) (signal 'error nil)))
|
|
|
|
|
(while (> count 0)
|
|
|
|
|
(re-search-forward "\\<begin\\>\\|\\<end\\>")
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(if (not (simula-context))
|
|
|
|
|
(setq count (if (memq (following-char) '(?b ?B))
|
|
|
|
|
(1- count)
|
|
|
|
|
(1+ count))))
|
|
|
|
|
(backward-word -1)
|
|
|
|
|
;; deeper level has to be found within starting block
|
|
|
|
|
(if (> count start-count) (signal 'error nil))))
|
|
|
|
|
;; If block level not found, jump back to origin and signal an error
|
|
|
|
|
(error (progn
|
|
|
|
|
(goto-char origin)
|
|
|
|
|
(error "No containing block level")))
|
|
|
|
|
(quit (progn
|
|
|
|
|
(goto-char origin)
|
|
|
|
|
(signal 'quit nil))))))
|
|
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(defun simula-previous-statement (count)
|
|
|
|
|
"Move backward COUNT statements.
|
1993-09-06 12:59:18 +00:00
|
|
|
|
If COUNT is negative, move forward instead."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(if (< count 0)
|
|
|
|
|
(simula-next-statement (- count))
|
|
|
|
|
(let (status
|
|
|
|
|
(case-fold-search t)
|
|
|
|
|
(origin (point)))
|
|
|
|
|
(condition-case ()
|
2003-02-04 13:24:35 +00:00
|
|
|
|
;;
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(progn
|
|
|
|
|
(simula-skip-comment-backward)
|
|
|
|
|
(if (memq (preceding-char) '(?n ?N))
|
|
|
|
|
(progn
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(if (not (looking-at "\\<begin\\>"))
|
|
|
|
|
(backward-word -1)))
|
|
|
|
|
(if (eq (preceding-char) ?\;)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(backward-char 1))
|
|
|
|
|
)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(while (and (natnump (setq count (1- count)))
|
|
|
|
|
(setq status (simula-search-backward
|
|
|
|
|
";\\|\\<begin\\>" nil 'move))))
|
|
|
|
|
(if status
|
|
|
|
|
(progn
|
|
|
|
|
(if (eq (following-char) ?\;)
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(backward-word -1))))
|
|
|
|
|
(simula-skip-comment-forward))
|
|
|
|
|
(error (progn (goto-char origin)
|
|
|
|
|
(error "Incomplete statement (too many ENDs)")))
|
|
|
|
|
(quit (progn (goto-char origin) (signal 'quit nil)))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-next-statement (count)
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Move forward COUNT statements.
|
|
|
|
|
If COUNT is negative, move backward instead."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(if (< count 0)
|
|
|
|
|
(simula-previous-statement (- count))
|
|
|
|
|
(let (status
|
|
|
|
|
(case-fold-search t)
|
|
|
|
|
(origin (point)))
|
|
|
|
|
(condition-case ()
|
|
|
|
|
(progn
|
|
|
|
|
(simula-skip-comment-forward)
|
|
|
|
|
(if (looking-at "\\<end\\>") (forward-word 1))
|
|
|
|
|
(while (and (natnump (setq count (1- count)))
|
|
|
|
|
(setq status (simula-search-forward
|
|
|
|
|
";\\|\\<end\\>" (point-max) 'move))))
|
|
|
|
|
(if (and status (/= (preceding-char) ?\;))
|
|
|
|
|
(progn
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(simula-skip-comment-backward))))
|
|
|
|
|
(error (progn (goto-char origin)
|
|
|
|
|
(error "Incomplete statement (too few ENDs)")))
|
|
|
|
|
(quit (progn (goto-char origin) (signal 'quit nil)))))))
|
|
|
|
|
|
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defun simula-skip-comment-backward (&optional stop-at-end)
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Search towards bob to find first char that is outside a comment."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(catch 'simula-out
|
|
|
|
|
(let (context)
|
|
|
|
|
(while t
|
|
|
|
|
(skip-chars-backward " \t\n\f")
|
|
|
|
|
(if (eq (preceding-char) ?\;)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-char 1)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(setq context (simula-context))
|
|
|
|
|
(if (and stop-at-end (eq context 2))
|
|
|
|
|
(setq context nil)))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(setq context (simula-context)))
|
|
|
|
|
(cond
|
|
|
|
|
((memq context '(nil 3 4))
|
|
|
|
|
;; check to see if we found a label
|
|
|
|
|
(if (and (eq (preceding-char) ?:)
|
|
|
|
|
(not (memq (following-char) '(?- ?=)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-backward ": \t\fa-zA-Z0-9_")
|
|
|
|
|
(not (looking-at "virtual\\>"))))
|
|
|
|
|
(skip-chars-backward ": \t\fa-zA-Z0-9_")
|
|
|
|
|
(throw 'simula-out nil)))
|
|
|
|
|
((eq context 0)
|
|
|
|
|
;; since we are inside a comment, it must start somewhere!
|
|
|
|
|
(while (and (re-search-backward "!\\|\\<comment\\>")
|
|
|
|
|
(memq (simula-context) '(0 1)))))
|
|
|
|
|
((eq context 1)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(beginning-of-line)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(if (bobp)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(throw 'simula-out nil)
|
|
|
|
|
(backward-char)))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
((eq context 2)
|
|
|
|
|
;; an END-comment must belong to an END
|
|
|
|
|
(re-search-backward "\\<end\\>")
|
|
|
|
|
(forward-word 1)
|
|
|
|
|
(throw 'simula-out nil))
|
|
|
|
|
;; should be impossible to get here..
|
|
|
|
|
)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-skip-comment-forward ()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Search towards eob to find first char that is outside a comment."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; this function assumes we start with point .outside a comment
|
|
|
|
|
(interactive)
|
|
|
|
|
(catch 'simula-out
|
|
|
|
|
(while t
|
|
|
|
|
(skip-chars-forward " \t\n\f")
|
1996-04-21 01:39:51 +00:00
|
|
|
|
;; BUG: the following (0 2) branches don't take into account intermixing
|
|
|
|
|
;; directive lines
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(cond
|
|
|
|
|
((looking-at "!\\|\\<comment\\>")
|
|
|
|
|
(search-forward ";" nil 'move))
|
|
|
|
|
((and (bolp) (eq (following-char) ?%))
|
|
|
|
|
(beginning-of-line 2))
|
|
|
|
|
((and (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]")
|
|
|
|
|
(not (looking-at "virtual\\>")))
|
|
|
|
|
(skip-chars-forward "a-zA-Z0-9_ \t\f:"))
|
|
|
|
|
(t
|
|
|
|
|
(throw 'simula-out t))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-forward-up-level ()
|
|
|
|
|
(let ((continue-loop t)
|
|
|
|
|
(origin (point))
|
|
|
|
|
(case-fold-search t)
|
|
|
|
|
return-value
|
|
|
|
|
temp)
|
|
|
|
|
(while continue-loop
|
|
|
|
|
(if (re-search-backward "\\<begin\\>\\|\\<end\\>" (point-min) 'move)
|
|
|
|
|
(setq temp (simula-context)
|
|
|
|
|
return-value (and (memq (preceding-char) '(?d ?D))
|
|
|
|
|
(memq temp '(nil 2)))
|
|
|
|
|
continue-loop (and (not return-value)
|
|
|
|
|
(simula-forward-up-level)))
|
|
|
|
|
(setq continue-loop nil)))
|
|
|
|
|
(if return-value
|
|
|
|
|
t
|
|
|
|
|
(goto-char origin)
|
|
|
|
|
nil)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-calculate-indent ()
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((where (simula-context))
|
|
|
|
|
(origin (point))
|
|
|
|
|
(indent 0)
|
|
|
|
|
continued
|
|
|
|
|
start-line
|
|
|
|
|
temp
|
|
|
|
|
found-end
|
|
|
|
|
prev-cont)
|
|
|
|
|
(cond
|
|
|
|
|
((eq where 0)
|
|
|
|
|
;;
|
|
|
|
|
;; Comment.
|
|
|
|
|
;; If comment started on previous non-blank line, indent to the
|
|
|
|
|
;; column where the comment started, else indent as that line.
|
|
|
|
|
;;
|
|
|
|
|
(skip-chars-backward " \t\n\f")
|
|
|
|
|
(while (and (not (bolp)) (eq (simula-context) 0))
|
|
|
|
|
(re-search-backward "^\\|!\\|\\<comment\\>"))
|
|
|
|
|
(skip-chars-forward " \t\n\f")
|
|
|
|
|
(prog1
|
|
|
|
|
(current-column)
|
|
|
|
|
(goto-char origin)))
|
1996-04-21 01:39:51 +00:00
|
|
|
|
((eq where 1)
|
|
|
|
|
;;
|
|
|
|
|
;; Directive. Always 0.
|
|
|
|
|
;;
|
|
|
|
|
0)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Detect missing string delimiters
|
|
|
|
|
;;
|
|
|
|
|
((eq where 3)
|
|
|
|
|
(error "Inside string"))
|
|
|
|
|
((eq where 4)
|
|
|
|
|
(error "Inside character constant"))
|
|
|
|
|
;;
|
|
|
|
|
;; check to see if inside ()'s
|
|
|
|
|
;;
|
|
|
|
|
((setq temp (simula-inside-parens))
|
|
|
|
|
temp)
|
|
|
|
|
;;
|
|
|
|
|
;; Calculate non-comment indentation
|
|
|
|
|
(t
|
|
|
|
|
;; first, find out if this line starts with something that needs
|
1993-06-09 11:59:12 +00:00
|
|
|
|
;; special indentation (END/IF/THEN/ELSE/WHEN/OTHERWISE or label)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;;
|
|
|
|
|
(skip-chars-forward " \t\f")
|
|
|
|
|
(cond
|
|
|
|
|
;;
|
|
|
|
|
;; END
|
|
|
|
|
;;
|
|
|
|
|
((looking-at "end\\>")
|
|
|
|
|
(setq indent (- simula-indent-level)
|
|
|
|
|
found-end t))
|
|
|
|
|
;;
|
|
|
|
|
;; IF/THEN/ELSE
|
|
|
|
|
;;
|
|
|
|
|
((looking-at "if\\>\\|then\\>\\|else\\>")
|
|
|
|
|
;; search for the *starting* IF
|
|
|
|
|
(cond
|
|
|
|
|
((memq (following-char) '(?T ?t))
|
|
|
|
|
(setq indent (car simula-if-indent)))
|
|
|
|
|
((memq (following-char) '(?E ?e))
|
|
|
|
|
(setq indent (cdr simula-if-indent)))
|
|
|
|
|
(t
|
|
|
|
|
(forward-word 1)
|
|
|
|
|
(setq indent 0)))
|
|
|
|
|
(simula-find-if))
|
|
|
|
|
;;
|
|
|
|
|
;; WHEN/OTHERWISE
|
|
|
|
|
;;
|
|
|
|
|
((looking-at "when\\>\\|otherwise\\>")
|
|
|
|
|
;; search for corresponding INSPECT
|
|
|
|
|
(if (memq (following-char) '(?W ?w))
|
|
|
|
|
(setq indent (car simula-inspect-indent))
|
|
|
|
|
(setq indent (cdr simula-inspect-indent)))
|
|
|
|
|
(simula-find-inspect))
|
|
|
|
|
;;
|
|
|
|
|
;; label:
|
|
|
|
|
;;
|
|
|
|
|
((and (not (looking-at "virtual\\>"))
|
|
|
|
|
(looking-at "[a-z0-9_]*[ \t\f]*:[^-=]"))
|
|
|
|
|
(setq indent simula-label-offset)))
|
|
|
|
|
;; find line with non-comment text
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(simula-skip-comment-backward 'dont-skip-end)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(if (and found-end
|
|
|
|
|
(not (eq (preceding-char) ?\;))
|
|
|
|
|
(if (memq (preceding-char) '(?N ?n))
|
|
|
|
|
(save-excursion
|
1992-11-16 01:42:04 +00:00
|
|
|
|
(backward-word 1)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(not (looking-at "begin\\>")))
|
|
|
|
|
t))
|
|
|
|
|
(progn
|
|
|
|
|
(simula-previous-statement 1)
|
|
|
|
|
(simula-skip-comment-backward)))
|
|
|
|
|
(setq start-line
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(line-beginning-position)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; - perhaps this is a continued statement
|
|
|
|
|
continued
|
|
|
|
|
(save-excursion
|
|
|
|
|
(and (not (bobp))
|
|
|
|
|
;; (not found-end)
|
|
|
|
|
(if (eq (char-syntax (preceding-char)) ?w)
|
|
|
|
|
(progn
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(not (looking-at
|
|
|
|
|
"begin\\|then\\|else\\|when\\|otherwise\\|do"
|
|
|
|
|
)))
|
|
|
|
|
(not (memq (preceding-char) '(?: ?\;)))))))
|
|
|
|
|
;;
|
|
|
|
|
;; MAIN calculation loop - count BEGIN/DO etc.
|
|
|
|
|
;;
|
|
|
|
|
(while (not (bolp))
|
|
|
|
|
(if (re-search-backward
|
|
|
|
|
";\\|\\<\\(begin\\|end\\|if\\|else\\|then\\|when\\|otherwise\\|do\\)\\>"
|
|
|
|
|
start-line 'move)
|
|
|
|
|
(if (simula-context)
|
|
|
|
|
();; found something in a comment/string - ignore
|
|
|
|
|
(setq temp (following-char))
|
|
|
|
|
(cond
|
|
|
|
|
((eq temp ?\;)
|
|
|
|
|
(simula-previous-statement 1))
|
|
|
|
|
((looking-at "begin\\>")
|
|
|
|
|
(setq indent (+ indent simula-indent-level)))
|
|
|
|
|
((looking-at "end\\>")
|
|
|
|
|
(forward-word 1)
|
|
|
|
|
(simula-previous-statement 1))
|
|
|
|
|
((looking-at "do\\>")
|
|
|
|
|
(setq indent (+ indent simula-substatement-offset))
|
|
|
|
|
(simula-find-do-match))
|
|
|
|
|
((looking-at "\\(if\\|then\\|else\\)\\>")
|
|
|
|
|
(if (memq temp '(?I ?i))
|
|
|
|
|
(forward-word 1)
|
|
|
|
|
(setq indent (+ indent
|
|
|
|
|
simula-substatement-offset
|
|
|
|
|
(if (memq temp '(?T ?t))
|
|
|
|
|
(car simula-if-indent)
|
|
|
|
|
(cdr simula-if-indent)))))
|
|
|
|
|
(simula-find-if))
|
|
|
|
|
((looking-at "\\<when\\>\\|\\<otherwise\\>")
|
|
|
|
|
(setq indent (+ indent
|
|
|
|
|
simula-substatement-offset
|
|
|
|
|
(if (memq temp '(?W ?w))
|
|
|
|
|
(car simula-if-indent)
|
|
|
|
|
(cdr simula-if-indent))))
|
|
|
|
|
(simula-find-inspect)))
|
|
|
|
|
;; found the start of a [sub]statement
|
1993-06-09 11:59:12 +00:00
|
|
|
|
;; add indentation for continued statement
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(if continued
|
|
|
|
|
(setq indent
|
|
|
|
|
(+ indent
|
|
|
|
|
(if (listp simula-continued-statement-offset)
|
|
|
|
|
(car simula-continued-statement-offset)
|
|
|
|
|
simula-continued-statement-offset))))
|
|
|
|
|
(setq start-line
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(line-beginning-position)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
continued nil))
|
|
|
|
|
;; search failed .. point is at beginning of line
|
|
|
|
|
;; determine if we should continue searching
|
|
|
|
|
;; (at or before comment or label)
|
|
|
|
|
;; temp = t means finished
|
|
|
|
|
(setq temp
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(and (not (simula-context))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-forward " \t\f")
|
|
|
|
|
(or (looking-at "virtual")
|
|
|
|
|
(not
|
|
|
|
|
(looking-at
|
|
|
|
|
"!\\|comment\\>\\|[a-z0-9_]*[ \t\f]*:[^-=]")))))
|
|
|
|
|
prev-cont continued)
|
|
|
|
|
;; if we are finished, find current line's indentation
|
|
|
|
|
(if temp
|
|
|
|
|
(setq indent (+ indent (current-indentation))))
|
|
|
|
|
;; find next line with non-comment SIMULA text
|
|
|
|
|
;; maybe indent extra if statement continues
|
|
|
|
|
(simula-skip-comment-backward)
|
|
|
|
|
(setq continued
|
|
|
|
|
(and (not (bobp))
|
|
|
|
|
(if (eq (char-syntax (preceding-char)) ?w)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(not (looking-at
|
|
|
|
|
"begin\\|then\\|else\\|when\\|otherwise\\|do")))
|
|
|
|
|
(not (memq (preceding-char) '(?: ?\;))))))
|
|
|
|
|
;; if we the state of the continued-variable
|
1993-06-09 11:59:12 +00:00
|
|
|
|
;; changed, add indentation for continued statement
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(if (or (and prev-cont (not continued))
|
|
|
|
|
(and continued
|
|
|
|
|
(listp simula-continued-statement-offset)))
|
|
|
|
|
(setq indent
|
|
|
|
|
(+ indent
|
|
|
|
|
(if (listp simula-continued-statement-offset)
|
|
|
|
|
(car simula-continued-statement-offset)
|
|
|
|
|
simula-continued-statement-offset))))
|
|
|
|
|
;; while ends if point is at beginning of line at loop test
|
|
|
|
|
(if (not temp)
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(setq start-line (line-beginning-position))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(beginning-of-line))))
|
|
|
|
|
;;
|
1993-06-09 11:59:12 +00:00
|
|
|
|
;; return indentation
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;;
|
|
|
|
|
indent)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-find-if ()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Find starting IF of a IF-THEN[-ELSE[-IF-THEN...]] statement."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(catch 'simula-out
|
|
|
|
|
(while t
|
|
|
|
|
(if (and (simula-search-backward "\\<if\\>\\|;\\|\\<begin\\>"nil t)
|
|
|
|
|
(memq (following-char) '(?I ?i)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
;;
|
|
|
|
|
;; find out if this IF was really the start of the IF statement
|
|
|
|
|
;;
|
|
|
|
|
(simula-skip-comment-backward)
|
|
|
|
|
(if (and (eq (char-syntax (preceding-char)) ?w)
|
|
|
|
|
(progn
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(looking-at "else\\>")))
|
|
|
|
|
()
|
|
|
|
|
(throw 'simula-out t)))
|
|
|
|
|
(if (not (looking-at "\\<if\\>"))
|
|
|
|
|
(error "Missing IF or misplaced BEGIN or ';' (can't find IF)")
|
|
|
|
|
;;
|
|
|
|
|
;; we were at the starting IF in the first place..
|
|
|
|
|
;;
|
|
|
|
|
(throw 'simula-out t))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-find-inspect ()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Find INSPECT matching WHEN or OTHERWISE."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(catch 'simula-out
|
|
|
|
|
(let ((level 0))
|
|
|
|
|
;;
|
|
|
|
|
;; INSPECTs can be nested, have to find the corresponding one
|
|
|
|
|
;;
|
|
|
|
|
(while t
|
|
|
|
|
(if (and (simula-search-backward "\\<inspect\\>\\|\\<otherwise\\>\\|;"
|
|
|
|
|
nil t)
|
|
|
|
|
(/= (following-char) ?\;))
|
|
|
|
|
(if (memq (following-char) '(?O ?o))
|
|
|
|
|
(setq level (1+ level))
|
|
|
|
|
(if (zerop level)
|
|
|
|
|
(throw 'simula-out t)
|
|
|
|
|
(setq level (1- level))))
|
|
|
|
|
(error "Missing INSPECT or misplaced ';' (can't find INSPECT)"))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-find-do-match ()
|
2003-02-11 21:19:36 +00:00
|
|
|
|
"Find keyword matching DO: FOR, WHILE, INSPECT or WHEN."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(while (and (re-search-backward
|
|
|
|
|
"\\<\\(do\\|for\\|while\\|inspect\\|when\\|end\\|begin\\)\\>\\|;"
|
|
|
|
|
nil 'move)
|
|
|
|
|
(simula-context)))
|
|
|
|
|
(if (and (looking-at "\\<\\(for\\|while\\|inspect\\|when\\)\\>")
|
|
|
|
|
(not (simula-context)))
|
|
|
|
|
() ;; found match
|
|
|
|
|
(error "No matching FOR, WHILE or INSPECT for DO, or misplaced ';'")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-inside-parens ()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Return position after `(' on line if inside parentheses, nil otherwise."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((parlevel 0))
|
|
|
|
|
(catch 'simula-out
|
|
|
|
|
(while t
|
|
|
|
|
(if (re-search-backward "(\\|)\\|;" nil t)
|
|
|
|
|
(if (eq (simula-context) nil)
|
|
|
|
|
;; found something - check it out
|
|
|
|
|
(cond
|
|
|
|
|
((eq (following-char) ?\;)
|
|
|
|
|
(if (zerop parlevel)
|
|
|
|
|
(throw 'simula-out nil)
|
1993-06-09 11:59:12 +00:00
|
|
|
|
(error "Parenthesis mismatch or misplaced ';'")))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
((eq (following-char) ?\()
|
|
|
|
|
(if (zerop parlevel)
|
|
|
|
|
(throw 'simula-out (1+ (current-column)))
|
|
|
|
|
(setq parlevel (1- parlevel))))
|
|
|
|
|
(t (setq parlevel (1+ parlevel))))
|
|
|
|
|
);; nothing - inside comment or string
|
|
|
|
|
;; search failed
|
|
|
|
|
(throw 'simula-out nil)))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-goto-definition ()
|
|
|
|
|
"Goto point of definition of variable, procedure or class."
|
|
|
|
|
(interactive))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-expand-stdproc ()
|
|
|
|
|
(if (or (not simula-abbrev-stdproc) (simula-context))
|
|
|
|
|
(unexpand-abbrev)
|
|
|
|
|
(cond
|
|
|
|
|
((eq simula-abbrev-stdproc 'upcase) (upcase-word -1))
|
|
|
|
|
((eq simula-abbrev-stdproc 'downcase) (downcase-word -1))
|
1996-04-21 01:39:51 +00:00
|
|
|
|
((eq simula-abbrev-stdproc 'capitalize) (capitalize-word -1))
|
|
|
|
|
((eq simula-abbrev-stdproc 'abbrev-table)
|
|
|
|
|
;; If not in lowercase, expansions are always capitalized.
|
|
|
|
|
;; We then want to replace with the exact expansion.
|
|
|
|
|
(if (equal (symbol-name last-abbrev) last-abbrev-text)
|
|
|
|
|
()
|
|
|
|
|
(downcase-word -1)
|
|
|
|
|
(expand-abbrev))))))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-expand-keyword ()
|
|
|
|
|
(if (or (not simula-abbrev-keyword) (simula-context))
|
|
|
|
|
(unexpand-abbrev)
|
|
|
|
|
(cond
|
|
|
|
|
((eq simula-abbrev-keyword 'upcase) (upcase-word -1))
|
|
|
|
|
((eq simula-abbrev-keyword 'downcase) (downcase-word -1))
|
1996-04-21 01:39:51 +00:00
|
|
|
|
((eq simula-abbrev-keyword 'capitalize) (capitalize-word -1))
|
|
|
|
|
((eq simula-abbrev-stdproc 'abbrev-table)
|
|
|
|
|
(if (equal (symbol-name last-abbrev) last-abbrev-text)
|
|
|
|
|
()
|
|
|
|
|
(downcase-word -1)
|
|
|
|
|
(expand-abbrev))))))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-electric-keyword ()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Expand SIMULA keyword. If it starts the line, reindent."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; redisplay
|
|
|
|
|
(let ((show-char (eq this-command 'self-insert-command)))
|
1993-06-09 11:59:12 +00:00
|
|
|
|
;; If the abbrev expansion results in reindentation, the user may have
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; to wait some time before the character he typed is displayed
|
|
|
|
|
;; (the char causing the expansion is inserted AFTER the hook function
|
|
|
|
|
;; is called). This is annoying in case of normal characters.
|
|
|
|
|
;; However, if the user pressed a key bound to newline, it is better
|
|
|
|
|
;; to have the line inserted after the begin-end match.
|
|
|
|
|
(if show-char
|
|
|
|
|
(progn
|
2009-01-09 04:23:38 +00:00
|
|
|
|
(insert-char last-command-event 1)
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(sit-for 0)
|
|
|
|
|
(backward-char 1)))
|
|
|
|
|
(if (let ((where (simula-context))
|
|
|
|
|
(case-fold-search t))
|
|
|
|
|
(if where
|
|
|
|
|
(if (and (eq where 2) (eq (char-syntax (preceding-char)) ?w))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(not (looking-at "end\\>"))))))
|
|
|
|
|
(unexpand-abbrev)
|
|
|
|
|
(cond
|
|
|
|
|
((not simula-abbrev-keyword) (unexpand-abbrev))
|
|
|
|
|
((eq simula-abbrev-keyword 'upcase) (upcase-word -1))
|
|
|
|
|
((eq simula-abbrev-keyword 'downcase) (downcase-word -1))
|
|
|
|
|
((eq simula-abbrev-keyword 'capitalize) (capitalize-word -1)))
|
|
|
|
|
(let ((pos (- (point-max) (point)))
|
2011-04-22 18:44:26 +00:00
|
|
|
|
(case-fold-search t))
|
|
|
|
|
(condition-case nil
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(progn
|
|
|
|
|
;; check if the expanded word is on the beginning of the line.
|
|
|
|
|
(if (and (eq (char-syntax (preceding-char)) ?w)
|
|
|
|
|
(progn
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(if (looking-at "end\\>")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(simula-backward-up-level 1)
|
|
|
|
|
(if (pos-visible-in-window-p)
|
|
|
|
|
(sit-for 1)
|
1996-01-25 00:57:23 +00:00
|
|
|
|
(message "Matches %s"
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(buffer-substring
|
|
|
|
|
(point)
|
1996-01-25 00:57:23 +00:00
|
|
|
|
(+ (point) (window-width)))))))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(skip-chars-backward " \t\f")
|
|
|
|
|
(bolp)))
|
|
|
|
|
(let ((indent (simula-calculate-indent)))
|
|
|
|
|
(if (eq indent (current-indentation))
|
|
|
|
|
()
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(indent-to indent)))
|
|
|
|
|
(skip-chars-forward " \t\f"))
|
|
|
|
|
;; check for END - blow whistles and ring bells
|
|
|
|
|
|
|
|
|
|
(goto-char (- (point-max) pos))
|
|
|
|
|
(if show-char
|
|
|
|
|
(delete-char 1)))
|
|
|
|
|
(quit (goto-char (- (point-max) pos))))))))
|
|
|
|
|
|
|
|
|
|
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(defun simula-search-backward (regexp &optional bound noerror)
|
2003-02-11 21:19:36 +00:00
|
|
|
|
"Search backward from point for regular expression REGEXP,
|
|
|
|
|
ignoring matches found inside SIMULA comments, string literals,
|
|
|
|
|
and BEGIN..END blocks.
|
1996-04-21 01:39:51 +00:00
|
|
|
|
Set point to the end of the occurrence found, and return point.
|
|
|
|
|
An optional second argument BOUND bounds the search, it is a buffer position.
|
|
|
|
|
The match found must not extend after that position. Optional third argument
|
|
|
|
|
NOERROR, if t, means if fail just return nil (no error).
|
|
|
|
|
If not nil and not t, move to limit of search and return nil."
|
2011-04-22 18:44:26 +00:00
|
|
|
|
(let ((comb-regexp (concat regexp "\\|\\<end\\>"))
|
|
|
|
|
(start-point (point))
|
|
|
|
|
context match)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(catch 'simula-backward
|
|
|
|
|
(while (re-search-backward comb-regexp bound 1)
|
|
|
|
|
;; We have a match, check SIMULA context at match-beginning
|
|
|
|
|
;; to see if we are outside comments etc.
|
|
|
|
|
;; Set MATCH to t if we found a true match,
|
|
|
|
|
;; set MATCH to 'BLOCK if we found a BEGIN..END block,
|
|
|
|
|
;; else set MATCH to nil.
|
|
|
|
|
(save-match-data
|
|
|
|
|
(setq context (simula-context))
|
|
|
|
|
(cond
|
|
|
|
|
((eq context nil)
|
|
|
|
|
(setq match (if (looking-at regexp) t 'BLOCK)))
|
2003-02-11 21:19:36 +00:00
|
|
|
|
;; A comment-ending `;' is part of the comment, and shouldn't match.
|
|
|
|
|
;; ((eq context 0)
|
|
|
|
|
;; (setq match (if (eq (following-char) ?\;) t nil)))
|
1996-04-21 01:39:51 +00:00
|
|
|
|
((eq context 2)
|
|
|
|
|
(setq match (if (and (looking-at regexp)
|
|
|
|
|
(looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>"))
|
|
|
|
|
t
|
|
|
|
|
(if (looking-at "\\<end\\>") 'BLOCK nil))))
|
|
|
|
|
(t (setq match nil))))
|
|
|
|
|
;; Exit if true match
|
|
|
|
|
(if (eq match t) (throw 'simula-backward (point)))
|
|
|
|
|
(if (eq match 'BLOCK)
|
|
|
|
|
;; We found the END of a block
|
|
|
|
|
(let ((level 0))
|
|
|
|
|
(while (natnump level)
|
|
|
|
|
(if (re-search-backward "\\<begin\\>\\|\\<end\\>" bound 1)
|
|
|
|
|
(let ((context (simula-context)))
|
|
|
|
|
;; We found a BEGIN -> decrease level count
|
|
|
|
|
(cond ((and (eq context nil)
|
|
|
|
|
(memq (following-char) '(?b ?B)))
|
|
|
|
|
(setq level (1- level)))
|
|
|
|
|
;; END -> increase level count
|
|
|
|
|
((and (memq context '(nil 2))
|
|
|
|
|
(memq (following-char) '(?e ?E)))
|
|
|
|
|
(setq level (1+ level)))))
|
|
|
|
|
;; Block search failed. Action depends on noerror.
|
|
|
|
|
(if (or (not noerror) (eq noerror t))
|
|
|
|
|
(goto-char start-point))
|
|
|
|
|
(if (not noerror)
|
|
|
|
|
(signal 'search-failed (list regexp)))
|
|
|
|
|
(throw 'simula-backward nil))))))
|
|
|
|
|
;; Search failed. Action depends on noerror.
|
|
|
|
|
(if (or (not noerror) (eq noerror t))
|
|
|
|
|
(goto-char start-point))
|
|
|
|
|
(if noerror
|
|
|
|
|
nil
|
|
|
|
|
(signal 'search-failed (list regexp))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun simula-search-forward (regexp &optional bound noerror)
|
2003-02-11 21:19:36 +00:00
|
|
|
|
"Search forward from point for regular expression REGEXP,
|
|
|
|
|
ignoring matches found inside SIMULA comments, string literals,
|
|
|
|
|
and BEGIN..END blocks.
|
1996-04-21 01:39:51 +00:00
|
|
|
|
Set point to the end of the occurrence found, and return point.
|
|
|
|
|
An optional second argument BOUND bounds the search, it is a buffer position.
|
|
|
|
|
The match found must not extend after that position. Optional third argument
|
|
|
|
|
NOERROR, if t, means if fail just return nil (no error).
|
|
|
|
|
If not nil and not t, move to limit of search and return nil."
|
2011-04-22 18:44:26 +00:00
|
|
|
|
(let ((comb-regexp (concat regexp "\\|\\<begin\\>"))
|
|
|
|
|
(start-point (point))
|
|
|
|
|
context match)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(catch 'simula-forward
|
|
|
|
|
(while (re-search-forward comb-regexp bound 1)
|
|
|
|
|
;; We have a match, check SIMULA context at match-beginning
|
|
|
|
|
;; to see if we are outside comments.
|
|
|
|
|
;; Set MATCH to t if we found a true match,
|
|
|
|
|
;; set MATCH to 'BLOCK if we found a BEGIN..END block,
|
|
|
|
|
;; else set MATCH to nil.
|
|
|
|
|
(save-match-data
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(setq context (simula-context))
|
|
|
|
|
(cond
|
|
|
|
|
((not context)
|
|
|
|
|
(setq match (if (looking-at regexp) t 'BLOCK)))
|
2003-02-11 21:19:36 +00:00
|
|
|
|
;; Comment-ending `;' is part of the comment, and shouldn't match.
|
|
|
|
|
;; ((eq context 0)
|
|
|
|
|
;; (setq match (if (eq (following-char) ?\;) t nil)))
|
1996-04-21 01:39:51 +00:00
|
|
|
|
((eq context 2)
|
|
|
|
|
(setq match (if (and (looking-at regexp)
|
|
|
|
|
(looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>")) t nil)))
|
|
|
|
|
(t (setq match nil)))))
|
|
|
|
|
;; Exit if true match
|
|
|
|
|
(if (eq match t) (throw 'simula-forward (point)))
|
|
|
|
|
(if (eq match 'BLOCK)
|
|
|
|
|
;; We found the BEGINning of a block
|
|
|
|
|
(let ((level 0))
|
|
|
|
|
(while (natnump level)
|
|
|
|
|
(if (re-search-forward "\\<begin\\>\\|\\<end\\>" bound 1)
|
|
|
|
|
(let ((context (simula-context)))
|
|
|
|
|
;; We found a BEGIN -> increase level count
|
|
|
|
|
(cond ((eq context nil) (setq level (1+ level)))
|
|
|
|
|
;; END -> decrease level count
|
|
|
|
|
((and (eq context 2)
|
|
|
|
|
;; Don't match BEGIN inside END comment
|
|
|
|
|
(memq (preceding-char) '(?d ?D)))
|
|
|
|
|
(setq level (1- level)))))
|
|
|
|
|
;; Block search failed. Action depends on noerror.
|
|
|
|
|
(if (or (not noerror) (eq noerror t))
|
|
|
|
|
(goto-char start-point))
|
|
|
|
|
(if (not noerror)
|
|
|
|
|
(signal 'search-failed (list regexp)))
|
|
|
|
|
(throw 'simula-forward nil))))))
|
|
|
|
|
;; Search failed. Action depends on noerror.
|
|
|
|
|
(if (or (not noerror) (eq noerror t))
|
|
|
|
|
(goto-char start-point))
|
|
|
|
|
(if noerror
|
|
|
|
|
nil
|
|
|
|
|
(signal 'search-failed (list regexp))))))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
1992-07-16 21:46:36 +00:00
|
|
|
|
(defun simula-install-standard-abbrevs ()
|
1993-09-06 12:59:18 +00:00
|
|
|
|
"Define Simula keywords, procedures and classes in local abbrev table."
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;; procedure and class names are as of the SIMULA 87 standard.
|
|
|
|
|
(interactive)
|
2003-02-25 01:45:55 +00:00
|
|
|
|
(dolist (args
|
1992-07-16 21:46:36 +00:00
|
|
|
|
'(("abs" "Abs" simula-expand-stdproc)
|
|
|
|
|
("accum" "Accum" simula-expand-stdproc)
|
|
|
|
|
("activate" "ACTIVATE" simula-expand-keyword)
|
|
|
|
|
("addepsilon" "AddEpsilon" simula-expand-stdproc)
|
|
|
|
|
("after" "AFTER" simula-expand-keyword)
|
|
|
|
|
("and" "AND" simula-expand-keyword)
|
|
|
|
|
("arccos" "ArcCos" simula-expand-stdproc)
|
|
|
|
|
("arcsin" "ArcSin" simula-expand-stdproc)
|
|
|
|
|
("arctan" "ArcTan" simula-expand-stdproc)
|
|
|
|
|
("arctan2" "ArcTan2" simula-expand-stdproc)
|
|
|
|
|
("array" "ARRAY" simula-expand-keyword)
|
|
|
|
|
("at" "AT" simula-expand-keyword)
|
|
|
|
|
("before" "BEFORE" simula-expand-keyword)
|
|
|
|
|
("begin" "BEGIN" simula-expand-keyword)
|
|
|
|
|
("blanks" "Blanks" simula-expand-stdproc)
|
|
|
|
|
("boolean" "BOOLEAN" simula-expand-keyword)
|
|
|
|
|
("breakoutimage" "BreakOutImage" simula-expand-stdproc)
|
|
|
|
|
("bytefile" "ByteFile" simula-expand-stdproc)
|
|
|
|
|
("call" "Call" simula-expand-stdproc)
|
|
|
|
|
("cancel" "Cancel" simula-expand-stdproc)
|
|
|
|
|
("cardinal" "Cardinal" simula-expand-stdproc)
|
|
|
|
|
("char" "Char" simula-expand-stdproc)
|
|
|
|
|
("character" "CHARACTER" simula-expand-keyword)
|
|
|
|
|
("checkpoint" "CheckPoint" simula-expand-stdproc)
|
|
|
|
|
("class" "CLASS" simula-expand-keyword)
|
|
|
|
|
("clear" "Clear" simula-expand-stdproc)
|
|
|
|
|
("clocktime" "ClockTime" simula-expand-stdproc)
|
|
|
|
|
("close" "Close" simula-expand-stdproc)
|
|
|
|
|
("comment" "COMMENT" simula-expand-keyword)
|
|
|
|
|
("constant" "Constant" simula-expand-stdproc)
|
|
|
|
|
("copy" "Copy" simula-expand-stdproc)
|
|
|
|
|
("cos" "Cos" simula-expand-stdproc)
|
|
|
|
|
("cosh" "CosH" simula-expand-stdproc)
|
|
|
|
|
("cotan" "CoTan" simula-expand-stdproc)
|
|
|
|
|
("cputime" "CpuTime" simula-expand-stdproc)
|
|
|
|
|
("current" "Current" simula-expand-stdproc)
|
|
|
|
|
("datetime" "DateTime" simula-expand-stdproc)
|
|
|
|
|
("decimalmark" "DecimalMark" simula-expand-stdproc)
|
|
|
|
|
("delay" "DELAY" simula-expand-keyword)
|
|
|
|
|
("deleteimage" "DeleteImage" simula-expand-stdproc)
|
|
|
|
|
("detach" "Detach" simula-expand-stdproc)
|
|
|
|
|
("digit" "Digit" simula-expand-stdproc)
|
|
|
|
|
("directbytefile" "DirectByteFile" simula-expand-stdproc)
|
|
|
|
|
("directfile" "DirectFile" simula-expand-stdproc)
|
|
|
|
|
("discrete" "Discrete" simula-expand-stdproc)
|
|
|
|
|
("do" "DO" simula-expand-keyword)
|
|
|
|
|
("downcase" "Downcase" simula-expand-stdproc)
|
|
|
|
|
("draw" "Draw" simula-expand-stdproc)
|
|
|
|
|
("eject" "Eject" simula-expand-stdproc)
|
|
|
|
|
("else" "ELSE" simula-electric-keyword)
|
|
|
|
|
("empty" "Empty" simula-expand-stdproc)
|
|
|
|
|
("end" "END" simula-electric-keyword)
|
|
|
|
|
("endfile" "Endfile" simula-expand-stdproc)
|
|
|
|
|
("entier" "Entier" simula-expand-stdproc)
|
|
|
|
|
("eq" "EQ" simula-expand-keyword)
|
|
|
|
|
("eqv" "EQV" simula-expand-keyword)
|
|
|
|
|
("erlang" "Erlang" simula-expand-stdproc)
|
|
|
|
|
("error" "Error" simula-expand-stdproc)
|
|
|
|
|
("evtime" "EvTime" simula-expand-stdproc)
|
|
|
|
|
("exp" "Exp" simula-expand-stdproc)
|
|
|
|
|
("external" "EXTERNAL" simula-expand-keyword)
|
|
|
|
|
("false" "FALSE" simula-expand-keyword)
|
|
|
|
|
("field" "Field" simula-expand-stdproc)
|
|
|
|
|
("file" "File" simula-expand-stdproc)
|
|
|
|
|
("first" "First" simula-expand-stdproc)
|
|
|
|
|
("follow" "Follow" simula-expand-stdproc)
|
|
|
|
|
("for" "FOR" simula-expand-keyword)
|
|
|
|
|
("ge" "GE" simula-expand-keyword)
|
|
|
|
|
("getchar" "GetChar" simula-expand-stdproc)
|
|
|
|
|
("getfrac" "GetFrac" simula-expand-stdproc)
|
|
|
|
|
("getint" "GetInt" simula-expand-stdproc)
|
|
|
|
|
("getreal" "GetReal" simula-expand-stdproc)
|
|
|
|
|
("go" "GO" simula-expand-keyword)
|
|
|
|
|
("goto" "GOTO" simula-expand-keyword)
|
|
|
|
|
("gt" "GT" simula-expand-keyword)
|
|
|
|
|
("head" "Head" simula-expand-stdproc)
|
|
|
|
|
("hidden" "HIDDEN" simula-expand-keyword)
|
|
|
|
|
("histd" "HistD" simula-expand-stdproc)
|
|
|
|
|
("histo" "Histo" simula-expand-stdproc)
|
|
|
|
|
("hold" "Hold" simula-expand-stdproc)
|
|
|
|
|
("idle" "Idle" simula-expand-stdproc)
|
|
|
|
|
("if" "IF" simula-expand-keyword)
|
|
|
|
|
("image" "Image" simula-expand-stdproc)
|
|
|
|
|
("imagefile" "ImageFile" simula-expand-stdproc)
|
|
|
|
|
("imp" "IMP" simula-expand-keyword)
|
|
|
|
|
("in" "IN" simula-expand-keyword)
|
|
|
|
|
("inbyte" "InByte" simula-expand-stdproc)
|
|
|
|
|
("inbytefile" "InByteFile" simula-expand-stdproc)
|
|
|
|
|
("inchar" "InChar" simula-expand-stdproc)
|
|
|
|
|
("infile" "InFile" simula-expand-stdproc)
|
|
|
|
|
("infrac" "InFrac" simula-expand-stdproc)
|
|
|
|
|
("inimage" "InImage" simula-expand-stdproc)
|
|
|
|
|
("inint" "InInt" simula-expand-stdproc)
|
|
|
|
|
("inner" "INNER" simula-expand-keyword)
|
|
|
|
|
("inreal" "InReal" simula-expand-stdproc)
|
|
|
|
|
("inrecord" "InRecord" simula-expand-stdproc)
|
|
|
|
|
("inspect" "INSPECT" simula-expand-keyword)
|
|
|
|
|
("integer" "INTEGER" simula-expand-keyword)
|
|
|
|
|
("intext" "InText" simula-expand-stdproc)
|
|
|
|
|
("into" "Into" simula-expand-stdproc)
|
|
|
|
|
("is" "IS" simula-expand-keyword)
|
|
|
|
|
("isochar" "ISOChar" simula-expand-stdproc)
|
|
|
|
|
("isopen" "IsOpen" simula-expand-stdproc)
|
|
|
|
|
("isorank" "ISORank" simula-expand-stdproc)
|
|
|
|
|
("label" "LABEL" simula-expand-keyword)
|
|
|
|
|
("last" "Last" simula-expand-stdproc)
|
|
|
|
|
("lastitem" "LastItem" simula-expand-stdproc)
|
|
|
|
|
("lastloc" "LastLoc" simula-expand-stdproc)
|
|
|
|
|
("le" "LE" simula-expand-keyword)
|
|
|
|
|
("length" "Length" simula-expand-stdproc)
|
|
|
|
|
("letter" "Letter" simula-expand-stdproc)
|
|
|
|
|
("line" "Line" simula-expand-stdproc)
|
|
|
|
|
("linear" "Linear" simula-expand-stdproc)
|
|
|
|
|
("linesperpage" "LinesPerPage" simula-expand-stdproc)
|
|
|
|
|
("link" "Link" simula-expand-stdproc)
|
|
|
|
|
("linkage" "Linkage" simula-expand-stdproc)
|
|
|
|
|
("ln" "Ln" simula-expand-stdproc)
|
|
|
|
|
("locate" "Locate" simula-expand-stdproc)
|
|
|
|
|
("location" "Location" simula-expand-stdproc)
|
|
|
|
|
("lock" "Lock" simula-expand-stdproc)
|
|
|
|
|
("locked" "Locked" simula-expand-stdproc)
|
|
|
|
|
("log10" "Log10" simula-expand-stdproc)
|
|
|
|
|
("long" "LONG" simula-expand-keyword)
|
|
|
|
|
("lowcase" "LowCase" simula-expand-stdproc)
|
|
|
|
|
("lowerbound" "LowerBound" simula-expand-stdproc)
|
|
|
|
|
("lowten" "LowTen" simula-expand-stdproc)
|
|
|
|
|
("lt" "LT" simula-expand-keyword)
|
|
|
|
|
("main" "Main" simula-expand-stdproc)
|
|
|
|
|
("max" "Max" simula-expand-stdproc)
|
|
|
|
|
("maxint" "MaxInt" simula-expand-stdproc)
|
|
|
|
|
("maxlongreal" "MaxLongReal" simula-expand-stdproc)
|
|
|
|
|
("maxloc" "MaxLoc" simula-expand-stdproc)
|
|
|
|
|
("maxrank" "MaxRank" simula-expand-stdproc)
|
|
|
|
|
("maxreal" "MaxReal" simula-expand-stdproc)
|
|
|
|
|
("min" "Min" simula-expand-stdproc)
|
|
|
|
|
("minint" "MinInt" simula-expand-stdproc)
|
|
|
|
|
("minlongreal" "MinLongReal" simula-expand-stdproc)
|
|
|
|
|
("minrank" "MinRank" simula-expand-stdproc)
|
|
|
|
|
("minreal" "MinReal" simula-expand-stdproc)
|
|
|
|
|
("mod" "Mod" simula-expand-stdproc)
|
|
|
|
|
("more" "More" simula-expand-stdproc)
|
|
|
|
|
("name" "NAME" simula-expand-keyword)
|
|
|
|
|
("ne" "NE" simula-expand-keyword)
|
|
|
|
|
("negexp" "NegExp" simula-expand-stdproc)
|
|
|
|
|
("new" "NEW" simula-expand-keyword)
|
|
|
|
|
("nextev" "NextEv" simula-expand-stdproc)
|
|
|
|
|
("none" "NONE" simula-expand-keyword)
|
|
|
|
|
("normal" "Normal" simula-expand-stdproc)
|
|
|
|
|
("not" "NOT" simula-expand-keyword)
|
|
|
|
|
("notext" "NOTEXT" simula-expand-keyword)
|
|
|
|
|
("open" "Open" simula-expand-stdproc)
|
|
|
|
|
("or" "OR" simula-expand-keyword)
|
|
|
|
|
("otherwise" "OTHERWISE" simula-electric-keyword)
|
|
|
|
|
("out" "Out" simula-expand-stdproc)
|
|
|
|
|
("outbyte" "OutByte" simula-expand-stdproc)
|
|
|
|
|
("outbytefile" "OutByteFile" simula-expand-stdproc)
|
|
|
|
|
("outchar" "OutChar" simula-expand-stdproc)
|
|
|
|
|
("outfile" "OutFile" simula-expand-stdproc)
|
|
|
|
|
("outfix" "OutFix" simula-expand-stdproc)
|
|
|
|
|
("outfrac" "OutFrac" simula-expand-stdproc)
|
|
|
|
|
("outimage" "OutImage" simula-expand-stdproc)
|
|
|
|
|
("outint" "OutInt" simula-expand-stdproc)
|
|
|
|
|
("outreal" "OutReal" simula-expand-stdproc)
|
|
|
|
|
("outrecord" "OutRecord" simula-expand-stdproc)
|
|
|
|
|
("outtext" "OutText" simula-expand-stdproc)
|
|
|
|
|
("page" "Page" simula-expand-stdproc)
|
|
|
|
|
("passivate" "Passivate" simula-expand-stdproc)
|
|
|
|
|
("poisson" "Poisson" simula-expand-stdproc)
|
|
|
|
|
("pos" "Pos" simula-expand-stdproc)
|
|
|
|
|
("precede" "Precede" simula-expand-stdproc)
|
|
|
|
|
("pred" "Pred" simula-expand-stdproc)
|
|
|
|
|
("prev" "Prev" simula-expand-stdproc)
|
|
|
|
|
("printfile" "PrintFile" simula-expand-stdproc)
|
|
|
|
|
("prior" "PRIOR" simula-expand-keyword)
|
|
|
|
|
("procedure" "PROCEDURE" simula-expand-keyword)
|
|
|
|
|
("process" "Process" simula-expand-stdproc)
|
|
|
|
|
("protected" "PROTECTED" simula-expand-keyword)
|
|
|
|
|
("putchar" "PutChar" simula-expand-stdproc)
|
|
|
|
|
("putfix" "PutFix" simula-expand-stdproc)
|
|
|
|
|
("putfrac" "PutFrac" simula-expand-stdproc)
|
|
|
|
|
("putint" "PutInt" simula-expand-stdproc)
|
|
|
|
|
("putreal" "PutReal" simula-expand-stdproc)
|
|
|
|
|
("qua" "QUA" simula-expand-keyword)
|
|
|
|
|
("randint" "RandInt" simula-expand-stdproc)
|
|
|
|
|
("rank" "Rank" simula-expand-stdproc)
|
|
|
|
|
("reactivate" "REACTIVATE" simula-expand-keyword)
|
|
|
|
|
("real" "REAL" simula-expand-keyword)
|
|
|
|
|
("ref" "REF" simula-expand-keyword)
|
|
|
|
|
("resume" "Resume" simula-expand-stdproc)
|
|
|
|
|
("setaccess" "SetAccess" simula-expand-stdproc)
|
|
|
|
|
("setpos" "SetPos" simula-expand-stdproc)
|
|
|
|
|
("short" "SHORT" simula-expand-keyword)
|
|
|
|
|
("sign" "Sign" simula-expand-stdproc)
|
|
|
|
|
("simset" "SimSet" simula-expand-stdproc)
|
|
|
|
|
("simulaid" "SimulaId" simula-expand-stdproc)
|
|
|
|
|
("simulation" "Simulation" simula-expand-stdproc)
|
|
|
|
|
("sin" "Sin" simula-expand-stdproc)
|
|
|
|
|
("sinh" "SinH" simula-expand-stdproc)
|
|
|
|
|
("sourceline" "SourceLine" simula-expand-stdproc)
|
|
|
|
|
("spacing" "Spacing" simula-expand-stdproc)
|
|
|
|
|
("sqrt" "Sqrt" simula-expand-stdproc)
|
|
|
|
|
("start" "Start" simula-expand-stdproc)
|
|
|
|
|
("step" "STEP" simula-expand-keyword)
|
|
|
|
|
("strip" "Strip" simula-expand-stdproc)
|
|
|
|
|
("sub" "Sub" simula-expand-stdproc)
|
|
|
|
|
("subepsilon" "SubEpsilon" simula-expand-stdproc)
|
|
|
|
|
("suc" "Suc" simula-expand-stdproc)
|
|
|
|
|
("switch" "SWITCH" simula-expand-keyword)
|
|
|
|
|
("sysin" "SysIn" simula-expand-stdproc)
|
|
|
|
|
("sysout" "SysOut" simula-expand-stdproc)
|
|
|
|
|
("tan" "Tan" simula-expand-stdproc)
|
|
|
|
|
("tanh" "TanH" simula-expand-stdproc)
|
|
|
|
|
("terminate_program" "Terminate_Program" simula-expand-stdproc)
|
|
|
|
|
("terminated" "Terminated" simula-expand-stdproc)
|
|
|
|
|
("text" "TEXT" simula-expand-keyword)
|
|
|
|
|
("then" "THEN" simula-electric-keyword)
|
|
|
|
|
("this" "THIS" simula-expand-keyword)
|
|
|
|
|
("time" "Time" simula-expand-stdproc)
|
|
|
|
|
("to" "TO" simula-expand-keyword)
|
|
|
|
|
("true" "TRUE" simula-expand-keyword)
|
|
|
|
|
("uniform" "Uniform" simula-expand-stdproc)
|
|
|
|
|
("unlock" "Unlock" simula-expand-stdproc)
|
|
|
|
|
("until" "UNTIL" simula-expand-keyword)
|
|
|
|
|
("upcase" "Upcase" simula-expand-stdproc)
|
|
|
|
|
("upperbound" "UpperBound" simula-expand-stdproc)
|
|
|
|
|
("value" "VALUE" simula-expand-keyword)
|
|
|
|
|
("virtual" "VIRTUAL" simula-expand-keyword)
|
|
|
|
|
("wait" "Wait" simula-expand-stdproc)
|
|
|
|
|
("when" "WHEN" simula-electric-keyword)
|
2003-02-25 01:45:55 +00:00
|
|
|
|
("while" "WHILE" simula-expand-keyword)))
|
|
|
|
|
(define-abbrev simula-mode-abbrev-table
|
|
|
|
|
(nth 0 args) (nth 1 args) (nth 2 args) nil 'system)))
|
|
|
|
|
|
|
|
|
|
(if simula-abbrev-file
|
|
|
|
|
(read-abbrev-file simula-abbrev-file))
|
|
|
|
|
(let (abbrevs-changed)
|
|
|
|
|
(simula-install-standard-abbrevs))
|
1992-07-16 21:46:36 +00:00
|
|
|
|
|
2003-02-11 21:19:36 +00:00
|
|
|
|
;; Hilit mode support.
|
* progmodes/mixal-mode.el (mixal-run, mixal-debug): Call mixvm
only if it is bound.
* textmodes/reftex.el: Move autoloads for before all uses.
(reftex-make-overlay, reftex-overlay-put, reftex-move-overlay)
(reftex-delete-overlay): Move to the top level with the condition
in the body.
* progmodes/simula.el: Use when instead of if.
* iimage.el (iimage-locate-file): Define unconditionally.
* mail/mailabbrev.el (mail-abbrev-next-line):
* emulation/vip.el (vip-enlarge-region, vip-line)
(vip-next-line-at-bol, vip-previous-line)
(vip-previous-line-at-bol, vip-find-char, vip-put-back, ex-read):
Wrap with-no-warnings around uses of next-line and previous-line.
* ediff.el (run-ediff-from-cvs-buffer):
* ediff-vers.el (cvs-run-ediff-on-file-descriptor): Remove
function not used by pcl-cvs anymore.
(noninteractive, generic-sc-get-latest-rev)
(ediff-generic-sc-internal, ediff-generic-sc-merge-internal):
Delete support for long obsolete generic-sc.el.
2007-10-31 06:28:09 +00:00
|
|
|
|
(when (fboundp 'hilit-set-mode-patterns)
|
|
|
|
|
(when (and (boundp 'hilit-patterns-alist)
|
|
|
|
|
(not (assoc 'simula-mode hilit-patterns-alist)))
|
1996-04-21 01:39:51 +00:00
|
|
|
|
(hilit-set-mode-patterns
|
|
|
|
|
'simula-mode
|
|
|
|
|
'(
|
|
|
|
|
("^%\\([ \t\f].*\\)?$" nil comment)
|
|
|
|
|
("^%include\\>" nil include)
|
|
|
|
|
("\"[^\"\n]*\"\\|'.'\\|'![0-9]+!'" nil string)
|
|
|
|
|
("\\<\\(ACTIVATE\\|AFTER\\|AND\\|ARRAY\\|AT\\|BEFORE\\|BEGIN\\|BOOLEAN\\|CHARACTER\\|CLASS\\|DELAY\\|DO\\|ELSE\\|END\\|EQ\\|EQV\\|EXTERNAL\\|FALSE\\|FOR\\|GE\\|GO\\|GOTO\\|GT\\|HIDDEN\\|IF\\|IMP\\|IN\\|INNER\\|INSPECT\\|INTEGER\\|IS\\|LABEL\\|LE\\|LONG\\|LT\\|NAME\\|NE\\|NEW\\|NONE\\|NOT\\|NOTEXT\\|OR\\|OTHERWISE\\|PRIOR\\|PROCEDURE\\|PROTECTED\\|QUA\\|REACTIVATE\\|REAL\\|REF\\|SHORT\\|STEP\\|SWITCH\\|TEXT\\|THEN\\|THIS\\|TO\\|TRUE\\|UNTIL\\|VALUE\\|VIRTUAL\\|WHEN\\|WHILE\\)\\>" nil keyword)
|
|
|
|
|
("!\\|\\<COMMENT\\>" ";" comment))
|
* progmodes/mixal-mode.el (mixal-run, mixal-debug): Call mixvm
only if it is bound.
* textmodes/reftex.el: Move autoloads for before all uses.
(reftex-make-overlay, reftex-overlay-put, reftex-move-overlay)
(reftex-delete-overlay): Move to the top level with the condition
in the body.
* progmodes/simula.el: Use when instead of if.
* iimage.el (iimage-locate-file): Define unconditionally.
* mail/mailabbrev.el (mail-abbrev-next-line):
* emulation/vip.el (vip-enlarge-region, vip-line)
(vip-next-line-at-bol, vip-previous-line)
(vip-previous-line-at-bol, vip-find-char, vip-put-back, ex-read):
Wrap with-no-warnings around uses of next-line and previous-line.
* ediff.el (run-ediff-from-cvs-buffer):
* ediff-vers.el (cvs-run-ediff-on-file-descriptor): Remove
function not used by pcl-cvs anymore.
(noninteractive, generic-sc-get-latest-rev)
(ediff-generic-sc-internal, ediff-generic-sc-merge-internal):
Delete support for long obsolete generic-sc.el.
2007-10-31 06:28:09 +00:00
|
|
|
|
nil 'case-insensitive)))
|
1996-04-21 01:39:51 +00:00
|
|
|
|
|
|
|
|
|
;; defuns for submitting bug reports
|
|
|
|
|
|
2008-04-16 14:10:34 +00:00
|
|
|
|
(defconst simula-mode-help-address "bug-gnu-emacs@gnu.org"
|
2003-02-11 21:19:36 +00:00
|
|
|
|
"Address accepting submission of `simula-mode' bug reports.")
|
1996-04-21 01:39:51 +00:00
|
|
|
|
|
2013-02-23 21:49:41 +00:00
|
|
|
|
(make-obsolete-variable 'simula-mode-help-address 'report-emacs-bug-address
|
|
|
|
|
"24.4")
|
|
|
|
|
|
|
|
|
|
(define-obsolete-function-alias 'simula-submit-bug-report
|
|
|
|
|
'report-emacs-bug "24.4")
|
1996-04-21 01:39:51 +00:00
|
|
|
|
|
1999-08-10 17:09:16 +00:00
|
|
|
|
(provide 'simula)
|
1996-04-21 01:39:51 +00:00
|
|
|
|
|
1992-07-16 21:46:36 +00:00
|
|
|
|
;;; simula.el ends here
|