]> Creatis software - bbtk.git/blob - kernel/appli/bbi/bbs-mode.el
Feature #1774
[bbtk.git] / kernel / appli / bbi / bbs-mode.el
1 ;/*
2 ; # ---------------------------------------------------------------------
3 ; #
4 ; # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 ; #                        pour la SantÈ)
6 ; # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 ; # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 ; # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 ; #
10 ; #  This software is governed by the CeCILL-B license under French law and
11 ; #  abiding by the rules of distribution of free software. You can  use,
12 ; #  modify and/ or redistribute the software under the terms of the CeCILL-B
13 ; #  license as circulated by CEA, CNRS and INRIA at the following URL
14 ; #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 ; #  or in the file LICENSE.txt.
16 ; #
17 ; #  As a counterpart to the access to the source code and  rights to copy,
18 ; #  modify and redistribute granted by the license, users are provided only
19 ; #  with a limited warranty  and the software's author,  the holder of the
20 ; #  economic rights,  and the successive licensors  have only  limited
21 ; #  liability.
22 ; #
23 ; #  The fact that you are presently reading this means that you have had
24 ; #  knowledge of the CeCILL-B license and that you accept its terms.
25 ; # ------------------------------------------------------------------------ */
26
27 ;=============================================================================
28 ; bbs-mode.el = Emacs major mode for editing bbi script files (.bbs).
29
30 ; Add bbs listfile names to the mode list.
31 (setq auto-mode-alist
32           (append
33            '(("\\.bbs\\'" . bbs-mode))
34            auto-mode-alist))
35 ; Note, add the above setq auto-mode-alist to your .emacs
36 ; along with the following to have the mode loaded when
37 ; a *.mac file is loaded in emacs.
38 ; (autoload 'bbs-mode "bbs-mode.el" t)
39
40 ; Default indentation increment.
41 (defvar bbs-tab-width 2)
42
43 ; Define keyword highlighting.
44 (defconst bbs-font-lock-defaults
45   (list
46    (regexp-opt '(
47                  "author"
48                  "config"
49                  "connect"
50                  "define"
51                  "delete"
52                  "description"
53                  "endefine"
54                  "endpackage"
55                  "exec"
56                  "graph"
57                  "help"
58                  "include"
59                  "input"
60                  "load"
61                  "message"
62                  "new"
63                  "output"
64                  "package"
65                  "print"
66                  "quit"
67                  "reset"
68                  "set"
69                  "unload"
70                  "index"
71                  "category"
72                  "clear"
73                  ) t )
74    "Highlighting expressions for bbs mode.")
75   )
76
77 ; Define a variable to hold the syntax table.
78 (defvar bbs-mode-syntax-table nil "Syntax table for bbs-mode.")
79
80 ; If bbs mode file is reloaded, we want the syntax table to be
81 ; regenerated when bbs-mode is called.
82 (setq bbs-mode-syntax-table nil)
83
84 ; Let users hook to bbs mode.
85 (defvar bbs-mode-hook nil)
86
87 ; Mode startup function.
88 (defun bbs-mode ()
89   "Major mode for editing bbtk script files (.bbs)."
90   (interactive)
91   (kill-all-local-variables)
92   (setq major-mode 'bbs-mode)
93   (setq mode-name "bbs")
94                                         ; Create the syntax table
95   (setq bbs-mode-syntax-table (make-syntax-table))
96   (set-syntax-table bbs-mode-syntax-table)
97   (modify-syntax-entry ?_  "w" bbs-mode-syntax-table)
98   (modify-syntax-entry ?\(  "()" bbs-mode-syntax-table)
99   (modify-syntax-entry ?\)  ")(" bbs-mode-syntax-table)
100   (modify-syntax-entry ?# "<" bbs-mode-syntax-table)
101   (modify-syntax-entry ?\n ">" bbs-mode-syntax-table)
102   
103                                         ; Setup font-lock mode.
104   (make-local-variable 'font-lock-defaults)
105   (setq font-lock-defaults '(bbs-font-lock-defaults))
106
107   ; Setup comment syntax.
108   (make-local-variable 'comment-start)
109   (setq comment-start "#")
110
111   (run-hooks 'bbs-mode-hook))
112
113 ; This file provides bbs-mode.
114 (provide 'bbs-mode)
115