zebra.el 3.1 KB

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