Function: snmp-calculate-indent

snmp-calculate-indent is a byte-compiled function defined in snmp-mode.el.gz.

Signature

(snmp-calculate-indent)

Documentation

Calculate the current line indentation in SNMP MIB code.

We use a very simple scheme: if the previous non-empty line was a "macro open" string, add snmp-indent-level to it. If it was a "macro close" string, subtract snmp-indent-level. Otherwise, use the same indentation as the previous non-empty line. Note comments are considered empty lines for the purposes of this function.

Source Code

;; Defined in /usr/src/emacs/lisp/net/snmp-mode.el.gz
(defun snmp-calculate-indent ()
  "Calculate the current line indentation in SNMP MIB code.

We use a very simple scheme: if the previous non-empty line was a \"macro
open\" string, add `snmp-indent-level' to it.  If it was a \"macro close\"
string, subtract `snmp-indent-level'.  Otherwise, use the same indentation
as the previous non-empty line.  Note comments are considered empty
lines for the purposes of this function."
  (let ((empty (concat "\\([ \t]*\\)\\(" comment-start-skip "\\|$\\)"))
        (case-fold-search nil)) ; keywords must be in uppercase
    (save-excursion
      (while (and (>= (forward-line -1) 0)
                  (looking-at empty)))
      (skip-chars-forward " \t")
      (+ (current-column)
         ;; Are we looking at a macro open string?  If so, add more.
         (cond ((looking-at snmp-macro-open)
                snmp-indent-level)
               ;; macro close string?  If so, remove some.
               ((looking-at snmp-macro-close)
                (- snmp-indent-level))
               ;; Neither; just stay here.
               (t 0))))))