/[emacs]/emacs/lisp/progmodes/simula.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/simula.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.26 by pj, Thu Dec 20 18:17:15 2001 UTC revision 1.26.4.1 by miles, Fri Apr 4 06:20:36 2003 UTC
# Line 77  If value is a list, each line in a multi Line 77  If value is a list, each line in a multi
77  will have the car of the list extra indentation with respect to  will have the car of the list extra indentation with respect to
78  the previous line of the statement.")  the previous line of the statement.")
79    
80  (defcustom simula-continued-statement-offset  (defcustom simula-continued-statement-offset
81    simula-continued-statement-offset-default    simula-continued-statement-offset-default
82    "*Extra indentation for lines not starting a statement or substatement.    "*Extra indentation for lines not starting a statement or substatement.
83  If value is a list, each line in a multipleline continued statement  If value is a list, each line in a multipleline continued statement
# Line 129  and the cdr extra OTHERWISE indentation. Line 129  and the cdr extra OTHERWISE indentation.
129  (defconst simula-abbrev-keyword-default 'upcase  (defconst simula-abbrev-keyword-default 'upcase
130    "Specify how to convert case for SIMULA keywords.    "Specify how to convert case for SIMULA keywords.
131  Value is one of the symbols `upcase', `downcase', `capitalize',  Value is one of the symbols `upcase', `downcase', `capitalize',
132  (as in) `abbrev-table' or nil if they should not be changed.")  \(as in) `abbrev-table' or nil if they should not be changed.")
133    
134  (defcustom simula-abbrev-keyword simula-abbrev-keyword-default  (defcustom simula-abbrev-keyword simula-abbrev-keyword-default
135    "*Specify how to convert case for SIMULA keywords.    "*Specify how to convert case for SIMULA keywords.
136  Value is one of the symbols `upcase', `downcase', `capitalize',  Value is one of the symbols `upcase', `downcase', `capitalize',
137  (as in) `abbrev-table' or nil if they should not be changed."  \(as in) `abbrev-table' or nil if they should not be changed."
138    :type '(choice (const upcase) (const downcase) (const capitalize)(const nil))    :type '(choice (const upcase) (const downcase) (const capitalize)(const nil))
139    :group 'simula)    :group 'simula)
140    
141  (defconst simula-abbrev-stdproc-default 'abbrev-table  (defconst simula-abbrev-stdproc-default 'abbrev-table
142    "Specify how to convert case for standard SIMULA procedure and class names.    "Specify how to convert case for standard SIMULA procedure and class names.
143  Value is one of the symbols `upcase', `downcase', `capitalize',  Value is one of the symbols `upcase', `downcase', `capitalize',
144  (as in) `abbrev-table', or nil if they should not be changed.")  \(as in) `abbrev-table', or nil if they should not be changed.")
145    
146  (defcustom simula-abbrev-stdproc simula-abbrev-stdproc-default  (defcustom simula-abbrev-stdproc simula-abbrev-stdproc-default
147    "*Specify how to convert case for standard SIMULA procedure and class names.    "*Specify how to convert case for standard SIMULA procedure and class names.
148  Value is one of the symbols `upcase', `downcase', `capitalize',  Value is one of the symbols `upcase', `downcase', `capitalize',
149  (as in) `abbrev-table', or nil if they should not be changed."  \(as in) `abbrev-table', or nil if they should not be changed."
150    :type '(choice (const upcase) (const downcase) (const capitalize)    :type '(choice (const upcase) (const downcase) (const capitalize)
151  (const abbrev-table) (const nil))            (const abbrev-table) (const nil))
152    :group 'simula)    :group 'simula)
153    
154  (defcustom simula-abbrev-file nil  (defcustom simula-abbrev-file nil
# Line 162  for SIMULA mode to function correctly." Line 162  for SIMULA mode to function correctly."
162  (defvar simula-mode-syntax-table nil  (defvar simula-mode-syntax-table nil
163    "Syntax table in SIMULA mode buffers.")    "Syntax table in SIMULA mode buffers.")
164    
165    (defconst simula-font-lock-syntactic-keywords
166      `(;; `comment' directive.
167        ("\\<\\(c\\)omment\\>" 1 "<")
168        ;; end comments
169        (,(concat "\\<end\\>\\([^;\n]\\).*?\\(\n\\|\\(.\\)\\(;\\|"
170                  (regexp-opt '("end" "else" "when" "otherwise"))
171                  "\\)\\)")
172         (1 "< b")
173         (3 "> b" nil t))
174        ;; non-quoted single-quote char.
175        ("'\\('\\)'" 1 ".")))
176    
177  ;; Regexps written with help from Alf-Ivar Holm <alfh@ifi.uio.no>.  ;; Regexps written with help from Alf-Ivar Holm <alfh@ifi.uio.no>.
178  (defconst simula-font-lock-keywords-1  (defconst simula-font-lock-keywords-1
179    (list    '(;;
180     ;;      ;; Compiler directives.
181     ;; Comments and strings.      ("^%\\([^ \t\n].*\\)" 1 font-lock-constant-face t)
182     '(simula-match-string-or-comment 0      ;;
183       (if (match-beginning 1) font-lock-string-face font-lock-comment-face))      ;; Class and procedure names.
184     ;;      ("\\<\\(class\\|procedure\\)\\>[ \t]*\\(\\sw+\\)?"
185     ;; Compiler directives.       (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)))
    '("^%\\([^ \t\n].*\\)" 1 font-lock-constant-face)  
    ;;  
    ;; Class and procedure names.  
    '("\\<\\(class\\|procedure\\)\\>[ \t]*\\(\\sw+\\)?"  
      (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))  
    )  
186    "Subdued level highlighting for Simula mode.")    "Subdued level highlighting for Simula mode.")
187    
188  (defconst simula-font-lock-keywords-2  (defconst simula-font-lock-keywords-2
# Line 187  for SIMULA mode to function correctly." Line 193  for SIMULA mode to function correctly."
193      '("\\<\\(false\\|none\\|notext\\|true\\)\\>" . font-lock-constant-face)      '("\\<\\(false\\|none\\|notext\\|true\\)\\>" . font-lock-constant-face)
194      ;;      ;;
195      ;; Keywords.      ;; Keywords.
196      (concat "\\<\\("      (regexp-opt
197  ;           (make-regexp       '("activate" "after" "and" "at" "before" "begin" "delay" "do"
198  ;            '("activate" "after" "and" "at" "before" "begin" "delay" "do"         "else" "end" "eq" "eqv" "external" "for" "ge" "go" "goto" "gt"
199  ;              "else" "end" "eq" "eqv" "external" "for" "ge" "go" "goto" "gt"         "hidden" "if" "imp" "in" "inner" "inspect" "is" "label" "le"
200  ;              "hidden" "if" "imp" "in" "inner" "inspect" "is" "label" "le"         "lt" "ne" "new" "not" "or" "otherwise" "prior" "protected"
201  ;              "lt" "ne" "new" "not" "or" "otherwise" "prior" "protected"         "qua" "reactivate" "step" "switch" "then" "this" "to" "until"
202  ;              "qua" "reactivate" "step" "switch" "then" "this" "to" "until"         "virtual" "when" "while") 'words)
 ;              "virtual" "when" "while"))  
             "a\\(ctivate\\|fter\\|nd\\|t\\)\\|be\\(fore\\|gin\\)\\|"  
             "d\\(elay\\|o\\)\\|e\\(lse\\|nd\\|qv?\\|xternal\\)\\|for\\|"  
             "g\\([eot]\\|oto\\)\\|hidden\\|i\\([fns]\\|mp\\|n\\(ner\\|"  
             "spect\\)\\)\\|l\\([et]\\|abel\\)\\|n\\(ew?\\|ot\\)\\|"  
             "o\\(r\\|therwise\\)\\|pr\\(ior\\|otected\\)\\|qua\\|"  
             "reactivate\\|s\\(tep\\|witch\\)\\|t\\(h\\(en\\|is\\)\\|o\\)\\|"  
             "until\\|virtual\\|wh\\(en\\|ile\\)"              
             "\\)\\>")  
203      ;;      ;;
204      ;; Types.      ;; Types.
205      (cons (concat "\\<\\(array\\|boolean\\|character\\|integer\\|"      (cons (regexp-opt
206                    "long\\|name\\|real\\|short\\|text\\|value\\|ref\\)\\>")             '("array" "boolean" "character" "integer"
207            'font-lock-type-face)               "long" "name" "real" "short" "text" "value" "ref") 'words)
208      ))            'font-lock-type-face)))
209    "Medium level highlighting for Simula mode.")    "Medium level highlighting for Simula mode.")
210    
211  (defconst simula-font-lock-keywords-3  (defconst simula-font-lock-keywords-3
# Line 243  for SIMULA mode to function correctly." Line 240  for SIMULA mode to function correctly."
240    
241  ; The following function is taken from cc-mode.el,  ; The following function is taken from cc-mode.el,
242  ; it determines the flavor of the Emacs running  ; it determines the flavor of the Emacs running
 (defconst simula-emacs-features  
   (let ((major (and (boundp 'emacs-major-version)  
                     emacs-major-version))  
         (minor (and (boundp 'emacs-minor-version)  
                     emacs-minor-version))  
         flavor comments)  
     ;; figure out version numbers if not already discovered  
     (and (or (not major) (not minor))  
          (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)  
          (setq major (string-to-int (substring emacs-version  
                                                (match-beginning 1)  
                                                (match-end 1)))  
                minor (string-to-int (substring emacs-version  
                                                (match-beginning 2)  
                                                (match-end 2)))))  
     (if (not (and major minor))  
         (error "Cannot figure out the major and minor version numbers"))  
     ;; calculate the major version  
     (cond  
      ((= major 18) (setq major 'v18))   ;Emacs 18  
      ((= major 4)  (setq major 'v18))   ;Epoch 4  
      ((>= major 19) (setq major 'v19    ;Emacs 19 or 20  
                          flavor (if (string-match "Lucid" emacs-version)  
                                     'Lucid 'FSF)))  
      ;; I don't know  
      (t (error "Cannot recognize major version number: %s" major)))  
         (list major flavor comments))  
   "A list of features extant in the Emacs you are using.  
 There are many flavors of Emacs out there, each with different  
 features supporting those needed by simula-mode.  Here's the current  
 supported list, along with the values for this variable:  
   
  Emacs 19:                  (v19 FSF 1-bit)  
  Vanilla Emacs 18/Epoch 4:  (v18 no-dual-comments)  
  Emacs 18/Epoch 4 (patch2): (v18 8-bit)  
  Lucid Emacs 19:            (v19 Lucid 8-bit).")  
243    
244  (defvar simula-mode-menu  (defvar simula-mode-menu
245    '(["Report Bug"             simula-submit-bug-report t]    '(["Report Bug"             simula-submit-bug-report t]
# Line 286  supported list, along with the values fo Line 247  supported list, along with the values fo
247      ["Backward Statement"     simula-previous-statement t]      ["Backward Statement"     simula-previous-statement t]
248      ["Forward Statement"      simula-next-statement t]      ["Forward Statement"      simula-next-statement t]
249      ["Backward Up Level"      simula-backward-up-level t]      ["Backward Up Level"      simula-backward-up-level t]
250      ["Forward Down Statement" simula-forward-down-level t]      ["Forward Down Statement" simula-forward-down-level t])
     )  
251    "Lucid Emacs menu for SIMULA mode.")    "Lucid Emacs menu for SIMULA mode.")
252    
253  (if simula-mode-syntax-table  (if simula-mode-syntax-table
# Line 295  supported list, along with the values fo Line 255  supported list, along with the values fo
255    (setq simula-mode-syntax-table (copy-syntax-table (standard-syntax-table)))    (setq simula-mode-syntax-table (copy-syntax-table (standard-syntax-table)))
256    (modify-syntax-entry ?!  "<"    simula-mode-syntax-table)    (modify-syntax-entry ?!  "<"    simula-mode-syntax-table)
257    (modify-syntax-entry ?$  "."    simula-mode-syntax-table)    (modify-syntax-entry ?$  "."    simula-mode-syntax-table)
258    (modify-syntax-entry ?%  "."    simula-mode-syntax-table)    (modify-syntax-entry ?%  "< b"  simula-mode-syntax-table)
259      (modify-syntax-entry ?\n "> b"  simula-mode-syntax-table)
260    (modify-syntax-entry ?'  "\""   simula-mode-syntax-table)    (modify-syntax-entry ?'  "\""   simula-mode-syntax-table)
261    (modify-syntax-entry ?\( "()"   simula-mode-syntax-table)    (modify-syntax-entry ?\( "()"   simula-mode-syntax-table)
262    (modify-syntax-entry ?\) ")("   simula-mode-syntax-table)    (modify-syntax-entry ?\) ")("   simula-mode-syntax-table)
# Line 308  supported list, along with the values fo Line 269  supported list, along with the values fo
269    (modify-syntax-entry ?\{ "."    simula-mode-syntax-table)    (modify-syntax-entry ?\{ "."    simula-mode-syntax-table)
270    (modify-syntax-entry ?\} "."    simula-mode-syntax-table))    (modify-syntax-entry ?\} "."    simula-mode-syntax-table))
271    
272  (defvar simula-mode-map ()  (defvar simula-mode-map
273    "Keymap used in SIMULA mode.")    (let ((map (make-sparse-keymap)))
274        (define-key map "\C-c\C-u"   'simula-backward-up-level)
275  (if simula-mode-map      (define-key map "\C-c\C-p"   'simula-previous-statement)
276      ()      (define-key map "\C-c\C-d"   'simula-forward-down-level)
277    (setq simula-mode-map (make-sparse-keymap))      (define-key map "\C-c\C-n"   'simula-next-statement)
278    (define-key simula-mode-map "\C-c\C-u"   'simula-backward-up-level)      ;; (define-key map "\C-c\C-g"   'simula-goto-definition)
279    (define-key simula-mode-map "\C-c\C-p"   'simula-previous-statement)      ;; (define-key map "\C-c\C-h"   'simula-standard-help)
280    (define-key simula-mode-map "\C-c\C-d"   'simula-forward-down-level)      (define-key map "\177"       'backward-delete-char-untabify)
281    (define-key simula-mode-map "\C-c\C-n"   'simula-next-statement)      (define-key map ":"          'simula-electric-label)
282    ;(define-key simula-mode-map "\C-c\C-g"   'simula-goto-definition)      (define-key map "\e\C-q"     'simula-indent-exp)
283    ;(define-key simula-mode-map "\C-c\C-h"   'simula-standard-help)      (define-key map "\t"         'simula-indent-command)
284    (define-key simula-mode-map "\177"       'backward-delete-char-untabify)      ;; Emacs 19 defines menus in the mode map
285    (define-key simula-mode-map ":"          'simula-electric-label)      (define-key map [menu-bar simula]
286    (define-key simula-mode-map "\e\C-q"     'simula-indent-exp)        (cons "SIMULA" (make-sparse-keymap "SIMULA")))
287    (define-key simula-mode-map "\t"         'simula-indent-command)      (define-key map [menu-bar simula bug-report]
288    ;; Emacs 19 defines menus in the mode map        '("Submit Bug Report" . simula-submit-bug-report))
289    (if (memq 'FSF simula-emacs-features)      (define-key map [menu-bar simula separator-indent]
290        (progn        '("--"))
291          (define-key simula-mode-map [menu-bar] (make-sparse-keymap))      (define-key map [menu-bar simula indent-exp]
292          '("Indent Expression" . simula-indent-exp))
293          (define-key simula-mode-map [menu-bar simula]      (define-key map [menu-bar simula indent-line]
294            (cons "SIMULA" (make-sparse-keymap "SIMULA")))        '("Indent Line" . simula-indent-command))
295          (define-key simula-mode-map [menu-bar simula bug-report]      (define-key map [menu-bar simula separator-navigate]
296            '("Submit Bug Report" . simula-submit-bug-report))        '("--"))
297          (define-key simula-mode-map [menu-bar simula separator-indent]      (define-key map [menu-bar simula backward-stmt]
298            '("--"))        '("Previous Statement" . simula-previous-statement))
299          (define-key simula-mode-map [menu-bar simula indent-exp]      (define-key map [menu-bar simula forward-stmt]
300            '("Indent Expression" . simula-indent-exp))        '("Next Statement" . simula-next-statement))
301          (define-key simula-mode-map [menu-bar simula indent-line]      (define-key map [menu-bar simula backward-up]
302            '("Indent Line" . simula-indent-command))        '("Backward Up Level" . simula-backward-up-level))
303          (define-key simula-mode-map [menu-bar simula separator-navigate]      (define-key map [menu-bar simula forward-down]
304            '("--"))        '("Forward Down Statement" . simula-forward-down-level))
305          (define-key simula-mode-map [menu-bar simula backward-stmt]  
306            '("Previous Statement" . simula-previous-statement))      (put 'simula-next-statement 'menu-enable '(not (eobp)))
307          (define-key simula-mode-map [menu-bar simula forward-stmt]      (put 'simula-previous-statement 'menu-enable '(not (bobp)))
308            '("Next Statement" . simula-next-statement))      (put 'simula-forward-down-level 'menu-enable '(not (eobp)))
309          (define-key simula-mode-map [menu-bar simula backward-up]      (put 'simula-backward-up-level 'menu-enable '(not (bobp)))
310            '("Backward Up Level" . simula-backward-up-level))      (put 'simula-indent-command 'menu-enable '(not buffer-read-only))
311          (define-key simula-mode-map [menu-bar simula forward-down]      (put 'simula-indent-exp 'menu-enable '(not buffer-read-only))
312            '("Forward Down Statement" . simula-forward-down-level))  
313        ;; RMS: mouse-3 should not select this menu.  mouse-3's global
314          (put 'simula-next-statement 'menu-enable '(not (eobp)))      ;; definition is useful in SIMULA mode and we should not interfere
315          (put 'simula-previous-statement 'menu-enable '(not (bobp)))      ;; with that.  The menu is mainly for beginners, and for them,
316          (put 'simula-forward-down-level 'menu-enable '(not (eobp)))      ;; the menubar requires less memory than a special click.
317          (put 'simula-backward-up-level 'menu-enable '(not (bobp)))      ;; in Lucid Emacs, we want the menu to popup when the 3rd button is
318          (put 'simula-indent-command 'menu-enable '(not buffer-read-only))      ;; hit.  In 19.10 and beyond this is done automatically if we put
319          (put 'simula-indent-exp 'menu-enable '(not buffer-read-only))))      ;; the menu on mode-popup-menu variable, see c-common-init [cc-mode.el]
320        ;;(if (not (boundp 'mode-popup-menu))
321    ;; RMS: mouse-3 should not select this menu.  mouse-3's global      ;;  (define-key simula-mode-map 'button3 'simula-popup-menu))
322    ;; definition is useful in SIMULA mode and we should not interfere      map)
323    ;; with that.  The menu is mainly for beginners, and for them,    "Keymap used in `simula-mode'.")
   ;; 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 (memq 'Lucid simula-emacs-features)  
       (if (not (boundp 'mode-popup-menu))  
           (define-key simula-mode-map 'button3 'simula-popup-menu))))  
324    
325  ;; menus for Lucid  ;; menus for Lucid
326  (defun simula-popup-menu (e)  (defun simula-popup-menu (e)
327    "Pops up the SIMULA menu."    "Pops up the SIMULA menu."
328    (interactive "@e")    (interactive "@e")
329    (popup-menu (cons (concat mode-name " Mode Commands") simula-mode-menu))    (popup-menu (cons (concat mode-name " Mode Commands") simula-mode-menu)))
   (simula-keep-region-active))  
   
 ;; active regions, and auto-newline/hungry delete key  
 (defun simula-keep-region-active ()  
   ;; do whatever is necessary to keep the region active in  
   ;; Lucid. ignore byte-compiler warnings you might see  
   (and (boundp 'zmacs-region-stays)  
        (setq zmacs-region-stays t)))  
   
 (defvar simula-mode-abbrev-table nil  
   "Abbrev table in SIMULA mode buffers")  
   
330    
331  ;;;###autoload  ;;;###autoload
332  (defun simula-mode ()  (define-derived-mode simula-mode nil "Simula"
333    "Major mode for editing SIMULA code.    "Major mode for editing SIMULA code.
334  \\{simula-mode-map}  \\{simula-mode-map}
335  Variables controlling indentation style:  Variables controlling indentation style:
336   simula-tab-always-indent   `simula-tab-always-indent'
337      Non-nil means TAB in SIMULA mode should always reindent the current line,      Non-nil means TAB in SIMULA mode should always reindent the current line,
338      regardless of where in the line point is when the TAB command is used.      regardless of where in the line point is when the TAB command is used.
339   simula-indent-level   `simula-indent-level'
340      Indentation of SIMULA statements with respect to containing block.      Indentation of SIMULA statements with respect to containing block.
341   simula-substatement-offset   `simula-substatement-offset'
342      Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.      Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.
343   simula-continued-statement-offset 3   `simula-continued-statement-offset' 3
344      Extra indentation for lines not starting a statement or substatement,      Extra indentation for lines not starting a statement or substatement,
345      e.g. a nested FOR-loop.  If value is a list, each line in a multiple-      e.g. a nested FOR-loop.  If value is a list, each line in a multiple-
346      line continued statement will have the car of the list extra indentation      line continued statement will have the car of the list extra indentation
347      with respect to the previous line of the statement.      with respect to the previous line of the statement.
348   simula-label-offset -4711   `simula-label-offset' -4711
349      Offset of SIMULA label lines relative to usual indentation.      Offset of SIMULA label lines relative to usual indentation.
350   simula-if-indent '(0 . 0)   `simula-if-indent' '(0 . 0)
351      Extra indentation of THEN and ELSE with respect to the starting IF.      Extra indentation of THEN and ELSE with respect to the starting IF.
352      Value is a cons cell, the car is extra THEN indentation and the cdr      Value is a cons cell, the car is extra THEN indentation and the cdr
353      extra ELSE indentation.  IF after ELSE is indented as the starting IF.      extra ELSE indentation.  IF after ELSE is indented as the starting IF.
354   simula-inspect-indent '(0 . 0)   `simula-inspect-indent' '(0 . 0)
355      Extra indentation of WHEN and OTHERWISE with respect to the      Extra indentation of WHEN and OTHERWISE with respect to the
356      corresponding INSPECT.  Value is a cons cell, the car is      corresponding INSPECT.  Value is a cons cell, the car is
357      extra WHEN indentation and the cdr extra OTHERWISE indentation.      extra WHEN indentation and the cdr extra OTHERWISE indentation.
358   simula-electric-indent nil   `simula-electric-indent' nil
359      If this variable is non-nil, `simula-indent-line'      If this variable is non-nil, `simula-indent-line'
360      will check the previous line to see if it has to be reindented.      will check the previous line to see if it has to be reindented.
361   simula-abbrev-keyword 'upcase   `simula-abbrev-keyword' 'upcase
362      Determine how SIMULA keywords will be expanded.  Value is one of      Determine how SIMULA keywords will be expanded.  Value is one of
363      the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table',      the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table',
364      or nil if they should not be changed.      or nil if they should not be changed.
365   simula-abbrev-stdproc 'abbrev-table   `simula-abbrev-stdproc' 'abbrev-table
366      Determine how standard SIMULA procedure and class names will be      Determine how standard SIMULA procedure and class names will be
367      expanded.  Value is one of the symbols `upcase', `downcase', `capitalize',      expanded.  Value is one of the symbols `upcase', `downcase', `capitalize',
368      (as in) `abbrev-table', or nil if they should not be changed.      (as in) `abbrev-table', or nil if they should not be changed.
369    
370  Turning on SIMULA mode calls the value of the variable simula-mode-hook  Turning on SIMULA mode calls the value of the variable simula-mode-hook
371  with no arguments, if that value is non-nil  with no arguments, if that value is non-nil."
   
 Warning: simula-mode-hook should not read in an abbrev file without calling  
 the function simula-install-standard-abbrevs afterwards, preferably not  
 at all."  
   (interactive)  
   (kill-all-local-variables)  
   (use-local-map simula-mode-map)  
   (setq major-mode 'simula-mode)  
   (setq mode-name "SIMULA")  
372    (make-local-variable 'comment-column)    (make-local-variable 'comment-column)
373    (setq comment-column 40)    (setq comment-column 40)
374  ;  (make-local-variable 'end-comment-column)  ;  (make-local-variable 'end-comment-column)
375  ;  (setq end-comment-column 75)  ;  (setq end-comment-column 75)
   (set-syntax-table simula-mode-syntax-table)  
376    (make-local-variable 'paragraph-start)    (make-local-variable 'paragraph-start)
377    (setq paragraph-start "[ \t]*$\\|\\f")    (setq paragraph-start "[ \t]*$\\|\\f")
378    (make-local-variable 'paragraph-separate)    (make-local-variable 'paragraph-separate)
# Line 463  at all." Line 395  at all."
395    (setq font-lock-defaults    (setq font-lock-defaults
396          '((simula-font-lock-keywords simula-font-lock-keywords-1          '((simula-font-lock-keywords simula-font-lock-keywords-1
397             simula-font-lock-keywords-2 simula-font-lock-keywords-3)             simula-font-lock-keywords-2 simula-font-lock-keywords-3)
398            t t ((?_ . "w"))))            nil t ((?_ . "w")) nil
399    (if simula-mode-abbrev-table            (font-lock-syntactic-keywords . simula-font-lock-syntactic-keywords)))
400        ()    (abbrev-mode 1))
     (if simula-abbrev-file  
         (read-abbrev-file simula-abbrev-file)  
       (define-abbrev-table 'simula-mode-abbrev-table ()))  
     (let (abbrevs-changed)  
       (simula-install-standard-abbrevs)))  
   (setq local-abbrev-table simula-mode-abbrev-table)  
   (abbrev-mode 1)  
   (run-hooks 'simula-mode-hook))  
   
401    
402  (defun simula-indent-exp ()  (defun simula-indent-exp ()
403    "Indent SIMULA expression following point."    "Indent SIMULA expression following point."
# Line 496  at all." Line 419  at all."
419                    (simula-indent-line))                    (simula-indent-line))
420                (forward-line 1)))                (forward-line 1)))
421          (and end (set-marker end nil))))))          (and end (set-marker end nil))))))
422          
423    
424  (defun simula-indent-line ()  (defun simula-indent-line ()
425    "Indent this line as SIMULA code.    "Indent this line as SIMULA code.
# Line 583  The relative indentation among the lines Line 506  The relative indentation among the lines
506    
507    
508  (defun simula-context ()  (defun simula-context ()
509    "Returns value according to syntactic SIMULA context of point.    "Return value according to syntactic SIMULA context of point.
510      0    point inside COMMENT comment      0    point inside COMMENT comment
511      1    point on SIMULA-compiler directive line      1    point on SIMULA-compiler directive line
512      2    point inside END comment      2    point inside END comment
# Line 728  The relative indentation among the lines Line 651  The relative indentation among the lines
651                (delete-horizontal-space)                (delete-horizontal-space)
652                (indent-to amount)))                (indent-to amount)))
653        (goto-char (- (point-max) origin)))))        (goto-char (- (point-max) origin)))))
654            
655    
656  (defun simula-backward-up-level (count)  (defun simula-backward-up-level (count)
657    "Move backward up COUNT block levels.    "Move backward up COUNT block levels.
# Line 797  If COUNT is negative, move backward down Line 720  If COUNT is negative, move backward down
720                (goto-char origin)                (goto-char origin)
721                (signal 'quit nil))))))                (signal 'quit nil))))))
722    
723        
724  (defun simula-previous-statement (count)  (defun simula-previous-statement (count)
725    "Move backward COUNT statements.    "Move backward COUNT statements.
726  If COUNT is negative, move forward instead."  If COUNT is negative, move forward instead."
# Line 808  If COUNT is negative, move forward inste Line 731  If COUNT is negative, move forward inste
731            (case-fold-search t)            (case-fold-search t)
732            (origin (point)))            (origin (point)))
733        (condition-case ()        (condition-case ()
734            ;;            ;;
735            (progn            (progn
736              (simula-skip-comment-backward)              (simula-skip-comment-backward)
737              (if (memq (preceding-char) '(?n ?N))              (if (memq (preceding-char) '(?n ?N))
# Line 1104  If COUNT is negative, move backward inst Line 1027  If COUNT is negative, move backward inst
1027              ;; (at or before comment or label)              ;; (at or before comment or label)
1028              ;; temp = t means finished              ;; temp = t means finished
1029              (setq temp              (setq temp
1030                    (and (not (simula-context))                                      (and (not (simula-context))
1031                         (save-excursion                         (save-excursion
1032                           (skip-chars-forward " \t\f")                           (skip-chars-forward " \t\f")
1033                           (or (looking-at "virtual")                           (or (looking-at "virtual")
# Line 1191  If COUNT is negative, move backward inst Line 1114  If COUNT is negative, move backward inst
1114    
1115    
1116  (defun simula-find-do-match ()  (defun simula-find-do-match ()
1117    "Find keyword matching DO: FOR, WHILE, INSPECT or WHEN"    "Find keyword matching DO: FOR, WHILE, INSPECT or WHEN."
1118    (while (and (re-search-backward    (while (and (re-search-backward
1119                 "\\<\\(do\\|for\\|while\\|inspect\\|when\\|end\\|begin\\)\\>\\|;"                 "\\<\\(do\\|for\\|while\\|inspect\\|when\\|end\\|begin\\)\\>\\|;"
1120                 nil 'move)                 nil 'move)
# Line 1324  If COUNT is negative, move backward inst Line 1247  If COUNT is negative, move backward inst
1247    
1248    
1249  (defun simula-search-backward (regexp &optional bound noerror)  (defun simula-search-backward (regexp &optional bound noerror)
1250    "Search backward from point for regular expression REGEXP, ignoring matches    "Search backward from point for regular expression REGEXP,
1251  found inside SIMULA comments, string literals, and BEGIN..END blocks.  ignoring matches found inside SIMULA comments, string literals,
1252    and BEGIN..END blocks.
1253  Set point to the end of the occurrence found, and return point.  Set point to the end of the occurrence found, and return point.
1254  An optional second argument BOUND bounds the search, it is a buffer position.  An optional second argument BOUND bounds the search, it is a buffer position.
1255  The match found must not extend after that position.  Optional third argument  The match found must not extend after that position.  Optional third argument
# Line 1345  If not nil and not t, move to limit of s Line 1269  If not nil and not t, move to limit of s
1269            (cond            (cond
1270             ((eq context nil)             ((eq context nil)
1271              (setq match (if (looking-at regexp) t 'BLOCK)))              (setq match (if (looking-at regexp) t 'BLOCK)))
1272  ;;; A comment-ending semicolon is part of the comment, and shouldn't match.             ;; A comment-ending `;' is part of the comment, and shouldn't match.
1273  ;;;          ((eq context 0)             ;; ((eq context 0)
1274  ;;;           (setq match (if (eq (following-char) ?\;) t nil)))             ;;  (setq match (if (eq (following-char) ?\;) t nil)))
1275             ((eq context 2)             ((eq context 2)
1276              (setq match (if (and (looking-at regexp)              (setq match (if (and (looking-at regexp)
1277                                   (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>"))                                   (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>"))
# Line 1385  If not nil and not t, move to limit of s Line 1309  If not nil and not t, move to limit of s
1309    
1310    
1311  (defun simula-search-forward (regexp &optional bound noerror)  (defun simula-search-forward (regexp &optional bound noerror)
1312    "Search forward from point for regular expression REGEXP, ignoring matches    "Search forward from point for regular expression REGEXP,
1313  found inside SIMULA comments, string literals, and BEGIN..END blocks.  ignoring matches found inside SIMULA comments, string literals,
1314    and BEGIN..END blocks.
1315  Set point to the end of the occurrence found, and return point.  Set point to the end of the occurrence found, and return point.
1316  An optional second argument BOUND bounds the search, it is a buffer position.  An optional second argument BOUND bounds the search, it is a buffer position.
1317  The match found must not extend after that position.  Optional third argument  The match found must not extend after that position.  Optional third argument
# Line 1408  If not nil and not t, move to limit of s Line 1333  If not nil and not t, move to limit of s
1333              (cond              (cond
1334               ((not context)               ((not context)
1335                (setq match (if (looking-at regexp) t 'BLOCK)))                (setq match (if (looking-at regexp) t 'BLOCK)))
1336  ;;; A comment-ending semicolon is part of the comment, and shouldn't match.               ;; Comment-ending `;' is part of the comment, and shouldn't match.
1337  ;;;          ((eq context 0)               ;; ((eq context 0)
1338  ;;;           (setq match (if (eq (following-char) ?\;) t nil)))               ;;  (setq match (if (eq (following-char) ?\;) t nil)))
1339               ((eq context 2)               ((eq context 2)
1340                (setq match (if (and (looking-at regexp)                (setq match (if (and (looking-at regexp)
1341                                     (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>")) t nil)))                                     (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>")) t nil)))
# Line 1443  If not nil and not t, move to limit of s Line 1368  If not nil and not t, move to limit of s
1368            nil            nil
1369          (signal 'search-failed (list regexp))))))          (signal 'search-failed (list regexp))))))
1370    
1371      
1372  (defun simula-install-standard-abbrevs ()  (defun simula-install-standard-abbrevs ()
1373    "Define Simula keywords, procedures and classes in local abbrev table."    "Define Simula keywords, procedures and classes in local abbrev table."
1374    ;; procedure and class names are as of the SIMULA 87 standard.    ;; procedure and class names are as of the SIMULA 87 standard.
1375    (interactive)    (interactive)
1376    (mapcar (function (lambda (args)    (dolist (args
                       (apply 'define-abbrev simula-mode-abbrev-table args)))  
1377            '(("abs" "Abs" simula-expand-stdproc)            '(("abs" "Abs" simula-expand-stdproc)
1378              ("accum" "Accum" simula-expand-stdproc)              ("accum" "Accum" simula-expand-stdproc)
1379              ("activate" "ACTIVATE" simula-expand-keyword)              ("activate" "ACTIVATE" simula-expand-keyword)
# Line 1679  If not nil and not t, move to limit of s Line 1603  If not nil and not t, move to limit of s
1603              ("virtual" "VIRTUAL" simula-expand-keyword)              ("virtual" "VIRTUAL" simula-expand-keyword)
1604              ("wait" "Wait" simula-expand-stdproc)              ("wait" "Wait" simula-expand-stdproc)
1605              ("when" "WHEN" simula-electric-keyword)              ("when" "WHEN" simula-electric-keyword)
1606              ("while" "WHILE" simula-expand-keyword))))              ("while" "WHILE" simula-expand-keyword)))
1607        (define-abbrev simula-mode-abbrev-table
1608          (nth 0 args) (nth 1 args) (nth 2 args) nil 'system)))
1609    
1610    (if simula-abbrev-file
1611        (read-abbrev-file simula-abbrev-file))
1612    (let (abbrevs-changed)
1613      (simula-install-standard-abbrevs))
1614    
1615  ;;; Font Lock mode support.  ;; Hilit mode support.
 (eval-when-compile  
   (require 'cl))  
   
 ;; SIMULA comments and strings are a mess.  If we rely on the syntax table,  
 ;; then %-comments may be shown incorrectly (and prematurely) ended by a  
 ;; semicolon, !-comments by a newline and '-strings may screw up the rest of  
 ;; the buffer.  And of course we can't do comment- or end-comments using the  
 ;; syntax table.  We can do everything except end-comments in one fast regexp,  
 ;; but we aught to do end-comments too, so we need a function.  simon@gnu.  
 (defun simula-match-string-or-comment (limit)  
   ;; Return t if there is a string or comment before LIMIT.  
   ;; Matches buffer text so that if (match-string 1) is non-nil, it is the  
   ;; string.  Otherwise, (match-string 0) is non-nil, and is the comment.  
   (when (re-search-forward  
          (eval-when-compile  
            (concat "\\(\"[^\"\n]*\"\\|'\\(.\\|![0-9]+!\\)'\\)\\|"  
                    "\\(\\<end[ \t\n]+\\)\\|"  
                    "^%[ \t].*\\|\\(!\\|\\<comment\\>\\)[^;]*;?"))  
          limit t)  
     (when (match-beginning 3)  
       ;; We've matched an end-comment.  Yuck.  Find the extent of it.  
       (set-match-data  
        (list (point)  
         (if (re-search-forward "\\<\\(end\\|else\\|when\\|otherwise\\)\\>\\|;"  
                                limit 'move)  
             (match-beginning 0)  
           (point)))))  
     t))  
   
 ;;; Hilit mode support.  
1616  (if (and (fboundp 'hilit-set-mode-patterns)  (if (and (fboundp 'hilit-set-mode-patterns)
1617           (boundp 'hilit-patterns-alist)           (boundp 'hilit-patterns-alist)
1618           (not (assoc 'simula-mode hilit-patterns-alist)))           (not (assoc 'simula-mode hilit-patterns-alist)))
# Line 1724  If not nil and not t, move to limit of s Line 1625  If not nil and not t, move to limit of s
1625         ("\\<\\(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)         ("\\<\\(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)
1626         ("!\\|\\<COMMENT\\>" ";" comment))         ("!\\|\\<COMMENT\\>" ";" comment))
1627       nil 'case-insensitive))       nil 'case-insensitive))
   
 ;; None of this seems to be used by anything, including hilit19.el.  simon@gnu.  
 ;(setq simula-find-comment-point -1  
 ;      simula-find-comment-context nil)  
 ;  
 ;;; function used by hilit19  
 ;(defun simula-find-next-comment-region (param)  
 ;  "Return region (start end) cons of comment after point, or nil."  
 ;  (let (start end)  
 ;    ;; This function is called repeatedly, check if point is  
 ;    ;; where we left it in the last call  
 ;    (if (not (eq simula-find-comment-point (point)))  
 ;       (setq simula-find-comment-point (point)  
 ;             simula-find-comment-context (simula-context)))  
 ;    ;; loop as long as we haven't found the end of a comment  
 ;    (if (memq simula-find-comment-context '(0 1 2))  
 ;       (setq start (point))  
 ;      (if (re-search-forward "\\<end\\>\\|!\\|\"\\|'\\|^%\\|\\<comment\\>"  
 ;                            nil 'move)  
 ;         (let ((previous-char (preceding-char)))  
 ;           (cond  
 ;            ((memq previous-char '(?d ?D))  
 ;             (setq start (point)  
 ;                   simula-find-comment-context 2))  
 ;            ((memq previous-char '(?t ?T ?\!))  
 ;             (setq start (point)  
 ;                   simula-find-comment-context 0))  
 ;            ((eq previous-char ?%)  
 ;             (setq start (point)  
 ;                   simula-find-comment-context 0))))))  
 ;    ;; BUG: the following (0 2) branches don't take into account intermixing  
 ;    ;; directive lines  
 ;    (cond  
 ;     ((eq simula-find-comment-context 0)  
 ;      (search-forward ";" nil 'move))  
 ;     ((eq simula-find-comment-context 1)  
 ;      (beginning-of-line 2))  
 ;     ((eq simula-find-comment-context 2)  
 ;      (re-search-forward ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>\\" (point-max) 'move)))  
 ;    (if start  
 ;       (setq end (point)))  
 ;    ;; save point for later calls to this function  
 ;    (setq simula-find-comment-point (if end (point) -1))  
 ;    (and end (cons start end))))  
1628    
1629  ;; defuns for submitting bug reports  ;; defuns for submitting bug reports
1630    
1631  (defconst simula-mode-help-address "simula-mode@ifi.uio.no"  (defconst simula-mode-help-address "simula-mode@ifi.uio.no"
1632    "Address accepting submission of simula-mode bug reports.")    "Address accepting submission of `simula-mode' bug reports.")
1633    
1634  (defun simula-submit-bug-report ()  (defun simula-submit-bug-report ()
1635    "Submit via mail a bug report on simula-mode."    "Submit via mail a bug report on `simula-mode'."
1636    (interactive)    (interactive)
1637    (and    (and
1638     (y-or-n-p "Do you want to submit a report on simula-mode? ")     (y-or-n-p "Do you want to submit a report on simula-mode? ")
# Line 1784  If not nil and not t, move to limit of s Line 1641  If not nil and not t, move to limit of s
1641      (concat "simula-mode from Emacs " emacs-version)      (concat "simula-mode from Emacs " emacs-version)
1642      (list      (list
1643       ;; report only the vars that affect indentation       ;; report only the vars that affect indentation
      'simula-emacs-features  
1644       'simula-indent-level       'simula-indent-level
1645       'simula-substatement-offset       'simula-substatement-offset
1646       'simula-continued-statement-offset       'simula-continued-statement-offset

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.26.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26