modula2.elc 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. (defvar m2-mode-syntax-table nil "\
  2. Syntax table in use in Modula-2-mode buffers.")
  3. (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)))
  4. (defvar m2-mode-map nil "\
  5. Keymap used in Modula-2 mode.")
  6. (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)))
  7. (defvar m2-indent 5 "\
  8. *This variable gives the indentation in Modula-2-Mode")
  9. (defun modula-2-mode nil "\
  10. This is a mode intended to support program development in Modula-2.
  11. All control constructs of Modula-2 can be reached by typing
  12. Control-C followed by the first character of the construct.
  13. \\{m2-mode-map}
  14. Control-c b begin Control-c c case
  15. Control-c d definition Control-c e else
  16. Control-c f for Control-c h header
  17. Control-c i if Control-c m module
  18. Control-c l loop Control-c o or
  19. Control-c p procedure Control-c Control-w with
  20. Control-c r record Control-c s stdio
  21. Control-c t type Control-c u until
  22. Control-c v var Control-c w while
  23. Control-c x export Control-c y import
  24. Control-c { begin-comment Control-c } end-comment
  25. Control-c Control-z suspend-emacs Control-c Control-t toggle
  26. Control-c Control-c compile Control-x ` next-error
  27. Control-c Control-l link
  28. m2-indent controls the number of spaces for each indentation." (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 require-final-newline t 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] 16))
  29. (defun m2-tab nil "\
  30. Indent to next tab stop." (interactive) (byte-code "ÁˆÂÃÄ \"T\"j‡" [m2-indent nil * / current-indentation] 5))
  31. (defun m2-begin nil "\
  32. Insert a BEGIN keyword and indent for the next line." (interactive) (byte-code "ÀˆÁcˆÂ ˆÃ ‡" [nil "BEGIN" m2-newline m2-tab] 3))
  33. (defun m2-case nil "\
  34. 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))
  35. (defun m2-definition nil "\
  36. Build skeleton DEFINITION MODULE, prompting for the <module name>." (interactive) (byte-code "ÁˆÂcˆÃÄ!ÅÆÇ$)ˆÈÉ!‡" [name nil "DEFINITION MODULE " read-string "Name: " insert ";
  37. END " ".
  38. " previous-line 3] 6))
  39. (defun m2-else nil "\
  40. 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))
  41. (defun m2-for nil "\
  42. Build skeleton FOR loop statment, prompting for the loop parameters." (interactive) (byte-code "ÁˆÂÃÄÅ!ÆÅ$ˆÄÅ!ÇÈ\"?ƒÂÉ\"‚Á)ˆÊcˆË ˆË ˆÌcˆÍÎ!ˆÏ ‡" [by nil insert "FOR " read-string ": " " TO " string-equal "" " BY " " DO" m2-newline "END (* for *);" end-of-line 0 m2-tab] 10))
  43. (defun m2-header nil "\
  44. Insert a comment block containing the module title, author, etc." (interactive) (byte-code "ÀˆÁcˆÂÃ!cˆÄcˆÅ cˆÆcˆÇ cˆÈÉÊ ËÌ Í%cˆÎc‡" [nil "(*
  45. Title: " read-string "Title: " "
  46. Created: " current-time-string "
  47. Author: " user-full-name concat "
  48. <" user-login-name "@" system-name ">
  49. " "*)
  50. "] 11))
  51. (defun m2-if nil "\
  52. 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))
  53. (defun m2-loop nil "\
  54. Build skeleton LOOP (with END)." (interactive) (byte-code "ÀˆÁcˆÂ ˆÂ ˆÃcˆÄÅ!ˆÆ ‡" [nil "LOOP" m2-newline "END (* loop *);" end-of-line 0 m2-tab] 5))
  55. (defun m2-module nil "\
  56. Build skeleton IMPLEMENTATION MODULE, prompting for <module-name>." (interactive) (byte-code "ÁˆÂcˆÃÄ!ÅÆÇ$)ˆÈÉ!‡" [name nil "IMPLEMENTATION MODULE " read-string "Name: " insert ";
  57. END " ".
  58. " previous-line 3] 6))
  59. (defun m2-or nil (interactive) (byte-code "ÁˆÂ ˆÃ!ˆÄcˆÂ ˆÅ ‡" [m2-indent nil m2-newline backward-delete-char-untabify "|" m2-tab] 5))
  60. (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))
  61. (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))
  62. (defun m2-record nil (interactive) (byte-code "ÀˆÁcˆÂ ˆÂ ˆÃcˆÄÅ!ˆÆ ‡" [nil "RECORD" m2-newline "END (* record *);" end-of-line 0 m2-tab] 5))
  63. (defun m2-stdio nil (interactive) (byte-code "ÀˆÁc‡" [nil "
  64. >FROM TextIO IMPORT
  65. WriteCHAR, ReadCHAR, WriteINTEGER, ReadINTEGER,
  66. WriteCARDINAL, ReadCARDINAL, WriteBOOLEAN, ReadBOOLEAN,
  67. WriteREAL, ReadREAL, WriteBITSET, ReadBITSET,
  68. WriteBasedCARDINAL, ReadBasedCARDINAL, WriteChars, ReadChars,
  69. WriteString, ReadString, WhiteSpace, EndOfLine;
  70. >FROM SysStreams IMPORT sysIn, sysOut, sysErr;
  71. "] 1))
  72. (defun m2-type nil (interactive) (byte-code "ÀˆÁcˆÂ ˆÃ ‡" [nil "TYPE" m2-newline m2-tab] 3))
  73. (defun m2-until nil (interactive) (byte-code "ÀˆÁcˆÂ ˆÂ ˆÃcˆÄÅÆ!Ç\"ˆÈÉ!ˆÊ ‡" [nil "REPEAT" m2-newline "UNTIL " insert read-string ": " ";" end-of-line 0 m2-tab] 7))
  74. (defun m2-var nil (interactive) (byte-code "ÀˆÁ ˆÂcˆÁ ˆÃ ‡" [nil m2-newline "VAR" m2-tab] 4))
  75. (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))
  76. (defun m2-export nil (interactive) (byte-code "ÀˆÁc‡" [nil "EXPORT QUALIFIED "] 1))
  77. (defun m2-import nil (interactive) (byte-code "ÀˆÁcˆÂÃ!cˆÄc‡" [nil "FROM " read-string "Module: " " IMPORT "] 2))
  78. (defun m2-begin-comment nil (interactive) (byte-code "Áˆn?ƒÂÃ\"‚ÁˆÄc‡" [comment-column nil indent-to 0 "(* "] 3))
  79. (defun m2-end-comment nil (interactive) (byte-code "Áˆn?ƒ j‚ ÁˆÂc‡" [end-comment-column nil "*)"] 1))
  80. (defun m2-compile nil (interactive) (byte-code "ÁˆÂ ‰ˆÃÄP!‡" [modulename nil buffer-name compile "m2c "] 4))
  81. (defun m2-link nil (interactive) (byte-code "ÁˆÂ ‰ˆÃÄÅÆOP!‡" [modulename nil buffer-name compile "m2l " 0 -4] 6))
  82. (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))
  83. (defun m2-visit nil (interactive) (byte-code "ÁˆÁÁÁŠÄÅ!‰ˆÆÇ!ˆÈÉ P!ˆebˆÁÊË�ˆÁÌÍ�ˆ†+
  84. ?ƒ6ÎÏ \"‚7Á)ˆƒQÐ!ˆ
  85. ƒMŠÐ
  86. !)‚NÁ‚X
  87. …XÐ
  88. !+‡" [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))
  89. (defun m2-toggle nil "\
  90. Toggle between .mod and .def files for the module." (interactive) (byte-code "ÀˆÁ ÃÀOÄ\"ƒÅ ÆÃOÇP!‚-Á ÃÀOÇ\"…-Å ÆÃOÄP!‡" [nil string-equal buffer-name -4 ".def" find-file-other-window 0 ".mod"] 11))