1 ;;; snmp-mode.el --- SNMP & SNMPv2 MIB major mode
3 ;; Copyright (C) 1995, 1998, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Author: Paul D. Smith <psmith@BayNetworks.com>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
30 ;; This package provides a major mode for editing SNMP MIBs. It
31 ;; provides all the modern Emacs 19 bells and whistles: default
32 ;; fontification via font-lock, imenu search functions, etc.
34 ;; SNMP mode also uses tempo, a textual boilerplate insertion package
35 ;; distributed with Emacs, to add in boilerplate SNMP MIB structures.
36 ;; See tempo.el for more details about tempo.
38 ;; If you want to change or add new tempo templates, use the tempo tag
39 ;; list `snmp-tempo-tags' (or `snmpv2-tempo-tags'): this list is
40 ;; automatically installed when snmp-mode (or snmpv2-mode) is entered.
42 ;; The SNMPv2 mode in this version has been enhanced thanks to popular
45 ;; I'm very interested in new tempo macros for both v1 and v2, and any
46 ;; other suggestions for enhancements (different syntax table items, new
52 ;; Mostly, use it as you would any other mode. There's a very
53 ;; simplistic auto-indent feature; hopefully it'll help more than get in
54 ;; your way. For the most part it tries to indent to the same level as
55 ;; the previous line. It will try to recognize some very simple tokens
56 ;; on the previous line that tell it to use extra indent or outdent.
60 ;; To use the Tempo templates, type the Tempo tag (or a unique prefix)
61 ;; and use C-c C-i (C-c TAB) to complete it; if you don't have
62 ;; tempo-interactive set to nil it will ask you to fill in values.
63 ;; Fields with predefined values (SYNTAX, STATUS, etc.) will do
64 ;; completing-reads on a list of valid values; use the normal SPC or TAB
67 ;; Currently the following templates are available:
69 ;; objectType -- Defines an OBJECT-TYPE macro.
71 ;; tableType -- Defines both a Table and Entry OBJECT-TYPE, and a
72 ;; SEQUENCE for the ASN.1 Entry definition.
74 ;; Once the template is done, you can use C-cC-f and C-cC-b to move back
75 ;; and forth between the Tempo sequence points to fill in the rest of
81 ;; If you want font-lock in your MIB buffers, add this:
83 ;; (add-hook 'snmp-common-mode-hook 'turn-on-font-lock)
85 ;; Enabling global-font-lock-mode is also sufficient.
93 ;;;----------------------------------------------------------------------------
97 ;;;----------------------------------------------------------------------------
100 "Mode for editing SNMP MIB files."
104 (defcustom snmp-special-indent t
105 "*If non-nil, use a simple heuristic to try to guess the right indentation.
106 If nil, then no special indentation is attempted."
110 (defcustom snmp-indent-level
4
111 "*Indentation level for SNMP MIBs."
115 (defcustom snmp-tab-always-indent nil
116 "*Non-nil means TAB should always reindent the current line.
117 A value of nil means reindent if point is within the initial line indentation;
118 otherwise insert a TAB."
122 (defcustom snmp-completion-ignore-case t
123 "*Non-nil means that case differences are ignored during completion.
124 A value of nil means that case is significant.
125 This is used during Tempo template completion."
129 (defcustom snmp-common-mode-hook nil
130 "*Hook(s) evaluated when a buffer enters either SNMP or SNMPv2 mode."
134 (defcustom snmp-mode-hook nil
135 "*Hook(s) evaluated when a buffer enters SNMP mode."
139 (defcustom snmpv2-mode-hook nil
140 "*Hook(s) evaluated when a buffer enters SNMPv2 mode."
144 (defvar snmp-tempo-tags nil
145 "*Tempo tags for SNMP mode.")
147 (defvar snmpv2-tempo-tags nil
148 "*Tempo tags for SNMPv2 mode.")
151 ;; Enable fontification for SNMP MIBs
154 ;; These are pretty basic fontifications. Note we assume these macros
155 ;; are first on a line (except whitespace), to speed up fontification.
157 (defvar snmp-font-lock-keywords-1
159 ;; OBJECT-TYPE, TRAP-TYPE, and OBJECT-IDENTIFIER macros
160 '("^[ \t]*\\([a-z][-a-zA-Z0-9]+\\)[ \t]+\\(\\(MODULE-\\(COMPLIANCE\\|IDENTITY\\)\\|OBJECT-\\(COMPLIANCE\\|GROUP\\|IDENTITY\\|TYPE\\)\\|TRAP-\\(GROUP\\|TYPE\\)\\)\\|\\(OBJECT\\)[ \t]+\\(IDENTIFIER\\)[ \t]*::=\\)"
161 (1 font-lock-variable-name-face
) (3 font-lock-keyword-face nil t
)
162 (7 font-lock-keyword-face nil t
) (8 font-lock-keyword-face nil t
))
164 ;; DEFINITIONS clause
165 '("^[ \t]*\\([A-Z][-a-zA-Z0-9]+\\)[ \t]+\\(DEFINITIONS\\)[ \t]*::="
166 (1 font-lock-function-name-face
) (2 font-lock-keyword-face
))
168 "Basic SNMP MIB mode expression highlighting.")
170 (defvar snmp-font-lock-keywords-2
172 '(("ACCESS\\|BEGIN\\|DE\\(FVAL\\|SCRIPTION\\)\\|END\\|FROM\\|I\\(MPORTS\\|NDEX\\)\\|S\\(TATUS\\|YNTAX\\)"
173 (0 font-lock-keyword-face
)))
174 snmp-font-lock-keywords-1
)
175 "Medium SNMP MIB mode expression highlighting.")
177 (defvar snmp-font-lock-keywords-3
179 '(("\\([^\n]+\\)[ \t]+::=[ \t]+\\(SEQUENCE\\)[ \t]+{"
180 (1 font-lock-reference-face
) (2 font-lock-keyword-face
))
181 ("::=[ \t]*{[ \t]*\\([a-z0-9].*[ \t]+\\)?\\([0-9]+\\)[ \t]*}"
182 (1 font-lock-reference-face nil t
) (2 font-lock-variable-name-face
)))
183 snmp-font-lock-keywords-2
)
184 "Gaudy SNMP MIB mode expression highlighting.")
186 (defvar snmp-font-lock-keywords snmp-font-lock-keywords-1
187 "Default SNMP MIB mode expression highlighting.")
190 ;; These lists are used for the completion capabilities in the tempo
194 (defvar snmp-mode-syntax-list nil
195 "Predefined types for SYNTAX clauses.")
197 (defvar snmp-rfc1155-types
198 '(("INTEGER") ("OCTET STRING") ("OBJECT IDENTIFIER") ("NULL") ("IpAddress")
199 ("NetworkAddress") ("Counter") ("Gauge") ("TimeTicks") ("Opaque"))
200 "Types from RFC 1155 v1 SMI.")
202 (defvar snmp-rfc1213-types
204 "Types from RFC 1213 MIB-II.")
206 (defvar snmp-rfc1902-types
207 '(("INTEGER") ("OCTET STRING") ("OBJECT IDENTIFIER") ("Integer32")
208 ("IpAddress") ("Counter32") ("Gauge32") ("Unsigned32") ("TimeTicks")
209 ("Opaque") ("Counter64"))
210 "Types from RFC 1902 v2 SMI.")
212 (defvar snmp-rfc1903-types
213 '(("DisplayString") ("PhysAddress") ("MacAddress") ("TruthValue")
214 ("TestAndIncr") ("AutonomousType") ("InstancePointer")
215 ("VariablePointer") ("RowPointer") ("RowStatus") ("TimeStamp")
216 ("TimeInterval") ("DateAndTime") ("StorageType") ("TDomain")
218 "Types from RFC 1903 Textual Conventions.")
221 (defvar snmp-mode-access-list nil
222 "Predefined values for ACCESS clauses.")
224 (defvar snmp-rfc1155-access
225 '(("read-only") ("read-write") ("write-only") ("not-accessible"))
226 "ACCESS values from RFC 1155 v1 SMI.")
228 (defvar snmp-rfc1902-access
229 '(("read-only") ("read-write") ("read-create") ("not-accessible")
230 ("accessible-for-notify"))
231 "ACCESS values from RFC 1155 v1 SMI.")
234 (defvar snmp-mode-status-list nil
235 "Predefined values for STATUS clauses.")
237 (defvar snmp-rfc1212-status
238 '(("mandatory") ("obsolete") ("deprecated"))
239 "STATUS values from RFC 1212 v1 SMI.")
241 (defvar snmp-rfc1902-status
242 '(("current") ("obsolete") ("deprecated"))
243 "STATUS values from RFC 1902 v2 SMI.")
246 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
247 ;;;----------------------------------------------------------------------------
249 ;; Nothing to customize below here.
251 ;;;----------------------------------------------------------------------------
252 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
255 ;; Need this stuff when compiling for imenu macros, etc.
262 ;; Create abbrev table for SNMP MIB mode
264 (defvar snmp-mode-abbrev-table nil
265 "Abbrev table in use in SNMP mode.")
266 (define-abbrev-table 'snmp-mode-abbrev-table
())
269 ;; Create abbrev table for SNMPv2 mode
271 (defvar snmpv2-mode-abbrev-table nil
272 "Abbrev table in use in SNMPv2 mode.")
273 (define-abbrev-table 'snmpv2-mode-abbrev-table
())
278 (defvar snmp-mode-map
(make-sparse-keymap)
279 "Keymap used in SNMP mode.")
281 (define-key snmp-mode-map
"\t" 'snmp-indent-command
)
282 (define-key snmp-mode-map
"\177" 'backward-delete-char-untabify
)
284 (define-key snmp-mode-map
"\C-c\C-i" 'tempo-complete-tag
)
285 (define-key snmp-mode-map
"\C-c\C-f" 'tempo-forward-mark
)
286 (define-key snmp-mode-map
"\C-c\C-b" 'tempo-backward-mark
)
289 ;; Set up our syntax table
291 (defvar snmp-mode-syntax-table nil
292 "Syntax table used for buffers in SNMP mode.")
294 (if snmp-mode-syntax-table
296 (setq snmp-mode-syntax-table
(make-syntax-table))
297 (modify-syntax-entry ?
\\ "\\" snmp-mode-syntax-table
)
298 (modify-syntax-entry ?-
"_ 1234" snmp-mode-syntax-table
)
299 (modify-syntax-entry ?
\n ">" snmp-mode-syntax-table
)
300 (modify-syntax-entry ?\^m
">" snmp-mode-syntax-table
)
301 (modify-syntax-entry ?_
"." snmp-mode-syntax-table
)
302 (modify-syntax-entry ?
: "." snmp-mode-syntax-table
)
303 (modify-syntax-entry ?
= "." snmp-mode-syntax-table
))
305 ;; Set up the stuff that's common between snmp-mode and snmpv2-mode
307 (defun snmp-common-mode (name mode abbrev font-keywords imenu-index tempo-tags
)
308 (kill-all-local-variables)
310 ;; Become the current major mode
311 (setq mode-name name
)
312 (setq major-mode mode
)
314 ;; Activate keymap, syntax table, and abbrev table
315 (use-local-map snmp-mode-map
)
316 (set-syntax-table snmp-mode-syntax-table
)
317 (setq local-abbrev-table abbrev
)
319 ;; Set up paragraphs (?)
320 (make-local-variable 'paragraph-start
)
321 (setq paragraph-start
(concat "$\\|" page-delimiter
))
322 (make-local-variable 'paragraph-separate
)
323 (setq paragraph-separate paragraph-start
)
324 (make-local-variable 'paragraph-ignore-fill-prefix
)
325 (setq paragraph-ignore-fill-prefix t
)
328 (make-local-variable 'comment-start
)
329 (setq comment-start
"-- ")
330 (make-local-variable 'comment-start-skip
)
331 (setq comment-start-skip
"--+[ \t]*")
332 (make-local-variable 'comment-column
)
333 (setq comment-column
40)
334 (make-local-variable 'parse-sexp-ignore-comments
)
335 (setq parse-sexp-ignore-comments t
)
337 ;; Set up indentation
338 (make-local-variable 'indent-line-function
)
339 (setq indent-line-function
(if snmp-special-indent
341 'indent-to-left-margin
))
344 (make-local-variable 'font-lock-defaults
)
345 (setq font-lock-defaults
(cons font-keywords
'(nil nil
((?- .
"w 1234")))))
348 (make-local-variable 'imenu-create-index-function
)
349 (setq imenu-create-index-function imenu-index
)
352 (tempo-use-tag-list tempo-tags
)
353 (make-local-variable 'tempo-match-finder
)
354 (setq tempo-match-finder
"\\b\\(.+\\)\\=")
355 (make-local-variable 'tempo-interactive
)
356 (setq tempo-interactive t
)
358 ;; Miscellaneous customization
359 (make-local-variable 'require-final-newline
)
360 (setq require-final-newline mode-require-final-newline
))
363 ;; SNMPv1 MIB Editing Mode.
367 "Major mode for editing SNMP MIBs.
368 Expression and list commands understand all C brackets.
369 Tab indents for C code.
370 Comments start with -- and end with newline or another --.
371 Delete converts tabs to spaces as it moves back.
373 Turning on snmp-mode runs the hooks in `snmp-common-mode-hook', then
377 (snmp-common-mode "SNMP" 'snmp-mode
378 snmp-mode-abbrev-table
379 '(snmp-font-lock-keywords
380 snmp-font-lock-keywords-1
381 snmp-font-lock-keywords-2
382 snmp-font-lock-keywords-3
)
383 'snmp-mode-imenu-create-index
387 (make-local-variable 'snmp-mode-syntax-list
)
388 (setq snmp-mode-syntax-list
(append snmp-rfc1155-types
390 snmp-mode-syntax-list
))
391 (make-local-variable 'snmp-mode-access-list
)
392 (setq snmp-mode-access-list snmp-rfc1155-access
)
393 (make-local-variable 'snmp-mode-status-list
)
394 (setq snmp-mode-status-list snmp-rfc1212-status
)
397 (run-mode-hooks 'snmp-common-mode-hook
'snmp-mode-hook
))
401 (defun snmpv2-mode ()
402 "Major mode for editing SNMPv2 MIBs.
403 Expression and list commands understand all C brackets.
404 Tab indents for C code.
405 Comments start with -- and end with newline or another --.
406 Delete converts tabs to spaces as it moves back.
408 Turning on snmp-mode runs the hooks in `snmp-common-mode-hook',
409 then `snmpv2-mode-hook'."
412 (snmp-common-mode "SNMPv2" 'snmpv2-mode
413 snmpv2-mode-abbrev-table
414 '(snmp-font-lock-keywords
415 snmp-font-lock-keywords-1
416 snmp-font-lock-keywords-2
417 snmp-font-lock-keywords-3
)
418 'snmp-mode-imenu-create-index
422 (make-local-variable 'snmp-mode-syntax-list
)
423 (setq snmp-mode-syntax-list
(append snmp-rfc1902-types
425 snmp-mode-syntax-list
))
426 (make-local-variable 'snmp-mode-access-list
)
427 (setq snmp-mode-access-list snmp-rfc1902-access
)
428 (make-local-variable 'snmp-mode-status-list
)
429 (setq snmp-mode-status-list snmp-rfc1902-status
)
432 (run-mode-hooks 'snmp-common-mode-hook
'snmpv2-mode-hook
))
435 ;;;----------------------------------------------------------------------------
439 ;;;----------------------------------------------------------------------------
441 (defvar snmp-macro-open
442 "[a-zA-Z][-a-zA-Z0-9]*[ \t]*\\(OBJECT\\|TRAP\\)-\\(TYPE\\|GROUP\\)\
443 \\|DESCRIPTION\\|IMPORTS\\|MODULE\\(-IDENTITY\\|-COMPLIANCE\\)\
444 \\|.*::=[ \t]*\\(BEGIN\\|TEXTUAL-CONVENTION\\)[ \t]*$")
446 (defvar snmp-macro-close
447 "::=[ \t]*{\\|\\(END\\|.*[;\"]\\)[ \t]*$")
449 (defun snmp-calculate-indent ()
450 "Calculate the current line indentation in SNMP MIB code.
452 We use a very simple scheme: if the previous non-empty line was a \"macro
453 open\" string, add `snmp-indent-level' to it. If it was a \"macro close\"
454 string, subtract `snmp-indent-level'. Otherwise, use the same indentation
455 as the previous non-empty line. Note comments are considered empty
456 lines for the purposes of this function."
457 (let ((empty (concat "\\([ \t]*\\)\\(" comment-start-skip
"\\|$\\)"))
458 (case-fold-search nil
)) ; keywords must be in uppercase
460 (while (and (>= (forward-line -
1) 0)
462 (skip-chars-forward " \t")
464 ;; Are we looking at a macro open string? If so, add more.
465 (cond ((looking-at snmp-macro-open
)
467 ;; macro close string? If so, remove some.
468 ((looking-at snmp-macro-close
)
469 (- snmp-indent-level
))
470 ;; Neither; just stay here.
473 (defun snmp-indent-line ()
474 "Indent current line as SNMP MIB code."
475 (let ((indent (snmp-calculate-indent))
476 (pos (- (point-max) (point)))
480 (skip-chars-forward " \t")
481 (setq shift-amt
(- indent
(current-column)))
482 (if (zerop shift-amt
)
484 (delete-region beg
(point))
486 ;; If initial point was within line's indentation,
487 ;; position after the indentation. Else stay at same point in text.
488 (if (> (- (point-max) pos
) (point))
489 (goto-char (- (point-max) pos
)))))
491 (defun snmp-indent-command ()
492 "Indent current line as SNMP MIB code, or sometimes insert a TAB.
493 If `snmp-tab-always-indent' is t, always reindent the current line when
495 If `snmp-tab-always-indent' is nil, reindent the current line if point is
496 in the initial indentation. Otherwise, insert a TAB."
498 (if (and (not snmp-tab-always-indent
)
500 (skip-chars-backward " \t")
506 ;;;----------------------------------------------------------------------------
510 ;;;----------------------------------------------------------------------------
512 (defvar snmp-clause-regexp
513 "^[ \t]*\\([a-zA-Z][-a-zA-Z0-9]*\\)[ \t\n]*\
514 \\(TRAP-TYPE\\|::=\\|OBJECT\\(-TYPE[ \t\n]+SYNTAX\\|[ \t\n]+IDENTIFIER[ \t\n]*::=\\)\\)")
516 (defun snmp-mode-imenu-create-index ()
517 (let ((index-alist '())
518 (index-oid-alist '())
520 (index-table-alist '())
521 (index-trap-alist '())
522 (case-fold-search nil
) ; keywords must be uppercase
523 prev-pos token marker end
)
524 (goto-char (point-min))
525 (imenu-progress-message prev-pos
0)
526 ;; Search for a useful MIB item (that's not in a comment)
528 (while (re-search-forward snmp-clause-regexp nil t
)
529 (imenu-progress-message prev-pos
)
532 token
(cons (buffer-substring (match-beginning 1) (match-end 1))
533 (set-marker (make-marker) (match-beginning 1))))
534 (goto-char (match-beginning 2))
535 (cond ((looking-at "OBJECT-TYPE[ \t\n]+SYNTAX")
536 (push token index-alist
))
537 ((looking-at "OBJECT[ \t\n]+IDENTIFIER[ \t\n]*::=")
538 (push token index-oid-alist
))
539 ((looking-at "::=[ \t\n]*SEQUENCE[ \t\n]*{")
540 (push token index-table-alist
))
541 ((looking-at "TRAP-TYPE")
542 (push token index-trap-alist
))
544 (push token index-tc-alist
)))
547 (imenu-progress-message prev-pos
100)
548 (setq index-alist
(nreverse index-alist
))
550 (push (cons "Textual Conventions" (nreverse index-tc-alist
))
552 (and index-trap-alist
553 (push (cons "Traps" (nreverse index-trap-alist
))
555 (and index-table-alist
556 (push (cons "Tables" (nreverse index-table-alist
))
559 (push (cons "Object IDs" (nreverse index-oid-alist
))
564 ;;;----------------------------------------------------------------------------
568 ;;;----------------------------------------------------------------------------
572 ;; Perform a completing-read with info given
574 (defun snmp-completing-read (prompt table
&optional pred require init hist
)
575 "Read from the minibuffer, with completion.
576 Like `completing-read', but the variable `snmp-completion-ignore-case'
577 controls whether case is significant."
578 (let ((completion-ignore-case snmp-completion-ignore-case
))
579 (completing-read prompt table pred require init hist
)))
581 ;; OBJECT-TYPE macro template
583 (tempo-define-template "snmp-object-type"
584 '(> (P "Object Label: ") " OBJECT-TYPE" n
>
586 (if tempo-interactive
587 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil
)
590 (if tempo-interactive
591 (snmp-completing-read "Access: " snmp-mode-access-list nil t
)
594 (if tempo-interactive
595 (snmp-completing-read "Status: " snmp-mode-status-list nil t
)
597 "DESCRIPTION" n
> "\"" p
"\"" n
>
598 (P "Default Value: " defval t
)
599 (if (string= "" (tempo-lookup-named 'defval
))
601 '(l "DEFVAL { " (s defval
) " }" n
>))
602 "::= { " (p "OID: ") " }" n
)
604 "Insert an OBJECT-TYPE macro."
607 ;; Table macro template
609 (tempo-define-template "snmp-table-type"
610 ;; First the table OBJECT-TYPE
611 '(> (P "Table Name: " table
)
612 (P "Entry Name: " entry t
)
613 (let* ((entry (tempo-lookup-named 'entry
))
614 (seq (copy-sequence entry
)))
615 (aset entry
0 (downcase (aref entry
0)))
616 (aset seq
0 (upcase (aref seq
0)))
617 (tempo-save-named 'obj-entry entry
)
618 (tempo-save-named 'seq-entry seq
)
621 "SYNTAX SEQUENCE OF "
623 "ACCESS not-accessible" n
>
624 "STATUS mandatory" n
>
625 "DESCRIPTION" n
> "\"" p
"\"" n
>
626 "::= { " (p "OID: ") " }" n n
>
627 ;; Next the row OBJECT-TYPE
628 (s obj-entry
) " OBJECT-TYPE" n
>
629 "SYNTAX " (s seq-entry
) n
>
630 "ACCESS not-accessible" n
>
631 "STATUS mandatory" n
>
632 "DESCRIPTION" n
> "\"" p
"\"" n
>
633 "INDEX { " (p "Index List: ") " }" n
>
634 "::= {" (s table
) " 1 }" n n
>
635 ;; Finally the SEQUENCE type
636 (s seq-entry
) " ::= SEQUENCE {" n
> p n
> "}" n
)
638 "Insert an SNMP table."
642 ;; v2 SMI OBJECT-TYPE macro template
644 (tempo-define-template "snmpv2-object-type"
645 '(> (P "Object Label: ") " OBJECT-TYPE" n
>
647 (if tempo-interactive
648 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil
)
651 (if tempo-interactive
652 (snmp-completing-read "Max Access: " snmp-mode-access-list nil t
)
655 (if tempo-interactive
656 (snmp-completing-read "Status: " snmp-mode-status-list nil t
)
658 "DESCRIPTION" n
> "\"" p
"\"" n
>
659 (P "Default Value: " defval t
)
660 (if (string= "" (tempo-lookup-named 'defval
))
662 '(l "DEFVAL { " (s defval
) " }" n
>))
663 "::= { " (p "OID: ") " }" n
)
665 "Insert an v2 SMI OBJECT-TYPE macro."
668 ;; v2 SMI Table macro template
670 (tempo-define-template "snmpv2-table-type"
671 ;; First the table OBJECT-TYPE
672 '(> (P "Table Name: " table
)
673 (P "Entry Name: " entry t
)
674 (let* ((entry (tempo-lookup-named 'entry
))
675 (seq (copy-sequence entry
)))
676 (aset entry
0 (downcase (aref entry
0)))
677 (aset seq
0 (upcase (aref seq
0)))
678 (tempo-save-named 'obj-entry entry
)
679 (tempo-save-named 'seq-entry seq
)
682 "SYNTAX SEQUENCE OF "
684 "MAX-ACCESS not-accessible" n
>
686 "DESCRIPTION" n
> "\"" p
"\"" n
>
687 "::= { " (p "OID: ") " }" n n
>
688 ;; Next the row OBJECT-TYPE
689 (s obj-entry
) " OBJECT-TYPE" n
>
690 "SYNTAX " (s seq-entry
) n
>
691 "MAX-ACCESS not-accessible" n
>
693 "DESCRIPTION" n
> "\"" p
"\"" n
>
694 "INDEX { " (p "Index List: ") " }" n
>
695 "::= { " (s table
) " 1 }" n n
>
696 ;; Finally the SEQUENCE type
697 (s seq-entry
) " ::= SEQUENCE {" n
> p n
> "}" n
)
699 "Insert an v2 SMI SNMP table."
702 ;; v2 SMI TEXTUAL-CONVENTION macro template
704 (tempo-define-template "snmpv2-textual-convention"
705 '(> (P "Texual Convention Type: ") " ::= TEXTUAL-CONVENTION" n
>
707 (if tempo-interactive
708 (snmp-completing-read "Status: " snmp-mode-status-list nil t
)
710 "DESCRIPTION" n
> "\"" p
"\"" n
>
712 (if tempo-interactive
713 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil
)
716 "Insert an v2 SMI TEXTUAL-CONVENTION macro."
722 ;;; arch-tag: eb6cc0f9-1e47-4023-8625-bc9aae6c3527
723 ;;; snmp-mode.el ends here