fix invalid variable issue
[spice-mode.git] / spice-mode.el
blob70ba42358f32b358bb74e57725361dd8baece694
1 ;;; spice-mode.el --- major mode providing a spice mode hook for fontification
2 ;;;* Last edited: Feb 23 12:55 1995 (cvieri)
4 ;; Author: 1994 Carlin J. Vieri, MIT AI Lab <cvieri@ai.mit.edu>
5 ;; Keywords: Spice editing major-mode
6 ;; Version: 0.0.1
8 ;; Copyright (C) 1994, MIT Artificial Intelligence Lab
10 ;; This file is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; This file is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 ;; If you have any questions about this mode, feel free to contact me
25 ;; at the following address: cvieri@ai.mit.edu. If you make any
26 ;; modifications or bug fixes, I'd like to hear about them.
28 ;;; Commentary:
30 ;; To use spice-mode, add the following to your .emacs file. This
31 ;; assumes that you will use the .sp extension for your spice source deck:
32 ;; (autoload 'spice-mode "spice-mode" "Spice Editing Mode" t)
33 ;; (setq auto-mode-alist
34 ;; (append '(("\\.sp$" . spice-mode)
35 ;; ) auto-mode-alist))
38 ;;; Todos:
40 ;; No bug report notification is currently available. No indentation is
41 ;; implemented; this mode provides a fontification hook. Common language
42 ;; commands and key bindings are linked through this command. Do not use a -*-
43 ;; Mode -*- line in a spice deck as the first card in the deck is defined to be
44 ;; the title card. Rather, autoload spice-mode through your .emacs file. turning
45 ;; on Spice mode calls the value of the variable `spice-mode-hook' with no args,
46 ;; if that value is non-nil.
48 ;;; Code:
50 (defvar spice-mode-syntax-table (make-syntax-table)
51 "Syntax table used in spice-mode buffers.")
53 (if spice-mode-syntax-table
54 (progn
55 (modify-syntax-entry ?* "<" spice-mode-syntax-table)
56 (modify-syntax-entry ?$ "<" spice-mode-syntax-table)
57 (modify-syntax-entry ?\n ">" spice-mode-syntax-table)))
59 (defvar spice-mode-abbrev-table nil
60 "Abbrev table in use in spice-mode buffers.")
62 (define-abbrev-table 'spice-mode-abbrev-table ())
64 (defvar spice-mode-map (make-sparse-keymap)
65 "Keymap used in spice-mode.")
67 ;; TODO: where does the `install-common-language-commands' from?
68 (if spice-mode-map
69 ;; (install-common-language-commands spice-mode-map)
72 ;; ======================================================================
73 ;; spice-mode main entry point
74 ;; ======================================================================
75 ;;;###autoload
76 (define-derived-mode spice-mode prog-mode "spice-mode"
77 "Major mode for editing spice decks."
78 (setq-local paragraph-start (concat "^$\\|" page-delimiter))
79 (setq-local paragraph-separate paragraph-start)
80 (setq-local paragraph-ignore-fill-prefix t)
81 (setq-local require-final-newline t)
82 (setq-local parse-sexp-ignore-comments nil)
83 (setq-local comment-start "* ")
84 (setq-local comment-end "")
85 (setq-local comment-column 32)
89 ;;; Hacks to implement the find function menu bar for spice mode subcircuits.
90 ;;; Fortunately spice only provides one means of abstraction so the parsing is
91 ;;; very easy.
92 (defconst spice-mode-function-name-regexp-spice
93 "^[\.]\\(subckt\\)[ \t]+\\([A-Za-z0-9_+-]*\\)[ \t]*"
94 "Expression to parse Spice subcircuit names.")
96 (defun spice-mode-find-next-spice-function-name (buffer)
97 "Search for the next spice subcircuit name in BUFFER."
98 (set-buffer buffer)
99 (if (re-search-forward spice-mode-function-name-regexp-spice nil t)
100 (let ((beg (match-beginning 2))
101 (end (match-end 2)))
102 (cons (buffer-substring beg end) beg))))
104 ;; hook in the spice mode regular expression above into the association list of
105 ;; regexps used by the function menu generator
106 (defvar spice-mode-function-name-regexp-alist
107 (list '(spice-mode . spice-mode-function-name-regexp-spice)))
109 ;; hook in the search method above into the association list used by the
110 ;; function menu generating code
111 (defvar spice-mode-find-function-name-method-alist
112 (list '(spice-mode . spice-mode-find-next-spice-function-name)))
115 ;;;###autoload
116 (setq auto-mode-alist
117 (append '(("\\.sp$" . spice-mode)) auto-mode-alist))
120 ;; this is sometimes useful
121 (provide 'spice-mode)
123 ;;; spice-mode.el ends here