;;; castem.el --- Castem mode for GNU Emacs ;; Copyright (C) 2000, 2001 Stephane Gounand ;; Author: Stéphane Gounand ;; ;;; Commentary: ;; This package provides a simple major mode for finite element code CASTEM 2000 ;;; Usage: ;; This file (castem.el) should reside in you home directory ;; or in your load-path. ;; For example, uncomment and add in your Emacs configuration file (~/.emacs) : ;; (add-to-list 'load-path "/u2/gounand/emacs") ;; if esope.el resides in /u2/gounand/emacs/ ;; ;; You should also have a shell-script named cast_info in your PATH if you want ;; to have help files for castem operators in emacs (Control-C i by default or ;; Castem menu) ;; ;; See the declaration below if you want to change the name of the script : ;; (defvar castem-info-program "cast_info" ;; "The name of the program that produces Cast3m info pages.") ;; Then, uncomment the three following lines and put them in your ;; Emacs configuration file (~/.emacs) to autoload castem-mode on opening Gibiane files: ;; (setq auto-mode-alist (cons '("\\.dgibi\\'" . castem-mode) auto-mode-alist)) ;; (setq auto-mode-alist (cons '("\\.procedur\\'" . castem-mode) auto-mode-alist)) ;; (autoload 'castem-mode "castem" "Castem mode" t nil) ;;; Todo: ;; * Skeleton for (si..finsi) ;; * Skeleton for other constructs (debp..finp) ;; * Générer automatiquement la liste des opérateurs et des procédures ;; (elles varient d'année en année). ;; * les constantes ne sont pas coloriées (vrai faux pi) ;; * l'indentation automatique ne fonctionne pas bien ;; * compléter le menu et les raccourcis avec des choses utiles... ;; * Inline doc for operators : ;; Generer les notices sans utiliser de shell-script : cast_info ;; Gérer la langue des notices ;;; Code: (require 'ehelp) (defvar castem-mode-hook nil "Normal hook run when entering Castem mode.") (defvar castem-mode-syntax-table nil "Syntax table used while in Castem mode.") ;(defvar castem-mode-abbrev-table nil ; "Abbrev table used while in Castem mode.") ;(define-abbrev-table 'castem-mode-abbrev-table ()) (if castem-mode-syntax-table () (setq castem-mode-syntax-table (make-syntax-table)) (modify-syntax-entry ?\; "." castem-mode-syntax-table) (modify-syntax-entry ?\r " " castem-mode-syntax-table) (modify-syntax-entry ?+ "w" castem-mode-syntax-table) (modify-syntax-entry ?- "w" castem-mode-syntax-table) (modify-syntax-entry ?* "w" castem-mode-syntax-table) (modify-syntax-entry ?/ "w" castem-mode-syntax-table) (modify-syntax-entry ?= "." castem-mode-syntax-table) (modify-syntax-entry ?\' "." castem-mode-syntax-table) (modify-syntax-entry ?\" "\"" castem-mode-syntax-table) (modify-syntax-entry ?\\ "/" castem-mode-syntax-table) (modify-syntax-entry ?. "w" castem-mode-syntax-table) (modify-syntax-entry ?_ "w" castem-mode-syntax-table) (modify-syntax-entry ?\@ "w" castem-mode-syntax-table) (modify-syntax-entry ?\< "w" castem-mode-syntax-table) (modify-syntax-entry ?\> "w" castem-mode-syntax-table) ) (defconst castem-font-lock-keywords-1 nil "Subdued level highlighting for Castem mode.") (defconst castem-font-lock-keywords-2 nil "Medium level highlighting for Castem mode.") (defconst castem-font-lock-keywords-3 nil "Gaudy level highlighting for Castem mode.") (let ((comment-chars "*") ; les opérateurs a moins de quatre lettres (castem-keywords-1 (regexp-opt (list "+" "-" "*" "/" "**" ">" "<" ">eg" "\\)") '(1 font-lock-function-name-face)) (list (concat "[(=][ ']*" "\\(\\<\\(" castem-keywords-1 "\\)\\>\\)") '(1 font-lock-function-name-face)) (list (concat "^[ ']*" "\\(\\<\\(" castem-keywords-3 "\\)\\>\\)") '(1 font-lock-keyword-face)) (list (concat "[(=][ ']*" "\\(\\<\\(" castem-keywords-3 "\\)\\>\\)") '(1 font-lock-keyword-face)) (list (concat "^[ ']*" "\\(\\<\\(" castem-keywords-2 "\\)\\w*\\>\\)") '(1 font-lock-function-name-face)) (list (concat "[(=][ ']*" "\\(\\<\\(" castem-keywords-2 "\\)\\w*\\>\\)") '(1 font-lock-function-name-face)) '("'[^'\n]*'?" . font-lock-string-face) ) )) (setq castem-font-lock-keywords-3 (append castem-font-lock-keywords-1 castem-font-lock-keywords-2 ) )) (defvar castem-font-lock-keywords castem-font-lock-keywords-1 "Default expressions to highlight in Castem mode.") (defvar castem-mode-map () "Keymap for Castem mode.") (if castem-mode-map () (setq castem-mode-map (make-sparse-keymap)) (define-key castem-mode-map "\n" 'newline-and-indent) (define-key castem-mode-map "\r" 'newline-and-indent) (define-key castem-mode-map "\t" 'tab-to-tab-stop) (define-key castem-mode-map "\C-ci" 'castem-info-operator) ; (define-key castem-mode-map "\t" 'indent-relative-maybe) ; (define-key castem-mode-map "\t" 'indent-relative) ; (define-key castem-mode-map "\t" 'indent-to-left-margin) ;; Menu bars (define-key castem-mode-map [menu-bar castem] (cons "Castem" (make-sparse-keymap "Castem"))) (define-key castem-mode-map [menu-bar castem castem-info] '("Castem INFO" . castem-info-operator)) ;; Put them in the menu bar: (setq menu-bar-final-items (append '(castem) menu-bar-final-items)) ) (defvar castem-mode-abbrev-table nil) (if castem-mode-abbrev-table () (let ((ac abbrevs-changed)) (define-abbrev-table 'castem-mode-abbrev-table ()) (define-abbrev castem-mode-abbrev-table "+" "'+'" 'castem-noexpand-if-line-commented-hook nil) (define-abbrev castem-mode-abbrev-table "-" "'-'" 'castem-noexpand-if-line-commented-hook nil) ; (define-abbrev castem-mode-abbrev-table "*" "'*'" 'castem-noexpand-if-line-commented-hook nil) (define-abbrev castem-mode-abbrev-table "**" "'**'" 'castem-noexpand-if-line-commented-hook nil) (define-abbrev castem-mode-abbrev-table "/" "'/'" 'castem-noexpand-if-line-commented-hook nil) (define-abbrev castem-mode-abbrev-table ">eg" "'>EG'" 'castem-noexpand-if-line-commented-hook nil) (define-abbrev castem-mode-abbrev-table "