1 ;;; snmp-mode.el --- SNMP & SNMPv2 MIB major mode
3 ;; Copyright (C) 1995, 1998, 2002, 2005 Free Software Foundation, Inc.
5 ;; Author: Paul D. Smith <psmith@BayNetworks.com>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 ;; This package provides a major mode for editing SNMP MIBs. It
30 ;; provides all the modern Emacs 19 bells and whistles: default
31 ;; fontification via font-lock, imenu search functions, etc.
33 ;; SNMP mode also uses tempo, a textual boilerplate insertion package
34 ;; distributed with Emacs, to add in boilerplate SNMP MIB structures.
35 ;; See tempo.el for more details about tempo.
37 ;; If you want to change or add new tempo templates, use the tempo tag
38 ;; list `snmp-tempo-tags' (or `snmpv2-tempo-tags'): this list is
39 ;; automatically installed when snmp-mode (or snmpv2-mode) is entered.
41 ;; The SNMPv2 mode in this version has been enhanced thanks to popular
44 ;; I'm very interested in new tempo macros for both v1 and v2, and any
45 ;; other suggestions for enhancements (different syntax table items, new
51 ;; Mostly, use it as you would any other mode. There's a very
52 ;; simplistic auto-indent feature; hopefully it'll help more than get in
53 ;; your way. For the most part it tries to indent to the same level as
54 ;; the previous line. It will try to recognize some very simple tokens
55 ;; on the previous line that tell it to use extra indent or outdent.
59 ;; To use the Tempo templates, type the Tempo tag (or a unique prefix)
60 ;; and use C-c C-i (C-c TAB) to complete it; if you don't have
61 ;; tempo-interactive set to nil it will ask you to fill in values.
62 ;; Fields with predefined values (SYNTAX, STATUS, etc.) will do
63 ;; completing-reads on a list of valid values; use the normal SPC or TAB
66 ;; Currently the following templates are available:
68 ;; objectType -- Defines an OBJECT-TYPE macro.
70 ;; tableType -- Defines both a Table and Entry OBJECT-TYPE, and a
71 ;; SEQUENCE for the ASN.1 Entry definition.
73 ;; Once the template is done, you can use C-cC-f and C-cC-b to move back
74 ;; and forth between the Tempo sequence points to fill in the rest of
80 ;; If you want font-lock in your MIB buffers, add this:
82 ;; (add-hook 'snmp-common-mode-hook 'turn-on-font-lock)
84 ;; Enabling global-font-lock-mode is also sufficient.
92 ;;;----------------------------------------------------------------------------
96 ;;;----------------------------------------------------------------------------
99 "Mode for editing SNMP MIB files."
103 (defcustom snmp-special-indent t
104 "*If non-nil, use a simple heuristic to try to guess the right indentation.
105 If nil, then no special indentation is attempted."
109 (defcustom snmp-indent-level
4
110 "*Indentation level for SNMP MIBs."
114 (defcustom snmp-tab-always-indent nil
115 "*Non-nil means TAB should always reindent the current line.
116 A value of nil means reindent if point is within the initial line indentation;
117 otherwise insert a TAB."
121 (defcustom snmp-completion-ignore-case t
122 "*Non-nil means that case differences are ignored during completion.
123 A value of nil means that case is significant.
124 This is used during Tempo template completion."
128 (defcustom snmp-common-mode-hook nil
129 "*Hook(s) evaluated when a buffer enters either SNMP or SNMPv2 mode."
133 (defcustom snmp-mode-hook nil
134 "*Hook(s) evaluated when a buffer enters SNMP mode."
138 (defcustom snmpv2-mode-hook nil
139 "*Hook(s) evaluated when a buffer enters SNMPv2 mode."
143 (defvar snmp-tempo-tags nil
144 "*Tempo tags for SNMP mode.")
146 (defvar snmpv2-tempo-tags nil
147 "*Tempo tags for SNMPv2 mode.")
150 ;; Enable fontification for SNMP MIBs
153 ;; These are pretty basic fontifications. Note we assume these macros
154 ;; are first on a line (except whitespace), to speed up fontification.
156 (defvar snmp-font-lock-keywords-1
158 ;; OBJECT-TYPE, TRAP-TYPE, and OBJECT-IDENTIFIER macros
159 '("^[ \t]*\\([a-z][-a-zA-Z0-9]+\\)[ \t]+\\(\\(MODULE-\\(COMPLIANCE\\|IDENTITY\\)\\|OBJECT-\\(COMPLIANCE\\|GROUP\\|IDENTITY\\|TYPE\\)\\|TRAP-\\(GROUP\\|TYPE\\)\\)\\|\\(OBJECT\\)[ \t]+\\(IDENTIFIER\\)[ \t]*::=\\)"
160 (1 font-lock-variable-name-face
) (3 font-lock-keyword-face nil t
)
161 (7 font-lock-keyword-face nil t
) (8 font-lock-keyword-face nil t
))
163 ;; DEFINITIONS clause
164 '("^[ \t]*\\([A-Z][-a-zA-Z0-9]+\\)[ \t]+\\(DEFINITIONS\\)[ \t]*::="
165 (1 font-lock-function-name-face
) (2 font-lock-keyword-face
))
167 "Basic SNMP MIB mode expression highlighting.")
169 (defvar snmp-font-lock-keywords-2
171 '(("ACCESS\\|BEGIN\\|DE\\(FVAL\\|SCRIPTION\\)\\|END\\|FROM\\|I\\(MPORTS\\|NDEX\\)\\|S\\(TATUS\\|YNTAX\\)"
172 (0 font-lock-keyword-face
)))
173 snmp-font-lock-keywords-1
)
174 "Medium SNMP MIB mode expression highlighting.")
176 (defvar snmp-font-lock-keywords-3
178 '(("\\([^\n]+\\)[ \t]+::=[ \t]+\\(SEQUENCE\\)[ \t]+{"
179 (1 font-lock-reference-face
) (2 font-lock-keyword-face
))
180 ("::=[ \t]*{[ \t]*\\([a-z0-9].*[ \t]+\\)?\\([0-9]+\\)[ \t]*}"
181 (1 font-lock-reference-face nil t
) (2 font-lock-variable-name-face
)))
182 snmp-font-lock-keywords-2
)
183 "Gaudy SNMP MIB mode expression highlighting.")
185 (defvar snmp-font-lock-keywords snmp-font-lock-keywords-1
186 "Default SNMP MIB mode expression highlighting.")
189 ;; These lists are used for the completion capabilities in the tempo
193 (defvar snmp-mode-syntax-list nil
194 "Predefined types for SYNTAX clauses.")
196 (defvar snmp-rfc1155-types
197 '(("INTEGER") ("OCTET STRING") ("OBJECT IDENTIFIER") ("NULL") ("IpAddress")
198 ("NetworkAddress") ("Counter") ("Gauge") ("TimeTicks") ("Opaque"))
199 "Types from RFC 1155 v1 SMI.")
201 (defvar snmp-rfc1213-types
203 "Types from RFC 1213 MIB-II.")
205 (defvar snmp-rfc1902-types
206 '(("INTEGER") ("OCTET STRING") ("OBJECT IDENTIFIER") ("Integer32")
207 ("IpAddress") ("Counter32") ("Gauge32") ("Unsigned32") ("TimeTicks")
208 ("Opaque") ("Counter64"))
209 "Types from RFC 1902 v2 SMI.")
211 (defvar snmp-rfc1903-types
212 '(("DisplayString") ("PhysAddress") ("MacAddress") ("TruthValue")
213 ("TestAndIncr") ("AutonomousType") ("InstancePointer")
214 ("VariablePointer") ("RowPointer") ("RowStatus") ("TimeStamp")
215 ("TimeInterval") ("DateAndTime") ("StorageType") ("TDomain")
217 "Types from RFC 1903 Textual Conventions.")
220 (defvar snmp-mode-access-list nil
221 "Predefined values for ACCESS clauses.")
223 (defvar snmp-rfc1155-access
224 '(("read-only") ("read-write") ("write-only") ("not-accessible"))
225 "ACCESS values from RFC 1155 v1 SMI.")
227 (defvar snmp-rfc1902-access
228 '(("read-only") ("read-write") ("read-create") ("not-accessible")
229 ("accessible-for-notify"))
230 "ACCESS values from RFC 1155 v1 SMI.")
233 (defvar snmp-mode-status-list nil
234 "Predefined values for STATUS clauses.")
236 (defvar snmp-rfc1212-status
237 '(("mandatory") ("obsolete") ("deprecated"))
238 "STATUS values from RFC 1212 v1 SMI.")
240 (defvar snmp-rfc1902-status
241 '(("current") ("obsolete") ("deprecated"))
242 "STATUS values from RFC 1902 v2 SMI.")
245 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
246 ;;;----------------------------------------------------------------------------
248 ;; Nothing to customize below here.
250 ;;;----------------------------------------------------------------------------
251 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
254 ;; Need this stuff when compiling for imenu macros, etc.
261 ;; Create abbrev table for SNMP MIB mode
263 (defvar snmp-mode-abbrev-table nil
264 "Abbrev table in use in SNMP mode.")
265 (define-abbrev-table 'snmp-mode-abbrev-table
())
268 ;; Create abbrev table for SNMPv2 mode
270 (defvar snmpv2-mode-abbrev-table nil
271 "Abbrev table in use in SNMPv2 mode.")
272 (define-abbrev-table 'snmpv2-mode-abbrev-table
())
277 (defvar snmp-mode-map
(make-sparse-keymap)
278 "Keymap used in SNMP mode.")
280 (define-key snmp-mode-map
"\t" 'snmp-indent-command
)
281 (define-key snmp-mode-map
"\177" 'backward-delete-char-untabify
)
283 (define-key snmp-mode-map
"\C-c\C-i" 'tempo-complete-tag
)
284 (define-key snmp-mode-map
"\C-c\C-f" 'tempo-forward-mark
)
285 (define-key snmp-mode-map
"\C-c\C-b" 'tempo-backward-mark
)
288 ;; Set up our syntax table
290 (defvar snmp-mode-syntax-table nil
291 "Syntax table used for buffers in SNMP mode.")
293 (if snmp-mode-syntax-table
295 (setq snmp-mode-syntax-table
(make-syntax-table))
296 (modify-syntax-entry ?
\\ "\\" snmp-mode-syntax-table
)
297 (modify-syntax-entry ?-
"_ 1234" snmp-mode-syntax-table
)
298 (modify-syntax-entry ?
\n ">" snmp-mode-syntax-table
)
299 (modify-syntax-entry ?\^m
">" snmp-mode-syntax-table
)
300 (modify-syntax-entry ?_
"." snmp-mode-syntax-table
)
301 (modify-syntax-entry ?
: "." snmp-mode-syntax-table
)
302 (modify-syntax-entry ?
= "." snmp-mode-syntax-table
))
304 ;; Set up the stuff that's common between snmp-mode and snmpv2-mode
306 (defun snmp-common-mode (name mode abbrev font-keywords imenu-index tempo-tags
)
307 (kill-all-local-variables)
309 ;; Become the current major mode
310 (setq mode-name name
)
311 (setq major-mode mode
)
313 ;; Activate keymap, syntax table, and abbrev table
314 (use-local-map snmp-mode-map
)
315 (set-syntax-table snmp-mode-syntax-table
)
316 (setq local-abbrev-table abbrev
)
318 ;; Set up paragraphs (?)
319 (make-local-variable 'paragraph-start
)
320 (setq paragraph-start
(concat "$\\|" page-delimiter
))
321 (make-local-variable 'paragraph-separate
)
322 (setq paragraph-separate paragraph-start
)
323 (make-local-variable 'paragraph-ignore-fill-prefix
)
324 (setq paragraph-ignore-fill-prefix t
)
327 (make-local-variable 'comment-start
)
328 (setq comment-start
"-- ")
329 (make-local-variable 'comment-start-skip
)
330 (setq comment-start-skip
"--+[ \t]*")
331 (make-local-variable 'comment-column
)
332 (setq comment-column
40)
333 (make-local-variable 'parse-sexp-ignore-comments
)
334 (setq parse-sexp-ignore-comments t
)
336 ;; Set up indentation
337 (make-local-variable 'indent-line-function
)
338 (setq indent-line-function
(if snmp-special-indent
340 'indent-to-left-margin
))
343 (make-local-variable 'font-lock-defaults
)
344 (setq font-lock-defaults
(cons font-keywords
'(nil nil
((?- .
"w 1234")))))
347 (make-local-variable 'imenu-create-index-function
)
348 (setq imenu-create-index-function imenu-index
)
351 (tempo-use-tag-list tempo-tags
)
352 (make-local-variable 'tempo-match-finder
)
353 (setq tempo-match-finder
"\\b\\(.+\\)\\=")
354 (make-local-variable 'tempo-interactive
)
355 (setq tempo-interactive t
)
357 ;; Miscellaneous customization
358 (make-local-variable 'require-final-newline
)
359 (setq require-final-newline mode-require-final-newline
))
362 ;; SNMPv1 MIB Editing Mode.
366 "Major mode for editing SNMP MIBs.
367 Expression and list commands understand all C brackets.
368 Tab indents for C code.
369 Comments start with -- and end with newline or another --.
370 Delete converts tabs to spaces as it moves back.
372 Turning on snmp-mode runs the hooks in `snmp-common-mode-hook', then
376 (snmp-common-mode "SNMP" 'snmp-mode
377 snmp-mode-abbrev-table
378 '(snmp-font-lock-keywords
379 snmp-font-lock-keywords-1
380 snmp-font-lock-keywords-2
381 snmp-font-lock-keywords-3
)
382 'snmp-mode-imenu-create-index
386 (make-local-variable 'snmp-mode-syntax-list
)
387 (setq snmp-mode-syntax-list
(append snmp-rfc1155-types
389 snmp-mode-syntax-list
))
390 (make-local-variable 'snmp-mode-access-list
)
391 (setq snmp-mode-access-list snmp-rfc1155-access
)
392 (make-local-variable 'snmp-mode-status-list
)
393 (setq snmp-mode-status-list snmp-rfc1212-status
)
396 (run-mode-hooks 'snmp-common-mode-hook
'snmp-mode-hook
))
400 (defun snmpv2-mode ()
401 "Major mode for editing SNMPv2 MIBs.
402 Expression and list commands understand all C brackets.
403 Tab indents for C code.
404 Comments start with -- and end with newline or another --.
405 Delete converts tabs to spaces as it moves back.
407 Turning on snmp-mode runs the hooks in `snmp-common-mode-hook',
408 then `snmpv2-mode-hook'."
411 (snmp-common-mode "SNMPv2" 'snmpv2-mode
412 snmpv2-mode-abbrev-table
413 '(snmp-font-lock-keywords
414 snmp-font-lock-keywords-1
415 snmp-font-lock-keywords-2
416 snmp-font-lock-keywords-3
)
417 'snmp-mode-imenu-create-index
421 (make-local-variable 'snmp-mode-syntax-list
)
422 (setq snmp-mode-syntax-list
(append snmp-rfc1902-types
424 snmp-mode-syntax-list
))
425 (make-local-variable 'snmp-mode-access-list
)
426 (setq snmp-mode-access-list snmp-rfc1902-access
)
427 (make-local-variable 'snmp-mode-status-list
)
428 (setq snmp-mode-status-list snmp-rfc1902-status
)
431 (run-mode-hooks 'snmp-common-mode-hook
'snmpv2-mode-hook
))
434 ;;;----------------------------------------------------------------------------
438 ;;;----------------------------------------------------------------------------
440 (defvar snmp-macro-open
441 "[a-zA-Z][-a-zA-Z0-9]*[ \t]*\\(OBJECT\\|TRAP\\)-\\(TYPE\\|GROUP\\)\
442 \\|DESCRIPTION\\|IMPORTS\\|MODULE\\(-IDENTITY\\|-COMPLIANCE\\)\
443 \\|.*::=[ \t]*\\(BEGIN\\|TEXTUAL-CONVENTION\\)[ \t]*$")
445 (defvar snmp-macro-close
446 "::=[ \t]*{\\|\\(END\\|.*[;\"]\\)[ \t]*$")
448 (defun snmp-calculate-indent ()
449 "Calculate the current line indentation in SNMP MIB code.
451 We use a very simple scheme: if the previous non-empty line was a \"macro
452 open\" string, add `snmp-indent-level' to it. If it was a \"macro close\"
453 string, subtract `snmp-indent-level'. Otherwise, use the same indentation
454 as the previous non-empty line. Note comments are considered empty
455 lines for the purposes of this function."
456 (let ((empty (concat "\\([ \t]*\\)\\(" comment-start-skip
"\\|$\\)"))
457 (case-fold-search nil
)) ; keywords must be in uppercase
459 (while (and (>= (forward-line -
1) 0)
461 (skip-chars-forward " \t")
463 ;; Are we looking at a macro open string? If so, add more.
464 (cond ((looking-at snmp-macro-open
)
466 ;; macro close string? If so, remove some.
467 ((looking-at snmp-macro-close
)
468 (- snmp-indent-level
))
469 ;; Neither; just stay here.
472 (defun snmp-indent-line ()
473 "Indent current line as SNMP MIB code."
474 (let ((indent (snmp-calculate-indent))
475 (pos (- (point-max) (point)))
479 (skip-chars-forward " \t")
480 (setq shift-amt
(- indent
(current-column)))
481 (if (zerop shift-amt
)
483 (delete-region beg
(point))
485 ;; If initial point was within line's indentation,
486 ;; position after the indentation. Else stay at same point in text.
487 (if (> (- (point-max) pos
) (point))
488 (goto-char (- (point-max) pos
)))))
490 (defun snmp-indent-command ()
491 "Indent current line as SNMP MIB code, or sometimes insert a TAB.
492 If `snmp-tab-always-indent' is t, always reindent the current line when
494 If `snmp-tab-always-indent' is nil, reindent the current line if point is
495 in the initial indentation. Otherwise, insert a TAB."
497 (if (and (not snmp-tab-always-indent
)
499 (skip-chars-backward " \t")
505 ;;;----------------------------------------------------------------------------
509 ;;;----------------------------------------------------------------------------
511 (defvar snmp-clause-regexp
512 "^[ \t]*\\([a-zA-Z][-a-zA-Z0-9]*\\)[ \t\n]*\
513 \\(TRAP-TYPE\\|::=\\|OBJECT\\(-TYPE[ \t\n]+SYNTAX\\|[ \t\n]+IDENTIFIER[ \t\n]*::=\\)\\)")
515 (defun snmp-mode-imenu-create-index ()
516 (let ((index-alist '())
517 (index-oid-alist '())
519 (index-table-alist '())
520 (index-trap-alist '())
521 (case-fold-search nil
) ; keywords must be uppercase
522 prev-pos token marker end
)
523 (goto-char (point-min))
524 (imenu-progress-message prev-pos
0)
525 ;; Search for a useful MIB item (that's not in a comment)
527 (while (re-search-forward snmp-clause-regexp nil t
)
528 (imenu-progress-message prev-pos
)
531 token
(cons (buffer-substring (match-beginning 1) (match-end 1))
532 (set-marker (make-marker) (match-beginning 1))))
533 (goto-char (match-beginning 2))
534 (cond ((looking-at "OBJECT-TYPE[ \t\n]+SYNTAX")
535 (push token index-alist
))
536 ((looking-at "OBJECT[ \t\n]+IDENTIFIER[ \t\n]*::=")
537 (push token index-oid-alist
))
538 ((looking-at "::=[ \t\n]*SEQUENCE[ \t\n]*{")
539 (push token index-table-alist
))
540 ((looking-at "TRAP-TYPE")
541 (push token index-trap-alist
))
543 (push token index-tc-alist
)))
546 (imenu-progress-message prev-pos
100)
547 (setq index-alist
(nreverse index-alist
))
549 (push (cons "Textual Conventions" (nreverse index-tc-alist
))
551 (and index-trap-alist
552 (push (cons "Traps" (nreverse index-trap-alist
))
554 (and index-table-alist
555 (push (cons "Tables" (nreverse index-table-alist
))
558 (push (cons "Object IDs" (nreverse index-oid-alist
))
563 ;;;----------------------------------------------------------------------------
567 ;;;----------------------------------------------------------------------------
571 ;; Perform a completing-read with info given
573 (defun snmp-completing-read (prompt table
&optional pred require init hist
)
574 "Read from the minibuffer, with completion.
575 Like `completing-read', but the variable `snmp-completion-ignore-case'
576 controls whether case is significant."
577 (let ((completion-ignore-case snmp-completion-ignore-case
))
578 (completing-read prompt table pred require init hist
)))
580 ;; OBJECT-TYPE macro template
582 (tempo-define-template "snmp-object-type"
583 '(> (P "Object Label: ") " OBJECT-TYPE" n
>
585 (if tempo-interactive
586 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil
)
589 (if tempo-interactive
590 (snmp-completing-read "Access: " snmp-mode-access-list nil t
)
593 (if tempo-interactive
594 (snmp-completing-read "Status: " snmp-mode-status-list nil t
)
596 "DESCRIPTION" n
> "\"" p
"\"" n
>
597 (P "Default Value: " defval t
)
598 (if (string= "" (tempo-lookup-named 'defval
))
600 '(l "DEFVAL { " (s defval
) " }" n
>))
601 "::= { " (p "OID: ") " }" n
)
603 "Insert an OBJECT-TYPE macro."
606 ;; Table macro template
608 (tempo-define-template "snmp-table-type"
609 ;; First the table OBJECT-TYPE
610 '(> (P "Table Name: " table
)
611 (P "Entry Name: " entry t
)
612 (let* ((entry (tempo-lookup-named 'entry
))
613 (seq (copy-sequence entry
)))
614 (aset entry
0 (downcase (aref entry
0)))
615 (aset seq
0 (upcase (aref seq
0)))
616 (tempo-save-named 'obj-entry entry
)
617 (tempo-save-named 'seq-entry seq
)
620 "SYNTAX SEQUENCE OF "
622 "ACCESS not-accessible" n
>
623 "STATUS mandatory" n
>
624 "DESCRIPTION" n
> "\"" p
"\"" n
>
625 "::= { " (p "OID: ") " }" n n
>
626 ;; Next the row OBJECT-TYPE
627 (s obj-entry
) " OBJECT-TYPE" n
>
628 "SYNTAX " (s seq-entry
) n
>
629 "ACCESS not-accessible" n
>
630 "STATUS mandatory" n
>
631 "DESCRIPTION" n
> "\"" p
"\"" n
>
632 "INDEX { " (p "Index List: ") " }" n
>
633 "::= {" (s table
) " 1 }" n n
>
634 ;; Finally the SEQUENCE type
635 (s seq-entry
) " ::= SEQUENCE {" n
> p n
> "}" n
)
637 "Insert an SNMP table."
641 ;; v2 SMI OBJECT-TYPE macro template
643 (tempo-define-template "snmpv2-object-type"
644 '(> (P "Object Label: ") " OBJECT-TYPE" n
>
646 (if tempo-interactive
647 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil
)
650 (if tempo-interactive
651 (snmp-completing-read "Max Access: " snmp-mode-access-list nil t
)
654 (if tempo-interactive
655 (snmp-completing-read "Status: " snmp-mode-status-list nil t
)
657 "DESCRIPTION" n
> "\"" p
"\"" n
>
658 (P "Default Value: " defval t
)
659 (if (string= "" (tempo-lookup-named 'defval
))
661 '(l "DEFVAL { " (s defval
) " }" n
>))
662 "::= { " (p "OID: ") " }" n
)
664 "Insert an v2 SMI OBJECT-TYPE macro."
667 ;; v2 SMI Table macro template
669 (tempo-define-template "snmpv2-table-type"
670 ;; First the table OBJECT-TYPE
671 '(> (P "Table Name: " table
)
672 (P "Entry Name: " entry t
)
673 (let* ((entry (tempo-lookup-named 'entry
))
674 (seq (copy-sequence entry
)))
675 (aset entry
0 (downcase (aref entry
0)))
676 (aset seq
0 (upcase (aref seq
0)))
677 (tempo-save-named 'obj-entry entry
)
678 (tempo-save-named 'seq-entry seq
)
681 "SYNTAX SEQUENCE OF "
683 "MAX-ACCESS not-accessible" n
>
685 "DESCRIPTION" n
> "\"" p
"\"" n
>
686 "::= { " (p "OID: ") " }" n n
>
687 ;; Next the row OBJECT-TYPE
688 (s obj-entry
) " OBJECT-TYPE" n
>
689 "SYNTAX " (s seq-entry
) n
>
690 "MAX-ACCESS not-accessible" n
>
692 "DESCRIPTION" n
> "\"" p
"\"" n
>
693 "INDEX { " (p "Index List: ") " }" n
>
694 "::= { " (s table
) " 1 }" n n
>
695 ;; Finally the SEQUENCE type
696 (s seq-entry
) " ::= SEQUENCE {" n
> p n
> "}" n
)
698 "Insert an v2 SMI SNMP table."
701 ;; v2 SMI TEXTUAL-CONVENTION macro template
703 (tempo-define-template "snmpv2-textual-convention"
704 '(> (P "Texual Convention Type: ") " ::= TEXTUAL-CONVENTION" n
>
706 (if tempo-interactive
707 (snmp-completing-read "Status: " snmp-mode-status-list nil t
)
709 "DESCRIPTION" n
> "\"" p
"\"" n
>
711 (if tempo-interactive
712 (snmp-completing-read "Syntax: " snmp-mode-syntax-list nil nil
)
715 "Insert an v2 SMI TEXTUAL-CONVENTION macro."
721 ;;; arch-tag: eb6cc0f9-1e47-4023-8625-bc9aae6c3527
722 ;;; snmp-mode.el ends here