annotate lisp/snmp-mode.el @ 27182:a4349e883944

ChangeLog
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Wed, 05 Jan 2000 12:29:41 +0000
parents bc3afd224741
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23144
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; snmp-mode.el --- SNMP & SNMPv2 MIB major mode.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1995,1998 Free Software Foundation, Inc.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5 ;; Author: Paul D. Smith <psmith@BayNetworks.com>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Keywords: data
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;; INTRODUCTION
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26 ;; ------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 ;; This package provides a major mode for editing SNMP MIBs. It
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;; provides all the modern Emacs 19 bells and whistles: default
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 ;; fontification via font-lock, imenu search functions, etc.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 ;; SNMP mode also uses tempo, a textual boilerplate insertion package
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 ;; distributed with Emacs, to add in boilerplate SNMP MIB structures.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 ;; See tempo.el for more details about tempo.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 ;; If you want to change or add new tempo templates, use the tempo tag
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 ;; list `snmp-tempo-tags' (or `snmpv2-tempo-tags'): this list is
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 ;; automatically installed when snmp-mode (or snmpv2-mode) is entered.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 ;; The SNMPv2 mode in this version has been enhanced thanks to popular
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 ;; demand.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 ;; I'm very interested in new tempo macros for both v1 and v2, and any
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 ;; other suggestions for enhancements (different syntax table items, new
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 ;; keybindings, etc.)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 ;; USAGE
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 ;; -----
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 ;; Mostly, use it as you would any other mode. There's a very
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 ;; simplistic auto-indent feature; hopefully it'll help more than get in
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 ;; your way. For the most part it tries to indent to the same level as
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 ;; the previous line. It will try to recognize some very simple tokens
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 ;; on the previous line that tell it to use extra indent or outdent.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 ;; Templates
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 ;; ---------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 ;; To use the Tempo templates, type the Tempo tag (or a unique prefix)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 ;; and use C-c C-i (C-c TAB) to complete it; if you don't have
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 ;; tempo-interactive set to nil it will ask you to fill in values.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 ;; Fields with predefined values (SYNTAX, STATUS, etc.) will do
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 ;; completing-reads on a list of valid values; use the normal SPC or TAB
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 ;; to complete.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 ;; Currently the following templates are available:
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 ;; objectType -- Defines an OBJECT-TYPE macro.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 ;; tableType -- Defines both a Table and Entry OBJECT-TYPE, and a
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 ;; SEQUENCE for the ASN.1 Entry definition.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 ;; Once the template is done, you can use C-cC-f and C-cC-b to move back
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 ;; and forth between the Tempo sequence points to fill in the rest of
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 ;; the information.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 ;; Font Lock
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 ;; ------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 ;; If you want font-lock in your MIB buffers, add this:
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 ;; (add-hook 'snmp-common-mode-hook 'turn-on-font-lock)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 ;; Enabling global-font-lock-mode is also sufficient.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 ;; Customize these:
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 (defgroup snmp nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 "Mode for editing SNMP MIB files."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 :group 'data
24553
bc3afd224741 (snmp): Fix defgroup :version.
Dave Love <fx@gnu.org>
parents: 24176
diff changeset
94 :version "20.4")
23144
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 (defcustom snmp-special-indent t
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 "*If non-nil, use a simple heuristic to try to guess the right indentation.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 If nil, then no special indentation is attempted."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 :type 'boolean
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 :group 'snmp)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 (defcustom snmp-indent-level 4
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 "*Indentation level for SNMP MIBs."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 :type 'integer
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 :group 'snmp)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 (defcustom snmp-tab-always-indent nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 "*Non-nil means TAB should always reindent the current line.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 A value of nil means reindent if point is within the initial line indentation;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 otherwise insert a TAB."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 :type 'boolean
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 :group 'snmp)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 (defcustom snmp-completion-ignore-case t
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 "*Non-nil means that case differences are ignored during completion.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 A value of nil means that case is significant.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 This is used during Tempo template completion."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 :type 'boolean
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 :group 'snmp)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 (defcustom snmp-common-mode-hook nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 "*Hook(s) evaluated when a buffer enters either SNMP or SNMPv2 mode."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 :type 'hook
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 :group 'snmp)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 (defcustom snmp-mode-hook nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 "*Hook(s) evaluated when a buffer enters SNMP mode."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 :type 'hook
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 :group 'snmp)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 (defcustom snmpv2-mode-hook nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 "*Hook(s) evaluated when a buffer enters SNMPv2 mode."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 :type 'hook
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 :group 'snmp)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 (defvar snmp-tempo-tags nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 "*Tempo tags for SNMP mode.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 (defvar snmpv2-tempo-tags nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 "*Tempo tags for SNMPv2 mode.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 ;; Enable fontification for SNMP MIBs
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 ;; These are pretty basic fontifications. Note we assume these macros
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 ;; are first on a line (except whitespace), to speed up fontification.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 (defvar snmp-font-lock-keywords-1
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 (list
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 ;; OBJECT-TYPE, TRAP-TYPE, and OBJECT-IDENTIFIER macros
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 '("^[ \t]*\\([a-z][-a-zA-Z0-9]+\\)[ \t]+\\(\\(MODULE-\\(COMPLIANCE\\|IDENTITY\\)\\|OBJECT-\\(COMPLIANCE\\|GROUP\\|IDENTITY\\|TYPE\\)\\|TRAP-\\(GROUP\\|TYPE\\)\\)\\|\\(OBJECT\\)[ \t]+\\(IDENTIFIER\\)[ \t]*::=\\)"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 (1 font-lock-variable-name-face) (3 font-lock-keyword-face nil t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 (7 font-lock-keyword-face nil t) (8 font-lock-keyword-face nil t))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 ;; DEFINITIONS clause
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 '("^[ \t]*\\([A-Z][-a-zA-Z0-9]+\\)[ \t]+\\(DEFINITIONS\\)[ \t]*::="
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 (1 font-lock-function-name-face) (2 font-lock-keyword-face))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 )
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 "Basic SNMP MIB mode expression highlighting.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 (defvar snmp-font-lock-keywords-2
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 (append
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 '(("ACCESS\\|BEGIN\\|DE\\(FVAL\\|SCRIPTION\\)\\|END\\|FROM\\|I\\(MPORTS\\|NDEX\\)\\|S\\(TATUS\\|YNTAX\\)"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 (0 font-lock-keyword-face)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 snmp-font-lock-keywords-1)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 "Medium SNMP MIB mode expression highlighting.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 (defvar snmp-font-lock-keywords-3
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (append
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 '(("\\([^\n]+\\)[ \t]+::=[ \t]+\\(SEQUENCE\\)[ \t]+{"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 (1 font-lock-reference-face) (2 font-lock-keyword-face))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 ("::=[ \t]*{[ \t]*\\([a-z0-9].*[ \t]+\\)?\\([0-9]+\\)[ \t]*}"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 (1 font-lock-reference-face nil t) (2 font-lock-variable-name-face)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 snmp-font-lock-keywords-2)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 "Gaudy SNMP MIB mode expression highlighting.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (defvar snmp-font-lock-keywords snmp-font-lock-keywords-1
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 "Default SNMP MIB mode expression highlighting.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 ;; These lists are used for the completion capabilities in the tempo
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 ;; templates.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 (defvar snmp-mode-syntax-list nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 "Predefined types for SYNTAX clauses.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 (defvar snmp-rfc1155-types
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 '(("INTEGER") ("OCTET STRING") ("OBJECT IDENTIFIER") ("NULL") ("IpAddress")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 ("NetworkAddress") ("Counter") ("Gauge") ("TimeTicks") ("Opaque"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 "Types from RFC 1155 v1 SMI.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 (defvar snmp-rfc1213-types
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 '(("DisplayString"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 "Types from RFC 1213 MIB-II.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 (defvar snmp-rfc1902-types
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 '(("INTEGER") ("OCTET STRING") ("OBJECT IDENTIFIER") ("Integer32")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 ("IpAddress") ("Counter32") ("Gauge32") ("Unsigned32") ("TimeTicks")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 ("Opaque") ("Counter64"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 "Types from RFC 1902 v2 SMI.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204 (defvar snmp-rfc1903-types
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 '(("DisplayString") ("PhysAddress") ("MacAddress") ("TruthValue")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 ("TestAndIncr") ("AutonomousType") ("InstancePointer")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207 ("VariablePointer") ("RowPointer") ("RowStatus") ("TimeStamp")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 ("TimeInterval") ("DateAndTime") ("StorageType") ("TDomain")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209 ("TAddress"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 "Types from RFC 1903 Textual Conventions.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 (defvar snmp-mode-access-list nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214 "Predefined values for ACCESS clauses.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 (defvar snmp-rfc1155-access
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 '(("read-only") ("read-write") ("write-only") ("not-accessible"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 "ACCESS values from RFC 1155 v1 SMI.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220 (defvar snmp-rfc1902-access
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221 '(("read-only") ("read-write") ("read-create") ("not-accessible")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 ("accessible-for-notify"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
223 "ACCESS values from RFC 1155 v1 SMI.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226 (defvar snmp-mode-status-list nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
227 "Predefined values for STATUS clauses.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 (defvar snmp-rfc1212-status
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
230 '(("mandatory") ("obsolete") ("deprecated"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231 "STATUS values from RFC 1212 v1 SMI.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
232
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
233 (defvar snmp-rfc1902-status
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
234 '(("current") ("obsolete") ("deprecated"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
235 "STATUS values from RFC 1902 v2 SMI.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
236
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
237
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
238 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
241 ;; Nothing to customize below here.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
242 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
247 ;; Need this stuff when compiling for imenu macros, etc.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
249 (eval-when-compile
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250 (require 'cl)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251 (require 'imenu))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254 ;; Create abbrev table for SNMP MIB mode
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256 (defvar snmp-mode-abbrev-table nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257 "Abbrev table in use in SNMP mode.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
258 (define-abbrev-table 'snmp-mode-abbrev-table ())
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
260
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
261 ;; Create abbrev table for SNMPv2 mode
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
262 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
263 (defvar snmpv2-mode-abbrev-table nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264 "Abbrev table in use in SNMPv2 mode.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 (define-abbrev-table 'snmpv2-mode-abbrev-table ())
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
267
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
268 ;; Set up our keymap
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
269 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
270 (defvar snmp-mode-map (make-sparse-keymap)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
271 "Keymap used in SNMP mode.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273 (define-key snmp-mode-map "\t" 'snmp-indent-command)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 (define-key snmp-mode-map "\177" 'backward-delete-char-untabify)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 (define-key snmp-mode-map "\C-c\C-i" 'tempo-complete-tag)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 (define-key snmp-mode-map "\C-c\C-f" 'tempo-forward-mark)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 (define-key snmp-mode-map "\C-c\C-b" 'tempo-backward-mark)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 ;; Set up our syntax table
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283 (defvar snmp-mode-syntax-table nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 "Syntax table used for buffers in SNMP mode.")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 (if snmp-mode-syntax-table
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 ()
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288 (setq snmp-mode-syntax-table (make-syntax-table))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289 (modify-syntax-entry ?\\ "\\" snmp-mode-syntax-table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 (modify-syntax-entry ?- "_ 1234" snmp-mode-syntax-table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291 (modify-syntax-entry ?\n ">" snmp-mode-syntax-table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292 (modify-syntax-entry ?\^m ">" snmp-mode-syntax-table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293 (modify-syntax-entry ?_ "." snmp-mode-syntax-table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 (modify-syntax-entry ?: "." snmp-mode-syntax-table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 (modify-syntax-entry ?= "." snmp-mode-syntax-table))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 ;; Set up the stuff that's common between snmp-mode and snmpv2-mode
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 (defun snmp-common-mode (name mode abbrev font-keywords imenu-index tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 (kill-all-local-variables)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 ;; Become the current major mode
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 (setq mode-name name)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 (setq major-mode mode)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 ;; Activate keymap, syntax table, and abbrev table
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 (use-local-map snmp-mode-map)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 (set-syntax-table snmp-mode-syntax-table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 (setq local-abbrev-table abbrev)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 ;; Set up paragraphs (?)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 (make-local-variable 'paragraph-start)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 (setq paragraph-start (concat "$\\|" page-delimiter))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 (make-local-variable 'paragraph-separate)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 (setq paragraph-separate paragraph-start)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316 (make-local-variable 'paragraph-ignore-fill-prefix)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 (setq paragraph-ignore-fill-prefix t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 ;; Set up comments
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 (make-local-variable 'comment-start)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 (setq comment-start "-- ")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 (make-local-variable 'comment-start-skip)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 (setq comment-start-skip "--+[ \t]*")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 (make-local-variable 'comment-column)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 (setq comment-column 40)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 (make-local-variable 'parse-sexp-ignore-comments)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 (setq parse-sexp-ignore-comments t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 ;; Set up indentation
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330 (make-local-variable 'indent-line-function)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 (setq indent-line-function (if snmp-special-indent
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332 'snmp-indent-line
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
333 'indent-to-left-margin))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
334
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335 ;; Font Lock
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336 (make-local-variable 'font-lock-defaults)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 (setq font-lock-defaults (cons font-keywords '(nil nil ((?- . "w 1234")))))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 ;; Imenu
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 (make-local-variable 'imenu-create-index-function)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 (setq imenu-create-index-function imenu-index)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 ;; Tempo
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 (tempo-use-tag-list tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 (make-local-variable 'tempo-match-finder)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 (setq tempo-match-finder "\\b\\(.+\\)\\=")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347 (make-local-variable 'tempo-interactive)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 (setq tempo-interactive t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 ;; Miscellaneous customization
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 (make-local-variable 'require-final-newline)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 (setq require-final-newline t))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 ;; SNMPv1 MIB Editing Mode.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 ;;
24176
077a147742fc (snmpv2-mode, snmpv-mode): Add autoload cookies -- see
Dave Love <fx@gnu.org>
parents: 23144
diff changeset
357 ;;;###autoload
23144
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 (defun snmp-mode ()
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 "Major mode for editing SNMP MIBs.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 Expression and list commands understand all C brackets.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 Tab indents for C code.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 Comments start with -- and end with newline or another --.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 Delete converts tabs to spaces as it moves back.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 \\{snmp-mode-map}
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365 Turning on snmp-mode runs the hooks in `snmp-common-mode-hook', then
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 `snmp-mode-hook'."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 (interactive)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 (snmp-common-mode "SNMP" 'snmp-mode
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 snmp-mode-abbrev-table
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 '(snmp-font-lock-keywords
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 snmp-font-lock-keywords-1
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 snmp-font-lock-keywords-2
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374 snmp-font-lock-keywords-3)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 'snmp-mode-imenu-create-index
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 'snmp-tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 ;; Completion lists
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 (make-local-variable 'snmp-mode-syntax-list)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 (setq snmp-mode-syntax-list (append snmp-rfc1155-types
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381 snmp-rfc1213-types
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 snmp-mode-syntax-list))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 (make-local-variable 'snmp-mode-access-list)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
384 (setq snmp-mode-access-list snmp-rfc1155-access)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
385 (make-local-variable 'snmp-mode-status-list)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386 (setq snmp-mode-status-list snmp-rfc1212-status)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 ;; Run hooks
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 (run-hooks 'snmp-common-mode-hook)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 (run-hooks 'snmp-mode-hook))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392
24176
077a147742fc (snmpv2-mode, snmpv-mode): Add autoload cookies -- see
Dave Love <fx@gnu.org>
parents: 23144
diff changeset
393 ;;;###autoload
23144
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 (defun snmpv2-mode ()
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 "Major mode for editing SNMPv2 MIBs.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 Expression and list commands understand all C brackets.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 Tab indents for C code.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 Comments start with -- and end with newline or another --.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 Delete converts tabs to spaces as it moves back.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 \\{snmp-mode-map}
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401 Turning on snmp-mode runs the hooks in `snmp-common-mode-hook',
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402 then `snmpv2-mode-hook'."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 (interactive)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
404
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
405 (snmp-common-mode "SNMPv2" 'snmpv2-mode
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 snmpv2-mode-abbrev-table
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407 '(snmp-font-lock-keywords
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408 snmp-font-lock-keywords-1
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
409 snmp-font-lock-keywords-2
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 snmp-font-lock-keywords-3)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411 'snmp-mode-imenu-create-index
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
412 'snmpv2-tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414 ;; Completion lists
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415 (make-local-variable 'snmp-mode-syntax-list)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 (setq snmp-mode-syntax-list (append snmp-rfc1902-types
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417 snmp-rfc1903-types
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 snmp-mode-syntax-list))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419 (make-local-variable 'snmp-mode-access-list)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 (setq snmp-mode-access-list snmp-rfc1902-access)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 (make-local-variable 'snmp-mode-status-list)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422 (setq snmp-mode-status-list snmp-rfc1902-status)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
424 ;; Run hooks
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425 (run-hooks 'snmp-common-mode-hook)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 (run-hooks 'snmpv2-mode-hook))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
428
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
431 ;; Indentation Setup
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
432 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
433 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
435 (defvar snmp-macro-open
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436 "[a-zA-Z][-a-zA-Z0-9]*[ \t]*\\(OBJECT\\|TRAP\\)-\\(TYPE\\|GROUP\\)\
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 \\|DESCRIPTION\\|IMPORTS\\|MODULE\\(-IDENTITY\\|-COMPLIANCE\\)\
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438 \\|.*::=[ \t]*\\(BEGIN\\|TEXTUAL-CONVENTION\\)[ \t]*$")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
440 (defvar snmp-macro-close
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
441 "::=[ \t]*{\\|\\(END\\|.*[;\"]\\)[ \t]*$")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
442
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443 (defun snmp-calculate-indent ()
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
444 "Calculate the current line indentation in SNMP MIB code.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
445
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446 We use a very simple scheme: if the previous non-empty line was a \"macro
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447 open\" string, add `snmp-indent-level' to it. If it was a \"macro close\"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 string, subtract `snmp-indent-level'. Otherwise, use the same indentation
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449 as the previous non-empty line. Note comments are considered empty
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
450 lines for the purposes of this function."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
451 (let ((empty (concat "\\([ \t]*\\)\\(" comment-start-skip "\\|$\\)"))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
452 (case-fold-search nil)) ; keywords must be in uppercase
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
453 (save-excursion
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454 (while (and (>= (forward-line -1) 0)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
455 (looking-at empty)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
456 (skip-chars-forward " \t")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
457 (+ (current-column)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
458 ;; Are we looking at a macro open string? If so, add more.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459 (cond ((looking-at snmp-macro-open)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460 snmp-indent-level)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 ;; macro close string? If so, remove some.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 ((looking-at snmp-macro-close)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 (- snmp-indent-level))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
464 ;; Neither; just stay here.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
465 (t 0))))))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467 (defun snmp-indent-line ()
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 "Indent current line as SNMP MIB code."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 (let ((indent (snmp-calculate-indent))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
470 (pos (- (point-max) (point)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 shift-amt beg end)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472 (beginning-of-line)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 (setq beg (point))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
474 (skip-chars-forward " \t")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 (setq shift-amt (- indent (current-column)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 (if (zerop shift-amt)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477 nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478 (delete-region beg (point))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479 (indent-to indent))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
480 ;; If initial point was within line's indentation,
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481 ;; position after the indentation. Else stay at same point in text.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482 (if (> (- (point-max) pos) (point))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483 (goto-char (- (point-max) pos)))))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
484
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485 (defun snmp-indent-command ()
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
486 "Indent current line as SNMP MIB code, or sometimes insert a TAB.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
487 If `snmp-tab-always-indent' is t, always reindent the current line when
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
488 this command is run.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489 If `snmp-tab-always-indent' is nil, reindent the current line if point is
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490 in the initial indentation. Otherwise, insert a TAB."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
491 (interactive)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492 (if (and (not snmp-tab-always-indent)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
493 (save-excursion
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
494 (skip-chars-backward " \t")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
495 (not (bolp))))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
496 (insert-tab)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
497 (snmp-indent-line)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
498
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
499
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
501 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
502 ;; Imenu Setup
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
504 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
505
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
506 (defvar snmp-clause-regexp
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
507 "^[ \t]*\\([a-zA-Z][-a-zA-Z0-9]*\\)[ \t\n]*\
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
508 \\(TRAP-TYPE\\|::=\\|OBJECT\\(-TYPE[ \t\n]+SYNTAX\\|[ \t\n]+IDENTIFIER[ \t\n]*::=\\)\\)")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
509
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
510 (defun snmp-mode-imenu-create-index ()
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511 (let ((index-alist '())
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 (index-oid-alist '())
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 (index-tc-alist '())
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 (index-table-alist '())
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 (index-trap-alist '())
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 (case-fold-search nil) ; keywords must be uppercase
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 prev-pos token marker end)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518 (goto-char (point-min))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519 (imenu-progress-message prev-pos 0)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520 ;; Search for a useful MIB item (that's not in a comment)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521 (save-match-data
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 (while (re-search-forward snmp-clause-regexp nil t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523 (imenu-progress-message prev-pos)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524 (setq
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525 end (match-end 0)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 token (cons (buffer-substring (match-beginning 1) (match-end 1))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
527 (set-marker (make-marker) (match-beginning 1))))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
528 (goto-char (match-beginning 2))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
529 (cond ((looking-at "OBJECT-TYPE[ \t\n]+SYNTAX")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530 (push token index-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
531 ((looking-at "OBJECT[ \t\n]+IDENTIFIER[ \t\n]*::=")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
532 (push token index-oid-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533 ((looking-at "::=[ \t\n]*SEQUENCE[ \t\n]*{")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534 (push token index-table-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535 ((looking-at "TRAP-TYPE")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 (push token index-trap-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 ((looking-at "::=")
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
538 (push token index-tc-alist)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539 (goto-char end)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
540 ;; Create the menu
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
541 (imenu-progress-message prev-pos 100)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 (setq index-alist (nreverse index-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
543 (and index-tc-alist
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544 (push (cons "Textual Conventions" (nreverse index-tc-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
545 index-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546 (and index-trap-alist
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547 (push (cons "Traps" (nreverse index-trap-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548 index-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
549 (and index-table-alist
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550 (push (cons "Tables" (nreverse index-table-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
551 index-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
552 (and index-oid-alist
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553 (push (cons "Object IDs" (nreverse index-oid-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
554 index-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
555 index-alist))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
556
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
560 ;; Tempo Setup
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
561 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
562 ;;;----------------------------------------------------------------------------
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
563
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
564 (require 'tempo)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
566 ;; Perform a completing-read with info given
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
567 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
568 (defun snmp-completing-read (prompt table &optional pred require init hist)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
569 "Read from the minibuffer, with completion.
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
570 Like `completing-read', but the variable `snmp-completion-ignore-case'
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
571 controls whether case is significant."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
572 (let ((completion-ignore-case snmp-completion-ignore-case))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
573 (completing-read prompt table pred require init hist)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
574
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
575 ;; OBJECT-TYPE macro template
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577 (tempo-define-template "snmp-object-type"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578 '(> (P "Object Label: ") " OBJECT-TYPE" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
579 "SYNTAX "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 (if tempo-interactive
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
582 p) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
583 "ACCESS "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
584 (if tempo-interactive
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
585 (snmp-completing-read "Access: " snmp-mode-access-list nil t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
586 p) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
587 "STATUS "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
588 (if tempo-interactive
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
589 (snmp-completing-read "Status: " snmp-mode-status-list nil t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
590 p) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
591 "DESCRIPTION" n> "\"" p "\"" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
592 (P "Default Value: " defval t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
593 (if (string= "" (tempo-lookup-named 'defval))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
594 nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
595 '(l "DEFVAL { " (s defval) " }" n>))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596 "::= { " (p "OID: ") " }" n)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 "objectType"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 "Insert an OBJECT-TYPE macro."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599 'snmp-tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
600
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601 ;; Table macro template
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
602 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
603 (tempo-define-template "snmp-table-type"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
604 ;; First the table OBJECT-TYPE
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
605 '(> (P "Table Name: " table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
606 (P "Entry Name: " entry t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
607 (let* ((entry (tempo-lookup-named 'entry))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608 (seq (copy-sequence entry)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
609 (aset entry 0 (downcase (aref entry 0)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
610 (aset seq 0 (upcase (aref seq 0)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611 (tempo-save-named 'obj-entry entry)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612 (tempo-save-named 'seq-entry seq)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 nil)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614 " OBJECT-TYPE" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 "SYNTAX SEQUENCE OF "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616 (s seq-entry) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
617 "ACCESS not-accessible" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618 "STATUS mandatory" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
619 "DESCRIPTION" n> "\"" p "\"" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
620 "::= { " (p "OID: ") " }" n n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621 ;; Next the row OBJECT-TYPE
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
622 (s obj-entry) " OBJECT-TYPE" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
623 "SYNTAX " (s seq-entry) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 "ACCESS not-accessible" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
625 "STATUS mandatory" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 "DESCRIPTION" n> "\"" p "\"" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 "INDEX { " (p "Index List: ") " }" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628 "::= {" (s table) " 1 }" n n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 ;; Finally the SEQUENCE type
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
630 (s seq-entry) " ::= SEQUENCE {" n> p n> "}" n)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
631 "tableType"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
632 "Insert an SNMP table."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
633 'snmp-tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
634
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
636 ;; v2 SMI OBJECT-TYPE macro template
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638 (tempo-define-template "snmpv2-object-type"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
639 '(> (P "Object Label: ") " OBJECT-TYPE" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
640 "SYNTAX "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641 (if tempo-interactive
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643 p) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
644 "MAX-ACCESS "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
645 (if tempo-interactive
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
646 (snmp-completing-read "Max Access: " snmp-mode-access-list nil t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 p) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648 "STATUS "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
649 (if tempo-interactive
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650 (snmp-completing-read "Status: " snmp-mode-status-list nil t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651 p) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
652 "DESCRIPTION" n> "\"" p "\"" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653 (P "Default Value: " defval t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 (if (string= "" (tempo-lookup-named 'defval))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655 nil
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656 '(l "DEFVAL { " (s defval) " }" n>))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
657 "::= { " (p "OID: ") " }" n)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 "objectType"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
659 "Insert an v2 SMI OBJECT-TYPE macro."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
660 'snmpv2-tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
661
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
662 ;; v2 SMI Table macro template
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
663 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
664 (tempo-define-template "snmpv2-table-type"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
665 ;; First the table OBJECT-TYPE
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
666 '(> (P "Table Name: " table)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
667 (P "Entry Name: " entry t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668 (let* ((entry (tempo-lookup-named 'entry))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
669 (seq (copy-sequence entry)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
670 (aset entry 0 (downcase (aref entry 0)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
671 (aset seq 0 (upcase (aref seq 0)))
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672 (tempo-save-named 'obj-entry entry)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
673 (tempo-save-named 'seq-entry seq)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
674 nil)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 " OBJECT-TYPE" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676 "SYNTAX SEQUENCE OF "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 (s seq-entry) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678 "MAX-ACCESS not-accessible" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 "STATUS current" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
680 "DESCRIPTION" n> "\"" p "\"" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 "::= { " (p "OID: ") " }" n n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
682 ;; Next the row OBJECT-TYPE
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
683 (s obj-entry) " OBJECT-TYPE" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
684 "SYNTAX " (s seq-entry) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
685 "MAX-ACCESS not-accessible" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
686 "STATUS current" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
687 "DESCRIPTION" n> "\"" p "\"" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
688 "INDEX { " (p "Index List: ") " }" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 "::= { " (s table) " 1 }" n n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690 ;; Finally the SEQUENCE type
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 (s seq-entry) " ::= SEQUENCE {" n> p n> "}" n)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 "tableType"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 "Insert an v2 SMI SNMP table."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 'snmpv2-tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696 ;; v2 SMI TEXTUAL-CONVENTION macro template
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 ;;
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 (tempo-define-template "snmpv2-textual-convention"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 '(> (P "Texual Convention Type: ") " ::= TEXTUAL-CONVENTION" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 "STATUS "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
701 (if tempo-interactive
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 (snmp-completing-read "Status: " snmp-mode-status-list nil t)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 p) n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
704 "DESCRIPTION" n> "\"" p "\"" n>
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
705 "SYNTAX "
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
706 (if tempo-interactive
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708 p) n> )
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 "textualConvention"
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
710 "Insert an v2 SMI TEXTUAL-CONVENTION macro."
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
711 'snmpv2-tempo-tags)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
712
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
713
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 (provide 'snmp-mode)
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715
44cb6e3cab44 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 ;; snmp-mode.el ends here