paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame^] | 1 | ;; -*- lisp -*- |
| 2 | ;;; zebra-mode.el -- major mode for editing zebra configuration file. |
| 3 | |
| 4 | ;; Copyright (C) 1998 Kunihiro Ishiguro |
| 5 | |
| 6 | ;; Author: 1998 Kunihiro Ishiguro |
| 7 | ;; SeonMeyong HEO |
| 8 | ;; Maintainer: kunihiro@zebra.org |
| 9 | ;; seirios@Matrix.IRI.Co.JP |
| 10 | ;; Created: Jan 28 1998 |
| 11 | ;; Version: Alpha 0.2 |
| 12 | ;; Keywords: zebra bgpd ripd ripngd languages |
| 13 | |
| 14 | ;; You can get the latest version of zebra from |
| 15 | ;; |
| 16 | ;; http://www.zebra.org/ |
| 17 | ;; |
| 18 | ;; Install this Emacs Lisp code |
| 19 | ;; |
| 20 | ;; Compile zebra.el |
| 21 | ;; % $(EMACS) -batch -f batch-byte-compile zebra.el |
| 22 | ;; Install zebra.el,zebra.elc to Emacs-load-path |
| 23 | ;; % cp zebra.el zebra.elc $(emacs-load-path) |
| 24 | ;; Add .emacs or (site-load.el | site-start.el) |
| 25 | ;; (auto-load 'zebra-mode "zebra" nil t) |
| 26 | ;; (auto-load 'bgp-mode "zebra" nil t) |
| 27 | ;; (auto-load 'rip-mode "zebra" nil t) |
| 28 | ;; |
| 29 | |
| 30 | ;;; Code: |
| 31 | |
| 32 | ;; Set keywords |
| 33 | |
| 34 | (defvar zebra-font-lock-keywords |
| 35 | (list |
| 36 | '("#.*$" . font-lock-comment-face) |
| 37 | '("!.*$" . font-lock-comment-face) |
| 38 | '("no\\|interface" . font-lock-type-face) |
| 39 | '("ip6\\|ip\\|route\\|address" . font-lock-function-name-face) |
| 40 | '("ipforward\\|ipv6forward" . font-lock-keyword-face) |
| 41 | '("hostname\\|password\\|enable\\|logfile\\|no" . font-lock-keyword-face)) |
| 42 | "Default value to highlight in zebra mode.") |
| 43 | |
| 44 | (defvar bgp-font-lock-keywords |
| 45 | (list |
| 46 | '("#.*$" . font-lock-comment-face) |
| 47 | '("!.*$" . font-lock-comment-face) |
| 48 | '("no\\|router" . font-lock-type-face) |
| 49 | '("bgp\\|router-id\\|neighbor\\|network" . font-lock-function-name-face) |
| 50 | '("ebgp\\|multihop\\|next\\|zebra\\|remote-as" . font-lock-keyword-face) |
| 51 | '("hostname\\|password\\|enable\\|logfile\\|no" . font-lock-keyword-face)) |
| 52 | "Default value to highlight in bgp mode.") |
| 53 | |
| 54 | (defvar rip-font-lock-keywords |
| 55 | (list |
| 56 | '("#.*$" . font-lock-comment-face) |
| 57 | '("!.*$" . font-lock-comment-face) |
| 58 | '("no\\|router\\|interface\\|ipv6\\|ip6\\|ip" . font-lock-type-face) |
| 59 | '("ripng\\|rip\\|recive\\|advertize\\|accept" . font-lock-function-name-face) |
| 60 | '("version\\|network" . font-lock-function-name-face) |
| 61 | '("default\\|none\\|zebra" . font-lock-keyword-face) |
| 62 | '("hostname\\|password\\|enable\\|logfile\\|no" . font-lock-keyword-face)) |
| 63 | "Default value to highlight in bgp mode.") |
| 64 | |
| 65 | ;; set font-lock-mode |
| 66 | |
| 67 | (defun zebra-font-lock () |
| 68 | (make-local-variable 'font-lock-defaults) |
| 69 | (setq font-lock-defaults '(zebra-font-lock-keywords nil t))) |
| 70 | |
| 71 | (defun bgp-font-lock () |
| 72 | (make-local-variable 'font-lock-defaults) |
| 73 | (setq font-lock-defaults '(bgp-font-lock-keywords nil t))) |
| 74 | |
| 75 | (defun rip-font-lock () |
| 76 | (make-local-variable 'font-lock-defaults) |
| 77 | (setq font-lock-defaults '(rip-font-lock-keywords nil t))) |
| 78 | |
| 79 | ;; define Major mode |
| 80 | |
| 81 | (defun major-mode-define () |
| 82 | (interactive) |
| 83 | (progn |
| 84 | (setq comment-start "[#!]" |
| 85 | comment-end "" |
| 86 | comment-start-skip "!+ ") |
| 87 | (run-hooks 'zebra-mode-hook) |
| 88 | (cond |
| 89 | ((string< "20" emacs-version) |
| 90 | (font-lock-mode))))) |
| 91 | |
| 92 | (defun zebra-mode () |
| 93 | (progn |
| 94 | (setq mode-name "zebra") |
| 95 | (zebra-font-lock)) |
| 96 | (major-mode-define)) |
| 97 | |
| 98 | (defun bgp-mode () |
| 99 | (progn |
| 100 | (setq mode-name "bgp") |
| 101 | (bgp-font-lock)) |
| 102 | (major-mode-define)) |
| 103 | |
| 104 | (defun rip-mode () |
| 105 | (progn |
| 106 | (setq mode-name "rip") |
| 107 | (rip-font-lock)) |
| 108 | (major-mode-define)) |