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