home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / lib / emacs / lisp / modula2.elc < prev    next >
Text File  |  1991-01-09  |  10KB  |  151 lines

  1.  
  2. (defvar m2-mode-syntax-table nil "\
  3. Syntax table in use in Modula-2-mode buffers.")
  4.  
  5. (defvar m2-compile-command "m2c" "\
  6. Command to compile Modula-2 programs")
  7.  
  8. (defvar m2-link-command "m2l" "\
  9. Command to link Modula-2 programs")
  10.  
  11. (defvar m2-link-name nil "\
  12. Name of the executable.")
  13.  
  14. (if m2-mode-syntax-table nil (let ((table (make-syntax-table))) (modify-syntax-entry 92 "\\" table) (modify-syntax-entry 40 ". 1" table) (modify-syntax-entry 41 ". 4" table) (modify-syntax-entry 42 ". 23" table) (modify-syntax-entry 43 "." table) (modify-syntax-entry 45 "." table) (modify-syntax-entry 61 "." table) (modify-syntax-entry 37 "." table) (modify-syntax-entry 60 "." table) (modify-syntax-entry 62 "." table) (modify-syntax-entry 39 "\"" table) (setq m2-mode-syntax-table table)))
  15.  
  16. (defvar m2-mode-map nil "\
  17. Keymap used in Modula-2 mode.")
  18.  
  19. (if m2-mode-map nil (let ((map (make-sparse-keymap))) (define-key map "    " (quote m2-tab)) (define-key map "b" (quote m2-begin)) (define-key map "c" (quote m2-case)) (define-key map "d" (quote m2-definition)) (define-key map "e" (quote m2-else)) (define-key map "f" (quote m2-for)) (define-key map "h" (quote m2-header)) (define-key map "i" (quote m2-if)) (define-key map "m" (quote m2-module)) (define-key map "l" (quote m2-loop)) (define-key map "o" (quote m2-or)) (define-key map "p" (quote m2-procedure)) (define-key map "" (quote m2-with)) (define-key map "r" (quote m2-record)) (define-key map "s" (quote m2-stdio)) (define-key map "t" (quote m2-type)) (define-key map "u" (quote m2-until)) (define-key map "v" (quote m2-var)) (define-key map "w" (quote m2-while)) (define-key map "x" (quote m2-export)) (define-key map "y" (quote m2-import)) (define-key map "{" (quote m2-begin-comment)) (define-key map "}" (quote m2-end-comment)) (define-key map "" (quote suspend-emacs)) (define-key map "" (quote m2-visit)) (define-key map "" (quote m2-toggle)) (define-key map " " (quote m2-link)) (define-key map "" (quote m2-compile)) (setq m2-mode-map map)))
  20.  
  21. (defvar m2-indent 5 "\
  22. *This variable gives the indentation in Modula-2-Mode")
  23.  
  24. (defun modula-2-mode nil "\
  25. This is a mode intended to support program development in Modula-2.
  26. All control constructs of Modula-2 can be reached by typing
  27. Control-C followed by the first character of the construct.
  28. \\{m2-mode-map}
  29.   Control-c b begin         Control-c c case
  30.   Control-c d definition    Control-c e else
  31.   Control-c f for           Control-c h header
  32.   Control-c i if            Control-c m module
  33.   Control-c l loop          Control-c o or
  34.   Control-c p procedure     Control-c Control-w with
  35.   Control-c r record        Control-c s stdio
  36.   Control-c t type          Control-c u until
  37.   Control-c v var           Control-c w while
  38.   Control-c x export        Control-c y import
  39.   Control-c { begin-comment Control-c } end-comment
  40.   Control-c Control-z suspend-emacs     Control-c Control-t toggle
  41.   Control-c Control-c compile           Control-x ` next-error
  42.   Control-c Control-l link
  43.  
  44.    m2-indent controls the number of spaces for each indentation.
  45.    m2-compile-command holds the command to compile a Modula-2 program.
  46.    m2-link-command holds the command to link a Modula-2 program." (interactive) (byte-code "±È¼ È½!ȾÉÈàÉÈáˆ!ÈâÉÈá˜!ÈãÉÈä!Èá˘!ÈåPÉÈá¨!ÈÉÈá²!È˚É    Èá¸!È˚É Èá³!ÈçÉ Èá˝!ÈèÉÈáˆ!ÈâÉÈá˛!ÈéÉÈáˇ!ÈêÉÈá—!È˚ÉÈëì!Ç" [m2-mode-map major-mode mode-name comment-column end-comment-column m2-mode-syntax-table paragraph-start page-delimiter paragraph-separate paragraph-ignore-fill-prefix t require-final-newline comment-start comment-end comment-start-skip comment-indent-hook parse-sexp-ignore-comments nil kill-all-local-variables use-local-map modula-2-mode "Modula-2" make-local-variable 41 75 set-syntax-table "^$\\|" "(* " " *)" "/\\*+ *" c-comment-indent run-hooks m2-mode-hook] 17))
  47.  
  48. (defun m2-newline nil "\
  49. Insert a newline and indent following line like previous line." (interactive) (byte-code "ˋÈ´ ˆ Èj)Ç" [hpos nil current-indentation newline] 3))
  50.  
  51. (defun m2-tab nil "\
  52. Indent to next tab stop." (interactive) (byte-code "ˋÈ´ˆ˜ \"T\"jÇ" [m2-indent nil * / current-indentation] 5))
  53.  
  54. (defun m2-begin nil "\
  55. Insert a BEGIN keyword and indent for the next line." (interactive) (byte-code "¹ÈˋcÈ´ Èˆ Ç" [nil "BEGIN" m2-newline m2-tab] 3))
  56.  
  57. (defun m2-case nil "\
  58. Build skeleton CASE statment, prompting for the <expression>." (interactive) (byte-code "¹Èˋ´ˆ˜!¯#È˘ È˘ È˙cȨ²!È˚ Ç" [nil insert "CASE " read-string ": " " OF" m2-newline "END (* case *);" end-of-line 0 m2-tab] 7))
  59.  
  60. (defun m2-definition nil "\
  61. Build skeleton DEFINITION MODULE, prompting for the <module name>." (interactive) (byte-code "ˋÈ´cȈ˜!¯˘˙$)Ȩ²!Ç" [name nil "DEFINITION MODULE " read-string "Name: " insert ";
  62.  
  63.  
  64.  
  65. END " ".
  66. " previous-line 3] 6))
  67.  
  68. (defun m2-else nil "\
  69. Insert ELSE keyword and indent for next line." (interactive) (byte-code "ˋÈ´ Èˆˋ\"ȘcÈ´ È¯ Ç" [m2-indent nil m2-newline backward-delete-char-untabify "ELSE" m2-tab] 5))
  70.  
  71. (defun m2-for nil "\
  72. Build skeleton FOR loop statment, prompting for the loop parameters." (interactive) (byte-code "ˋÈ´ˆ˜¯!˘˜˙!$Ș¨!²˚\"?Ä´¸\")ȳcÈ˝ È˝ È˛cÈˇ—!ȱ Ç" [by nil insert "FOR " read-string "init: " " TO " "end: " "by: " string-equal "" " BY " " DO" m2-newline "END (* for *);" end-of-line 0 m2-tab] 11))
  73.  
  74. (defun m2-header nil "\
  75. Insert a comment block containing the module title, author, etc." (interactive) (byte-code "¹ÈˋcÈ´ˆ!cȘcȯ cÈ˘cÈ˙ cȨ²˚ ¸³ ˝%cÈ˛cÇ" [nil "(*
  76.     Title:     " read-string "Title: " "
  77.     Created:    " current-time-string "
  78.     Author:     " user-full-name concat "
  79.         <" user-login-name "@" system-name ">
  80. " "*)
  81.  
  82. "] 11))
  83.  
  84. (defun m2-if nil "\
  85. Insert skeleton IF statment, prompting for <boolean-expression>." (interactive) (byte-code "¹Èˋ´ˆ˜!¯#È˘ È˘ È˙cȨ²!È˚ Ç" [nil insert "IF " read-string "<boolean-expression>: " " THEN" m2-newline "END (* if *);" end-of-line 0 m2-tab] 7))
  86.  
  87. (defun m2-loop nil "\
  88. Build skeleton LOOP (with END)." (interactive) (byte-code "¹ÈˋcÈ´ È´ ÈˆcȘ¯!È˘ Ç" [nil "LOOP" m2-newline "END (* loop *);" end-of-line 0 m2-tab] 5))
  89.  
  90. (defun m2-module nil "\
  91. Build skeleton IMPLEMENTATION MODULE, prompting for <module-name>." (interactive) (byte-code "ˋÈ´cȈ˜!¯˘˙$)Ȩ²!Ç" [name nil "IMPLEMENTATION MODULE " read-string "Name: " insert ";
  92.  
  93.  
  94.  
  95. END " ".
  96. " previous-line 3] 6))
  97.  
  98. (defun m2-or nil (interactive) (byte-code "ˋÈ´ Èˆ!ȘcÈ´ È¯ Ç" [m2-indent nil m2-newline backward-delete-char-untabify "|" m2-tab] 5))
  99.  
  100. (defun m2-procedure nil (interactive) (byte-code "´ÈˆcȘ¯!´˘˙\"È˘˜¨!²\"Ș˚!Éȸ    ³\"?Ä)˘˝    \"È˛cÈˇ È—cÈˇ Èˇ È±cÈcÈ˛cȼ½!Ⱦ *Ç" [name args nil "PROCEDURE " read-string "Name: " insert " (" "Arguments: " ")" "Result Type: " string-equal "" " : " ";" m2-newline "BEGIN" "END " end-of-line 0 m2-tab] 13))
  101.  
  102. (defun m2-with nil (interactive) (byte-code "¹ÈˋcÈ´ˆ!cȘcȯ È¯ È˘cÈ˙¨!Ȳ Ç" [nil "WITH " read-string ": " " DO" m2-newline "END (* with *);" end-of-line 0 m2-tab] 6))
  103.  
  104. (defun m2-record nil (interactive) (byte-code "¹ÈˋcÈ´ È´ ÈˆcȘ¯!È˘ Ç" [nil "RECORD" m2-newline "END (* record *);" end-of-line 0 m2-tab] 5))
  105.  
  106. (defun m2-stdio nil (interactive) (byte-code "¹ÈˋcÇ" [nil "
  107. >FROM TextIO IMPORT 
  108.    WriteCHAR, ReadCHAR, WriteINTEGER, ReadINTEGER,
  109.    WriteCARDINAL, ReadCARDINAL, WriteBOOLEAN, ReadBOOLEAN,
  110.    WriteREAL, ReadREAL, WriteBITSET, ReadBITSET,
  111.    WriteBasedCARDINAL, ReadBasedCARDINAL, WriteChars, ReadChars,
  112.    WriteString, ReadString, WhiteSpace, EndOfLine;
  113.  
  114. >FROM SysStreams IMPORT sysIn, sysOut, sysErr;
  115.  
  116. "] 1))
  117.  
  118. (defun m2-type nil (interactive) (byte-code "¹ÈˋcÈ´ Èˆ Ç" [nil "TYPE" m2-newline m2-tab] 3))
  119.  
  120. (defun m2-until nil (interactive) (byte-code "¹ÈˋcÈ´ È´ ÈˆcȘ¯˘!˙\"Ȩ²!È˚ Ç" [nil "REPEAT" m2-newline "UNTIL " insert read-string ": " ";" end-of-line 0 m2-tab] 7))
  121.  
  122. (defun m2-var nil (interactive) (byte-code "¹Èˋ È´cÈˋ Èˆ Ç" [nil m2-newline "VAR" m2-tab] 4))
  123.  
  124. (defun m2-while nil (interactive) (byte-code "¹ÈˋcÈ´ˆ!cȘcȯ È¯ È˘cÈ˙¨!Ȳ Ç" [nil "WHILE " read-string ": " " DO" m2-newline "END (* while *);" end-of-line 0 m2-tab] 6))
  125.  
  126. (defun m2-export nil (interactive) (byte-code "¹ÈˋcÇ" [nil "EXPORT QUALIFIED "] 1))
  127.  
  128. (defun m2-import nil (interactive) (byte-code "¹ÈˋcÈ´ˆ!cȘcÇ" [nil "FROM " read-string "Module: " " IMPORT "] 2))
  129.  
  130. (defun m2-begin-comment nil (interactive) (byte-code "ˋÈn?Ä ´ˆ\"ȘcÇ" [comment-column nil indent-to 0 "(*  "] 3))
  131.  
  132. (defun m2-end-comment nil (interactive) (byte-code "ˋÈn?Ä    jÈ´cÇ" [end-comment-column nil "*)"] 1))
  133.  
  134. (defun m2-compile nil (interactive) (byte-code "´Èˆ ÉȘ    ¯Q!Ç" [modulename m2-compile-command nil buffer-name compile " "] 5))
  135.  
  136. (defun m2-link nil (interactive) (byte-code "ˆÈ˜ ÉÈ    Â¯
  137. ˘    Q!Á¯
  138. ˘˙¨\"ÉQ!Ç" [modulename m2-link-name m2-link-command nil buffer-name compile " " read-string "Name of executable: "] 8))
  139.  
  140. (defun execute-monitor-command (command) (byte-code "    ˘˙!¨\"²ˆ˜˜˚¸P&*Ç" [shell shell-file-name csh nil t command equal file-name-nondirectory "csh" call-process "-cf" "exec "] 10))
  141.  
  142. (defun m2-visit nil (interactive) (byte-code "ˋÈˋˋˋʘ¯!ÉÈ˘˙!Ȩ² P!ÈebÈˋ˚¸ÏÈˋ³˝ÏÈÅ+
  143. ?Ä3˛ˇ \")ÈÂI—!È
  144. ÄFÊ—
  145. !)ÁP
  146. ÄP—
  147. !+Ç" [deffile nil modfile modulename read-string "Module name: " switch-to-buffer "*Command Execution*" execute-monitor-command "m2whereis " (byte-code "ˋ´!Ȉ˜¯!˘¯!\"ÉÇ" [deffile re-search-forward "\\(.*\\.def\\) *$" buffer-substring match-beginning 1 match-end] 6) ((search-failed (byte-code "¹Ç" [nil] 1))) (byte-code "ˋ´!Ȉ˜¯!˘¯!\"ÉÇ" [modfile re-search-forward "\\(.*\\.mod\\) *$" buffer-substring match-beginning 1 match-end] 6) ((search-failed (byte-code "¹Ç" [nil] 1))) error "I can find neither definition nor implementation of %s" find-file] 8))
  148.  
  149. (defun m2-toggle nil "\
  150. Toggle between .mod and .def files for the module." (interactive) (byte-code "¹Èˋ´ ˆ¹O˜\"¯´ ˘ˆO˙P!Á[ˋ´ ˆ¹O˙\"Â0¯´ ˘ˆO˜P!Á[ˋ´ ¨¹O²\"ÂG¯´ ˘¨O˚P!Á[ˋ´ ¨¹O˚\"Ä[¯´ ˘¨O²P!Ç" [nil string-equal buffer-name -4 ".def" find-file-other-window 0 ".mod" -3 ".mi" ".md"] 19))
  151.