r3/tng-r3.el
author Tony Garnock-Jones <tonygarnockjones@gmail.com>
Wed, 16 Jan 2019 17:15:58 +0000
changeset 438 1fe179d53161
parent 67 fd7a6a55a7f3
permissions -rw-r--r--
Add missing primitive implementation for the plain interpreter.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     1
;;; tng-r3.el --- ThiNG r3 code editing commands for Emacs
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     2
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     3
;; Add code like the following to your .emacs to install:
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     4
;; (autoload 'tng-r3-mode "...path.to.wherever.you.put.this.file.../tng-r3.el" nil t)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     5
;; (setq auto-mode-alist (cons '("\\.tng\\'" . tng-r3-mode)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     6
;;                             auto-mode-alist))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     7
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     8
;; Copyright (C) 1988,94,96,2000  Free Software Foundation, Inc.
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     9
;; Copyright (C) 2003, 2005 Tony Garnock-Jones <tonyg@lshift.net>
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    10
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    11
;; This file is based on GNU Emacs' AWK mode (awk-mode.el).
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    12
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    13
;; This is free software; you can redistribute it and/or modify
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    14
;; it under the terms of the GNU General Public License as published by
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    15
;; the Free Software Foundation; either version 2, or (at your option)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    16
;; any later version.
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    17
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    18
;; This is distributed in the hope that it will be useful,
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    19
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    20
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    21
;; GNU General Public License for more details.
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    22
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    23
;; You should have received a copy of the GNU General Public License
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    24
;; along with this software; see the file COPYING.  If not, write to the
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    25
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    26
;; Boston, MA 02111-1307, USA.
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    27
35
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
    28
(require 'cmuscheme)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
    29
(require 'comint)
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    30
(require 'cc-mode)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    31
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    32
(defvar tng-r3-mode-syntax-table nil
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    33
  "Syntax table in use in tng-r3-mode buffers.")
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    34
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    35
(if tng-r3-mode-syntax-table
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    36
    ()
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    37
  (setq tng-r3-mode-syntax-table (make-syntax-table))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    38
  (cond ((memq '8-bit c-emacs-features) ;; XEmacs
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    39
	 (modify-syntax-entry ?\" "! " tng-r3-mode-syntax-table))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    40
	((memq '1-bit c-emacs-features) ;; Proper Emacs
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    41
	 (modify-syntax-entry ?\" "! " tng-r3-mode-syntax-table)))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    42
  (modify-syntax-entry ?_ "_" tng-r3-mode-syntax-table)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    43
  (mapcar #'(lambda (x) (modify-syntax-entry x "." tng-r3-mode-syntax-table))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    44
	  '(?, ?\; ?- ?+ ?= ?| ?/ ?? ?. ?< ?> ?* ?& ?^ ?% ?$ ?# ?@ ?! ?` ?~))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    45
  (modify-syntax-entry ?\' "\"" tng-r3-mode-syntax-table))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    46
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    47
(defconst tng-r3-font-lock-keywords
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    48
  (eval-when-compile
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    49
    (list
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    50
     '(";;" . font-lock-warning-face)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    51
34
570a02bb7a27 New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 33
diff changeset
    52
     ;; Atoms.
51
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    53
     ;;'("\\.\\<\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>" . font-lock-constant-face)
34
570a02bb7a27 New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 33
diff changeset
    54
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    55
     ;; Keywords.
45
604988e365e5 Dot for quote, instead of hash
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 35
diff changeset
    56
     '("\\<define\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>" . font-lock-keyword-face)
51
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    57
     ;; '("\\<\\(new\\)\\s \\([a-zA-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\|::\\)*\\)\\>"
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    58
     ;;   (1 font-lock-keyword-face) (2 font-lock-type-face))
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    59
     (regexp-opt
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    60
      '(
51
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    61
	"do"
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    62
	"in"
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    63
	"let"
54
4f1328b847bb Add self as a keyword for syntax highlighting
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 52
diff changeset
    64
	"self"
51
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    65
	;;"letrec"
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    66
	"module"
51
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    67
	;;"new"
34
570a02bb7a27 New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 33
diff changeset
    68
	"return"
67
fd7a6a55a7f3 Sketch of sample code
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 54
diff changeset
    69
	"case"
fd7a6a55a7f3 Sketch of sample code
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 54
diff changeset
    70
	"of"
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    71
	)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    72
      'words)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    73
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    74
     ;; Namespaces.
45
604988e365e5 Dot for quote, instead of hash
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 35
diff changeset
    75
     '("\\<[A-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>::" . font-lock-type-face)
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    76
51
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    77
     ;; Selectors.
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    78
     ;;'("\\<[A-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>:" . font-lock-function-name-face)
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    79
67
fd7a6a55a7f3 Sketch of sample code
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 54
diff changeset
    80
     ;; Symbols (by convention).
fd7a6a55a7f3 Sketch of sample code
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 54
diff changeset
    81
     '("\\<[A-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>" . font-lock-type-face)
51
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    82
     ;;'("\\<[A-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>" . font-lock-constant-face)
34
570a02bb7a27 New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 33
diff changeset
    83
570a02bb7a27 New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 33
diff changeset
    84
     ;; Functions.
51
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    85
     ;;'("(\\(\\<[a-zA-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>\\)\\($\\|\\s [^-+=_|/?<>*&^%$@!`~#]\\)"
e9fafa149b08 Muck about with yet /another/ experimental syntax
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    86
     ;;(1 font-lock-function-name-face))
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    87
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    88
     ;; Variables.
52
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 51
diff changeset
    89
     ;'("+\\<[a-zA-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>" . font-lock-variable-name-face)
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 51
diff changeset
    90
     '("\\.\\<[a-zA-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>" . font-lock-variable-name-face)
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 51
diff changeset
    91
     ;'("\\<[a-zA-Z]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>@" . font-lock-variable-name-face)
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    92
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    93
     ;; Infixops.
45
604988e365e5 Dot for quote, instead of hash
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 35
diff changeset
    94
     '("\\<[-+=_|/?<>*&^%$@!`~]\\([-a-zA-Z0-9+=_|/?<>*&^%$@!`~]\\)*\\>"
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    95
       . font-lock-function-name-face)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    96
     ))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    97
 "Default expressions to highlight in TNG-R3 mode.")
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    98
35
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
    99
(defun tng-mode-variables ()
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   100
  (make-local-variable 'comment-start)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   101
  (make-local-variable 'comment-end)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   102
  (make-local-variable 'comment-start-skip)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   103
  (setq comment-start "\"")
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   104
  (setq comment-end "\"")
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   105
  (setq comment-start-skip "\" *")
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   106
  (make-local-variable 'c-syntactic-indentation)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   107
  (setq c-syntactic-indentation nil)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   108
  (make-local-variable 'font-lock-defaults)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   109
  (setq font-lock-defaults '(tng-r3-font-lock-keywords nil nil ((?_ . "w")))))
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   110
35
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   111
;;;###autoload
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   112
(define-derived-mode tng-r3-mode c-mode "TNG-R3"
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   113
  "Major mode for editing TNG-R3 code.
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   114
This is much like C mode except for the syntax of comments.  Its keymap
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   115
inherits from C mode's and it has the same variables for customizing
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   116
indentation.  It has its own abbrev table and its own syntax table.
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   117
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   118
Turning on TNG-R3 mode runs `tng-r3-mode-hook'." ;; actually a lie
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   119
  (tng-mode-variables))
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   120
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   121
;---------------------------------------------------------------------------
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   122
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   123
(defcustom tng-program-name "./main.scm"
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   124
  "*Program invoked by the `run-tng' command."
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   125
  :type 'string
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   126
  :group 'tng)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   127
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   128
(defcustom inferior-tng-mode-hook nil
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   129
  "*Hook for customising inferior-tng mode."
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   130
  :type 'hook
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   131
  :group 'tng)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   132
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   133
(defvar tng-buffer)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   134
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   135
(define-derived-mode inferior-tng-mode comint-mode "Inferior ThiNG"
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   136
  "Major mode for interacting with an inferior ThiNG process."
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   137
  ;; Customise in inferior-tng-mode-hook
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   138
  (setq comint-prompt-regexp "^\"[^\"\n]*\" *")
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   139
  (tng-mode-variables)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   140
  (setq mode-line-process '(":%s")))
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   141
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   142
;;;###autoload
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   143
(defun run-tng (cmd)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   144
  "Run an inferior ThiNG process, input and output via buffer *tng*.
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   145
If there is a process already running in `*tng*', switch to that buffer.
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   146
With argument, allows you to edit the command line (default is value
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   147
of `tng-program-name').  Runs the hooks `inferior-tng-mode-hook'
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   148
\(after the `comint-mode-hook' is run).
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   149
\(Type \\[describe-mode] in the process buffer for a list of commands.)"
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   150
  (interactive (list (if current-prefix-arg
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   151
			 (read-string "Run ThiNG: " tng-program-name)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   152
		       tng-program-name)))
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   153
  (if (not (comint-check-proc "*tng*"))
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   154
      (let ((cmdlist (scheme-args-to-list cmd)))
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   155
	(set-buffer (apply 'make-comint "tng" (car cmdlist)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   156
			   nil (cdr cmdlist)))
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   157
	(inferior-tng-mode)))
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   158
  (setq tng-program-name cmd)
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   159
  (setq tng-buffer "*tng*")
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   160
  (pop-to-buffer "*tng*"))
0415292cf581 Printer for ThiNG CST; improved emacs mode, including comint run-tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 34
diff changeset
   161
33
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   162
(provide 'tng-r3-mode)
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   163
ca497a9ada93 Move to R3.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
   164
;;; tng-r3.el ends here